KillTimer - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: KillTimer (
/showthread.php?tid=187090)
KillTimer -
RedFusion - 31.10.2010
I can't get my KillTimer to work..
Код:
forward start();
new starter;
Код:
public start()
{
starter = SetTimer("fire1",0,false);
}
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/firework", cmdtext, true, 10) == 0)
{
SetTimer("start",0,false);
return 1;
}
if (strcmp("/stopfirework", cmdtext, true, 10) == 0)
{
KillTimer(starter);
return 1;
}
return 0;
}
When i do /stopfirework it doesn't stop! /firework starts the whole thing nicely.
But when it comes to shutting the fireworks down it doesnt work.
Re: KillTimer -
Saurik - 31.10.2010
public start()
{
starter = SetTimer("fire1",0,false);
}
there zero means that the timer wont work... 0 = 0 mili-seconds
1,000 = 1 second
and i honestly dont see why you are using timers when you have commands ....
You can just have variables
Re: KillTimer -
RedFusion - 01.11.2010
So what is there to do?
Re: KillTimer -
Zamaroht - 01.11.2010
You have to assign the variable to the timer. That is, change your /firework command to:
pawn Код:
starter = SetTimer("start",0,false);
Also, why are you using 0 as the timer's time? If you just want to call the function, you just have to write:
Re: KillTimer -
RedFusion - 01.11.2010
Thanks, but the
Still doesnt work
Re: KillTimer -
HireMe - 01.11.2010
Maybe this works :
#include <a_samp>
#define TIME 1000 //1000 stands for 1 sec it'll loop every second. just change this to whatever you want!
forward start();
forward stop();
forward fire1();
new starter;
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/firework", cmdtext, true, 10) == 0)
{
start();
return 1;
}
if (strcmp("/stopfirework", cmdtext, true, 10) == 0)
{
stop();
return 1;
}
return 0;
}
public stop()
{
KillTimer(starter);
}
public start()
{
starter = SetTimer("fire1",TIME,true);
}
public fire1()
{
// put what ever you want to happen in here
}
Re: KillTimer -
Bessensap - 01.11.2010
EDIT: dumb. Sorry