Timer is going faster then it should
#1

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
Reply
#2

You should kill timer before turning it on again everytime.
Reply
#3

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

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
Reply
#5

did not work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)