progressbar fill - 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: progressbar fill (
/showthread.php?tid=661028)
progressbar fill -
zZzTGTzZz - 19.11.2018
Hello! I have a problem with the progressbar, it turns out that I need to increase every 10 seconds by 10%, but only by 1 time.
Код:
new TimeBar[MAX_PLAYERS];
forward Cant(playerid);
public Cant(playerid)
{
new Work_Cant[MAX_PLAYERS];
Work_Cant[playerid] ++;
SetProgressBarValue(WorkBar[playerid], Work_Cant[playerid]);
UpdateProgressBar(WorkBar[playerid], playerid);
return 1;
// timer:
TimeBar[playerid] = SetTimer("Cant", 1000, 1);
}
Re: progressbar fill -
ReD_HunTeR - 19.11.2018
dont use timer inside local callback which u are calling through same timer wtf
pawn Код:
new TimeBar[MAX_PLAYERS],
Work_Cant[MAX_PLAYERS]; //you have to use it globally cuz it will reset if u use inside timer
TimeBar[playerid] = SetTimerEx("Cant", 10 * 1000, true, "i", playerid); //add this when you want to start timer 10 sec timer
forward Cant(playerid);
public Cant(playerid)
{
Work_Cant[playerid] += 10; //Adding 10 Percent
SetProgressBarValue(WorkBar[playerid], Work_Cant[playerid]); //Now lets set it on progress bar
UpdateProgressBar(WorkBar[playerid], playerid); //updating it
if(Work_Cant[playerid] == 100) //when it reaches 100 percent
{
RemoveProgressBar(WorkBar[playerid]); //removes progressbar not sure if its right function
World_Cant[playerid] = 0; //reseting it to 0
KillTimer(TimerBar[playerid]); //now we kill the timer
}
return 1;
}
now make sure to reset everything once the timer ends