Timer problem - 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: Timer problem (
/showthread.php?tid=606895)
Timer problem -
ratxrat - 11.05.2016
i Have problem with timer. i create settimer in onplayerentercheckpoint but timmer cannot execute this my code
PHP код:
forward bsampah(playerid);
forward csampah(playerid);
public bsampah(playerid)
{
TogglePlayerControllable(playerid, 1);
tsampah[playerid] = SetPlayerCheckpoint(playerid,2290.5510,-2117.1140,14.0950,3);
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "* sampah berhasil di naikan. pergi ke penbuangan");
jsampah[playerid]=2;
}
public csampah(playerid)
{
GivePlayerMoney(playerid,2500);
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "* sampah telah di buang");
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "* Kamu mendapatkan $2500 dari membuang sampah");
jsampah[playerid]=0;
TogglePlayerControllable(playerid, 1);
DisablePlayerCheckpoint(playerid);
}
onplayercheckpoint
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 408)
{
if (jsampah[playerid]==1)
{
TogglePlayerControllable(playerid, 0);
SetTimer("bsampah", 5000, 0);
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "* proses menaikan sampah");
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "* proses............");
//tidebos
}
if (jsampah[playerid]==2)
{
TogglePlayerControllable(playerid, 0);
SetTimer("csampah", 5000, 0);
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "* proses munurunkan sampah");
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "* proses............");
//tidebos
}
}
why time not execute?
Re: Timer problem -
Amunra - 11.05.2016
Change this
PHP код:
SetTimer("bsampah", 5000, 0); to
SetTimerEx("bsampah", 5000, 0,"i",playerid);
First. Why the timer can't execute with SetTimer !
>>Because the playerid is not certainly !!
So .. we must SetTimerEx(Callbacks,time,repeat,format,float);
So The callbacks can execute the certainly playerid..
Dont forget change the SetTimerEx "jsampah" too..