SA-MP Forums Archive
[Solved] Can-t kill timer! - 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: [Solved] Can-t kill timer! (/showthread.php?tid=124143)



[Solved] Can-t kill timer! - aNdReSkKkK - 29.01.2010

Hi,
So when player uses /weed it activates a timer like this

SetTimerEx("Weed",250,true,"i",playerid);
but then i cant destroy it..


Код:
forward Weed(playerid);
public Weed(playerid)
{
	DrugCount[playerid]=DrugCount[playerid]+1;
	if (DrugCount[playerid]>=20){
	SetPlayerSpecialAction(playerid,0);
	KillTimer(Weed);
	DrugCount[playerid]=0;
	return 1;
	}
	
	new Float: phealthdrug;
	GetPlayerHealth(playerid,phealthdrug);
		if ( phealthdrug < 100 ){
		phealthdrug = phealthdrug+1;
		SetPlayerHealth(playerid,phealthdrug);
		}
		
return 1;
}
Gives me error 076: syntax error in the expression, or invalid function call

in the line that has: KillTimer(Weed);



Re: Can-t kill timer! - mansonh - 29.01.2010

whats your calling function.


Re: Can-t kill timer! - aNdReSkKkK - 29.01.2010

but if it-s not looping it wont heal player every certain time

Код:
	if(strcmp(cmd, "/weed", true) == 0) {

		if(PlayerInfo[playerid][weed]>0){
		SetPlayerSpecialAction (playerid,SPECIAL_ACTION_SMOKE_CIGGY );
		SendClientMessage(playerid, COLOR_GREY, "You are now smoking one gram of weed!");
		PlayerInfo[playerid][weed]=PlayerInfo[playerid][weed]-1;
		DrugCount[playerid]=0;
		SetTimerEx("Weed",250,true,"i",playerid);
		return 1;}
        SendClientMessage(playerid, COLOR_GREY, "You don't have weed.");
		return 1;
	}



Re: Can-t kill timer! - Goobiiify - 29.01.2010

I think it's should have a function name like "Timer1 = SetTimerEx("Weed",250,true,"i",playerid);".. Need to go to school cya!!


Re: Can-t kill timer! - mansonh - 29.01.2010

Ok then it should be like this:

new PlayerWeedTimer[MAX_PLAYERS];

Код:
if(strcmp(cmd, "/weed", true) == 0) {

		if(PlayerInfo[playerid][weed]>0){
		SetPlayerSpecialAction (playerid,SPECIAL_ACTION_SMOKE_CIGGY );
		SendClientMessage(playerid, COLOR_GREY, "You are now smoking one gram of weed!");
		PlayerInfo[playerid][weed]=PlayerInfo[playerid][weed]-1;
		DrugCount[playerid]=0;
		PlayerWeedTimer[playerid] = SetTimerEx("Weed",250,true,"i",playerid);
		return 1;}
        SendClientMessage(playerid, COLOR_GREY, "You don't have weed.");
		return 1;
	}
Код:
forward Weed(playerid);
public Weed(playerid)
{
	DrugCount[playerid]=DrugCount[playerid]+1;
	if (DrugCount[playerid]>=20){
	SetPlayerSpecialAction(playerid,0);
	KillTimer(PlayerWeedTimer[playerid]);
	DrugCount[playerid]=0;
	return 1;
	}
	
	new Float: phealthdrug;
	GetPlayerHealth(playerid,phealthdrug);
		if ( phealthdrug < 100 ){
		phealthdrug = phealthdrug+1;
		SetPlayerHealth(playerid,phealthdrug);
		}
		
return 1;
}



Re: Can-t kill timer! - aNdReSkKkK - 29.01.2010

thx mansonh and gobii :P
perfectly working now!

Timers have always hated me :P


Re: [Solved] Can-t kill timer! - mansonh - 29.01.2010

Np. here to help