Raoul Posted April 4, 2007 Share Posted April 4, 2007 I want to make a countdown script, but I ran into a problem. I dont know how I can prevent my script to go on into minus. This is just a part of my script, if you take 2 it will eventually say "-1!" if ($3 == !countdown) { var %b = $4 if (%b > 15) mta.pm $1 $2 Maximum amount of seconds is 15. elseif (%b == $null) mta.pm $1 $2 !countdown else { mta.text $1 Get ready! !.timer 1 1 mta.text $1 %b $+ ! !.timer 1 2 mta.text $1 $calc(%b - 1) $+ ! !.timer 1 3 mta.text $1 $calc(%b - 2) $+ ! !.timer 1 4 mta.text $1 $calc(%b - 3) $+ ! !.timer 1 5 mta.text $1 GO! } } This is for MTA: SA. Please help, I would appreciate it very much! Link to comment
Dead-Inside Posted April 4, 2007 Share Posted April 4, 2007 Rename the timers .timer .timer2 .timer3 .timer4 .timer5 Link to comment
lil Toady Posted April 4, 2007 Share Posted April 4, 2007 (edited) here, syntax !countdown , if seconds havnt been specified, default is 3 on *:SIGNAL:mta.command:{ if ($3 == !countdown) { var %i = 3,%a = 0 if (($4 isnum) && ($4 <= 15)) %i = $4 mta.text $1 Get Ready! while (%i >= 1) { .timer 1 %a mta.text $1 %i | !dec %i | !inc %a } .timer 1 %a mta.text $1 GOGOGO!!! } } Edited April 4, 2007 by Guest Link to comment
Scooby Posted April 4, 2007 Share Posted April 4, 2007 Here, Try this elseif ($3 == !countdown) { var %a = 1,%b = $iif($4 == $null,3,$v1) if ((%b < 3) || (%b > 10) || (%b !isnum)) { mta.pm $1 $2 Error: Invalid Amount <3-10> } else { while (%a <= %b) { .timer 1 %a mta.text $1 Countdown: $calc(%b - (%a - 1)) !inc %a } .timer 1 %a mta.text $1 Countdown: GOGOGO! } } Edit: Ah, a nice one by toady while i wrote this, looks like his is for mtavc tho. both seem to be about the same. Edit: omg stop that lol ok he changed it Link to comment
Raoul Posted April 4, 2007 Author Share Posted April 4, 2007 Many, many thnx. Both Scooby and Toady. One question, what is different if I do .timer .timer2 .timer3 .timer4 .timer5? Link to comment
Dead-Inside Posted April 4, 2007 Share Posted April 4, 2007 Many, many thnx. Both Scooby and Toady. One question, what is different if I do .timer .timer2 .timer3 .timer4 .timer5? They'll all run. Link to comment
lil Toady Posted April 4, 2007 Share Posted April 4, 2007 Many, many thnx. Both Scooby and Toady. One question, what is different if I do .timer .timer2 .timer3 .timer4 .timer5? Don't listen to him.. Those timers are not needed at all, these 1 2 3 4 5 are just timers' names, you can set it to whatever and it's mostly needed if you're expecting to control your timer in future, like stop it. In the countdown that is not needed at all Link to comment
Raoul Posted April 4, 2007 Author Share Posted April 4, 2007 Many, many thnx. Both Scooby and Toady. One question, what is different if I do .timer .timer2 .timer3 .timer4 .timer5? Don't listen to him.. Those timers are not needed at all, these 1 2 3 4 5 are just timers' names, you can set it to whatever and it's mostly needed if you're expecting to control your timer in future, like stop it. In the countdown that is not needed at all Ok, thnx Link to comment
Recommended Posts