SA-MP Forums Archive
[HELP]Need help in 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)
+--- Thread: [HELP]Need help in KillTimer (/showthread.php?tid=454039)



[HELP]Need help in KillTimer - qazwsx - 27.07.2013

Guys please help me, I need help. I want make Simple Antispawnkill system.
Well, it is worked, but although AntiSpawnKill is has been off, the health and armor keep regenerating :/
How i can stop this? Ive make KillTimer but it still not work
Please help, i really need this.
Here is the code:

Код:
OnPlayerSpawn(playerid)
{
SetPlayerHealth(playerid, 1000000);
	SetTimerEx("endspawnkillprotect", 5000, true, "i", playerid);
	SendClientMessage(playerid, COLOR_BRIGHTRED, "Youre Protected by Anti Spawnkill Now");
	SetPlayerToTeamColour(playerid);
return 1;
}
Код:
new connect_timer[MAX_PLAYERS]
Код:
forward endspawnkillprotect(playerid);
Код:
public endspawnkillprotect(playerid)
{
	SetPlayerHealth(playerid, 100.0);
	SetPlayerArmour(playerid, 100.0);
	KillTimer(connect_timer[playerid]);
	return 1;
}



Re: [HELP]Need help in KillTimer - Donvalley - 27.07.2013

pawn Код:
OnPlayerSpawn(playerid)
{
SetPlayerHealth(playerid, 1000000);
    SetTimerEx("endspawnkillprotect", 5000, false, "i", playerid);
    SendClientMessage(playerid, COLOR_BRIGHTRED, "Youre Protected by Anti Spawnkill Now");
    SetPlayerToTeamColour(playerid);
return 1;
}
try that not tested


Re: [HELP]Need help in KillTimer - ScRipTeRi - 27.07.2013

pawn Код:
new connect_timer[MAX_PLAYERS];

public OnPlayerSpawn(playerid)
{
SetPlayerHealth(playerid, 1000000);
connect_timer[playerid] = SetTimerEx("endspawnkillprotect", 5000, true, "i", playerid);
SendClientMessage(playerid, COLOR_BRIGHTRED, "Youre Protected by Anti Spawnkill Now");
SetPlayerToTeamColour(playerid);
return 1;
}
forward endspawnkillprotect(playerid);
public endspawnkillprotect(playerid)
{
SetPlayerHealth(playerid, 100.0);
SetPlayerArmour(playerid, 100.0);
KillTimer(connect_timer[playerid]);
return 1;
}



Re: [HELP]Need help in KillTimer - qazwsx - 27.07.2013

Quote:
Originally Posted by Donvalley
Посмотреть сообщение
pawn Код:
OnPlayerSpawn(playerid)
{
SetPlayerHealth(playerid, 1000000);
    SetTimerEx("endspawnkillprotect", 5000, false, "i", playerid);
    SendClientMessage(playerid, COLOR_BRIGHTRED, "Youre Protected by Anti Spawnkill Now");
    SetPlayerToTeamColour(playerid);
return 1;
}
try that not tested
Thanks mane, yours is worked


Re: [HELP]Need help in KillTimer - ScRipTeRi - 27.07.2013

<Removed>


Re: [HELP]Need help in KillTimer - Donvalley - 27.07.2013

No problem reason was it was set to

pawn Код:
SetTimerEx("endspawnkillprotect", 5000, true, "i", playerid);
i changed it to

pawn Код:
SetTimerEx("endspawnkillprotect", 5000, false, "i", playerid);
if you set repeating to true means that it will be called repeatedly (only be stopped with KillTimer)
we set it to false so its only called the once (when its needed)

details here for future reference:

https://sampwiki.blast.hk/wiki/SetTimerEx