open.mp forum
[Pawn] timers sometime work sometime doesnt work - Printable Version

+- open.mp forum (https://forum.open.mp)
+-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
+--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
+--- Thread: [Pawn] timers sometime work sometime doesnt work (/showthread.php?tid=1384)



timers sometime work sometime doesnt work - Zow - 2020-11-27

[Video: https://www.dailymotion.com/video/x7xqv85]

First time I try to show but its gone for no reason
00:01 > 00:06 Ignore after that

Code:
forward OnProgressUpdate(playerid, progress, objective); forward OnProgressFinish(playerid, objective); StartProgress(playerid, duration, startvalue = 0, objective) { if(ProgressState[playerid] == 1) return 0; stop ProgressTimer[playerid]; ProgressTimer[playerid] = repeat ProgressUpdate(playerid, objective); ProgressLimit[playerid] = duration; ProgressProgress[playerid] = startvalue; ProgressState[playerid] = 1; ProgressObject[playerid] = objective; SetPlayerProgressBarMaxValue(playerid, PlayerProgressJob[playerid], ProgressLimit[playerid]); SetPlayerProgressBarValue(playerid, PlayerProgressJob[playerid], ProgressProgress[playerid]); ShowPlayerProgressBar(playerid, PlayerProgressJob[playerid]); PlayerTextDrawShow(playerid, PlayerJobCountTD[playerid]); return 1; } StopProgress(playerid) { if(ProgressState[playerid] == 0) return 0; stop ProgressTimer[playerid]; ProgressLimit[playerid] = 0; ProgressProgress[playerid] = 0; ProgressState[playerid] = 0; ProgressObject[playerid] = INVALID_OBJECT_ID; HidePlayerProgressBar(playerid, PlayerProgressJob[playerid]); PlayerTextDrawHide(playerid, PlayerJobCountTD[playerid]); return 1; } timer ProgressUpdate[100](playerid, objective) { if(ProgressProgress[playerid] >= ProgressLimit[playerid]) { StopProgress(playerid); CallLocalFunction("OnProgressFinish", "dd", playerid, objective); return; } SetPlayerProgressBarMaxValue(playerid, PlayerProgressJob[playerid], ProgressLimit[playerid]); SetPlayerProgressBarValue(playerid, PlayerProgressJob[playerid], ProgressProgress[playerid]); ShowPlayerProgressBar(playerid, PlayerProgressJob[playerid]); CallLocalFunction("OnProgressUpdate", "ddd", playerid, ProgressProgress[playerid], objective); ProgressProgress[playerid]; return; }

This all function is from SSS and I mix to my script
And here how I use

Code:
StartProgress(playerid, 100, 0, objectid);

Already fix it
Put stop ProgressTimer[playerid]; under OnPlayerDisconnect