mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2013
Posts: 21
A
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Nov 2013
Posts: 21
okay so here i have some coding for a giveaway system, it is just I am having some problems, mainly with the actual original !giveaway command

How it works is u do !giveaway DonatorNameHere Name Of the Game Here


Code:
on *:text:!giveaway *:#:{
  if ($nick isop #) {
    %newgacommand = $1 
    %newgasponsor = $2 
    %newgatext = $1- 
    %newgast1 = $remove(%newgatext,%newgacommand) 
    %newgast2 = $remove(%newgast1,%newgasponsor)
    /write -c tempga.txt.txt
    /write tempga.txt %newgast2
    /write -c giveawayenters.txt
    %game = $read(tempga.txt)
    msg # A new giveaway has just been opened by $nick $+ , donated by %donor for a copy of $read(tempga.txt) $+ . To enter type !enter to be in with a chance of winning, you have 3 minutes to enter
    timer 1 120 msg # There is one minute left of this giveaway so get your !enter's in, BIG THANKS AGAIN TO $upper(%newgasponsor)
    timer 1 180 msg # $read(giveawayenters.txt) has just won this giveaway for a copy of $read(tempga.txt) $+ , big thanks to %newgasponsor for sponsoring this giveaway
  }
}

on *:text:!giveawaydraw:#:{
  var %winner2 $read(giveawayenters.txt)
  msg # The new winner is $upper(%winner2), thank you $upper(%newgasponsor) for sponsoring this giveaway for $read(tempga.txt) $+ . 
}


on *:text:!enter:#: {
  if ($read(giveawayenters.txt, nw, $nick)) {
    echo -a $nick is already in giveawayenters.txt
  }
  else {
    /write giveawayenters.txt $nick
    echo -a $nick is now in giveawayenters.txt
  }
}



The problem is that sometimes it displays different things for the game, and it never shows the $read(giveawayenters.txt) from the line that says timer 1 180

This is an example of what it says:

Quote:
[18:39] <@alphakennyv2> !giveaway alphakennyv2 The Other Other Fake Game
01[18:39] <@thealphabot> A new giveaway has just been opened by alphakennyv2, donated by for a copy of The Other Other Fake Game. To enter type !enter to be in with a chance of winning, you have 3 minutes to enter
[18:39] <@alphakennyv2> okay so the game name is now fixed
[18:39] <@alphakennyv2> !enter
[18:39] alphakennyv2 is now in giveawayenters.txt
01[18:41] <@thealphabot> There is one minute left of this giveaway so get your !enter's in, BIG THANKS AGAIN TO ALPHAKENNYV2
01[18:42] <@thealphabot> has just won this giveaway for a copy of Nothing cus this isnt a real giveaway, big thanks to alphakennyv2 for sponsoring this giveaway

Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
Quote:
The problem is that sometimes it displays different things for the game
That's because you typoed the filename, too many .txt here: /write -c tempga.txt.txt, since you use $read and its random function to grab a line from a file that is only one line (you should set a variable for that too instead of using a file)
Quote:
and it never shows the $read(giveawayenters.txt) from the line that says timer 1 180
and that's because /timer is a command that accepts a command as its parameter, the $read you have there will evaluate at the time mIRC parses that /timer command, not at the time the command associated for that timer is executed, you need to make sure it's evaluated correctly by using a non evaluated version of those $read, which can be done with the ! identifier prefix:
Code:
timer 1 180 msg # $!read(giveawayenters.txt) has just won this giveaway for a copy of $!read(tempga.txt) $!+ , big thanks to %newgasponsor for sponsoring this giveaway
Notice how I also use it on $+, otherwise it would stick the comma: "$read()," and when mIRC parses that, the comma is ignored


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Nov 2013
Posts: 21
A
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Nov 2013
Posts: 21
Thank you sooo much, this was a great help, and also you should see all the face palms i am doing due to the .txt.txt

And also I was just wondering, would i be able to do something like

Code:
timer 1 179 %winner = $!read(giveawayenters.txt)


Would that work, so that I could use the %winner in something else??

EDIT: Or would I need an Alias to do this??

Last edited by AlphaKennyHuan; 12/01/14 03:10 PM.

Link Copied to Clipboard