KillTimer
#1

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.
Reply
#2

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
Reply
#3

So what is there to do?
Reply
#4

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:

pawn Код:
start();
Reply
#5

Thanks, but the
Код:
KillTimer(starter);
Still doesnt work
Reply
#6

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
}
Reply
#7

EDIT: dumb. Sorry
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)