15.05.2015, 19:47
Hi everyone, im making jail command using a timer with repeating true, but when i try to cut off the timer it doesn't.
Here the script.
This function should kill timer if jail time is 0, else refresh textdraw.
This function get the remaining time.
When /jail is perform
The call of JailTimeLeft every second for refresh time.
How to fix this timer problem?
Here the script.
Код:
stock CheckJail(playerid) { new time[20]; if(PlayerData[playerid][pJailTime]==0) { SendClientMessage(playerid,BIANCO,"Jail finito"); SetPlayerPos(playerid,2127.7607,2360.1333,10.8203); PlayerTextDrawHide(playerid,JailRemainTime[playerid]); SetPlayerVirtualWorld(playerid,0); KillTimer(JailTimer[playerid]); } else { PlayerTextDrawHide(playerid,JailRemainTime[playerid]); format(time,sizeof(time),"%d minuti rimanenti",PlayerData[playerid][pJailTime]); PlayerTextDrawSetString(playerid,JailRemainTime[playerid],time); PlayerTextDrawShow(playerid,JailRemainTime[playerid]); } }
Код:
stock JailTimeLeft(playerid,time,bool:First) { new hour,minute; new tsjail; gettime(hour,minute); tsjail=(hour*60)+minute; printf("%d %d\n",tsjail,tsjailPlusOne[playerid]); if(tsjail==tsjailPlusOne[playerid]||First==true) { if(First) { TimeForSjail[playerid]=(hour*60)+time+minute; } tsjailPlusOne[playerid]=(hour*60)+minute+1; PlayerData[playerid][pJailTime]=TimeForSjail[playerid]-tsjail; CheckJail(playerid); printf("%d %d %d\n",PlayerData[playerid][pJailTime],tsjail,tsjailPlusOne[playerid]); } }
Код:
JailTimeLeft(id,PlayerData[id][pJailTime],true); JailTimer[id] = SetTimerEx("WaitTime",1000,true,"ii",id,PlayerData[id][pJailTime]);
Код:
forward WaitTime(playerid,time); public WaitTime(playerid,time) { JailTimeLeft(playerid,time,false); }
How to fix this timer problem?