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;
}
Code:
StartProgress(playerid, 100, 0, objectid);