SetTimerEx work twice in OnPlayerSpawn - 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: SetTimerEx work twice in OnPlayerSpawn (
/showthread.php?tid=585014)
[Solved] SetTimerEx work twice in OnPlayerSpawn -
N3cromancer - 10.08.2015
Hello my friends, trying to make the wanted level down (1 by 1) but my timer remove 2 stars insead 1
I active the timer in OnPlayerSpawn
PHP код:
WantedTimer[playerid] = SetTimerEx("RemoveWantedLevel", 20000, true, "i", playerid);
PHP код:
public RemoveWantedLevel(playerid)
{
if(IsLogged(playerid))
{
new WantedLevel = GetPlayerWantedLevel(playerid), tmp_wanted;
switch(WantedLevel)
{
case 6: tmp_wanted = 5;
case 5: tmp_wanted = 4;
case 4: tmp_wanted = 3;
case 3: tmp_wanted = 2;
case 2: tmp_wanted = 1;
case 1: tmp_wanted = 0;
}
SetPlayerWantedLevel(playerid, tmp_wanted);
}
return 1;
}
EDIT: Was a trouble by me, calling 2 times OnPlayerSpawn with ToglePlayerSpectate inside a stock to spawn the player.
Re: SetTimerEx work twice in OnPlayerSpawn -
M0HAMMAD - 10.08.2015
use it on OnPlayerConnect and use the code like this, it's better:
pawn Код:
public RemoveWantedLevel(playerid)
{
if(IsLogged(playerid) && GetPlayerWantedLevel(playerid) >= 1) SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid)-1)
return 1;
}
Re: SetTimerEx work twice in OnPlayerSpawn -
SickAttack - 10.08.2015
You should always kill a timer before setting it to run, it will avoid overlaps and what not. And no, you are doing something wrong there, buddy. You just haven't noticed yet.