SA-MP Forums Archive
Timer is going faster then it should - 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 is going faster then it should (/showthread.php?tid=441681)



Timer is going faster then it should - RedWolfX - 03.06.2013

Hello, I got a hunger & thirst system on my server. And when there is more players online, the hunger & thirst goes up faster than it should.

Here is the forward/new codes:

Код:
ew Bar:Hunger[MAX_PLAYERS] = {INVALID_BAR_ID, ...};
new Bar:Thirst[MAX_PLAYERS] = {INVALID_BAR_ID, ...};
new Hungry[MAX_PLAYERS];
new Thirsty[MAX_PLAYERS];
forward hunger(playerid);
forward thirsty(playerid);
//forward ProgressBar();
new hungertimer[MAX_PLAYERS];
new thirsttimer[MAX_PLAYERS];
new GetUp[MAX_PLAYERS];
forward getuptimer(playerid);
OnPlayerSpawn:

Код:
hungertimer[playerid] = SetTimerEx("hunger", 1200000, true, "i", playerid);
thirsttimer[playerid] = SetTimerEx("thirsty", 1200000, true, "i", playerid);
OnPlayerDeath:

Код:
KillTimer(hungertimer[playerid]);
    KillTimer(thirsttimer[playerid]);
    DestroyProgressBar(Hunger[playerid]);
	DestroyProgressBar(Thirst[playerid]);
Public:

Код:
public hunger(playerid)
{
    Hungry[playerid] = Hungry[playerid] += 1;
    //hungertimer[playerid] = SetTimerEx("hunger", 1200000, false, "i", playerid); 
    return 1;
}
public thirsty(playerid)
{
    Thirsty[playerid] = Thirsty[playerid] += 1;
    //thirsttimer[playerid] = SetTimerEx("thirsty", 1200000, false, "i", playerid); 
    return 1;
}
I cant figure out whats wrong, I have been looking for a while and still cant find what is wrong.

EDIT: Progress bar dont update all the time either when you eat


Re: Timer is going faster then it should - Konewka - 03.06.2013

You should kill timer before turning it on again everytime.


Re: Timer is going faster then it should - Pupak - 03.06.2013

This fixes timers.
https://sampforum.blast.hk/showthread.php?tid=375925


Re: Timer is going faster then it should - RedWolfX - 04.06.2013

Quote:
Originally Posted by Konewka
Посмотреть сообщение
You should kill timer before turning it on again everytime.
I have KillTimer on OnPlayerDeath and OnPlayerDisconnect

Quote:
Originally Posted by Pupak
Посмотреть сообщение
Gonna try it


Re: Timer is going faster then it should - RedWolfX - 06.06.2013

did not work