Timer Lombrado -
GuilhermeW - 12.11.2017
Galera, me ajudem por favor, tou com um problema aqui, jб tentei resolver de todas as formas que sei, porйm nгo obtive кxito...
O problema й o seguinte, eu coloco o timer para tirar 1 da variбvel que seria no total 100 a cada 6 minutos, no total teria que acabar em 10h, porйm tб acabando em 1h, 2h, tipo, й um sistema de fome, sede e sono, tou usando em GM limpo, padrгo do SA-MP, e antes que me perguntem, nгo tem nada que possa tб mexendo no code, se alguйm puder me ajudar, obrigado.
PHP код:
public progress_pHunger()
{
for(new I = 0; I < MAX_PLAYERS; I++)
{
if(pHunger[I] == 0)
{
SetPlayerHealth(I, 0.0);
kpHunger[I] = 1;
pHunger[I] = -1;
pThirst[I] = -1;
pSleep[I] = -1;
SetPlayerProgressBarValue(I, cCMbnbarsVar[0][I], pHunger[I]);
ShowPlayerProgressBar(I, cCMbnbarsVar[0][I]);
}
pHunger[I] --;
SetPlayerProgressBarValue(I, cCMbnbarsVar[0][I], pHunger[I]);
ShowPlayerProgressBar(I, cCMbnbarsVar[0][I]);
if(pHunger[I] < 5)
{
SendClientMessage(I, 0xC8E1FFAA, "| FOME | Vocк estб com muita fome, coma algo ou irб morrer!");
}
}
return 1;
}
public progress_pThirst()
{
for(new I = 0; I < MAX_PLAYERS; I++)
{
if(pThirst[I] == 0)
{
SetPlayerHealth(I, 0.0);
kpThirst[I] = 1;
pHunger[I] = -1;
pThirst[I] = -1;
pSleep[I] = -1;
SetPlayerProgressBarValue(I, cCMbnbarsVar[1][I], pThirst[I]);
ShowPlayerProgressBar(I, cCMbnbarsVar[1][I]);
}
pThirst[I] --;
SetPlayerProgressBarValue(I, cCMbnbarsVar[1][I], pThirst[I]);
ShowPlayerProgressBar(I, cCMbnbarsVar[1][I]);
if(pThirst[I] < 5)
{
SendClientMessage(I, 0xC8E1FFAA, "| SEDE | Vocк estб com muita sede, beba algo ou irб morrer!");
}
}
return 1;
}
public progress_pSleep()
{
for(new I = 0; I < MAX_PLAYERS; I++)
{
if(pSleep[I] == 0)
{
SetPlayerHealth(I, 0.0);
kpSleep[I] = 1;
pHunger[I] = -1;
pThirst[I] = -1;
pSleep[I] = -1;
SetPlayerProgressBarValue(I, cCMbnbarsVar[1][I], pThirst[I]);
ShowPlayerProgressBar(I, cCMbnbarsVar[1][I]);
}
pSleep[I] --;
SetPlayerProgressBarValue(I, cCMbnbarsVar[2][I], pSleep[I]);
ShowPlayerProgressBar(I, cCMbnbarsVar[2][I]);
if(pSleep[I] < 5)
{
SendClientMessage(I, 0xC8E1FFAA, "| SONO | Vocк estб com muito sono, durma ou irб morrer!");
}
}
return 1;
}
Chamando o timer na callback OnPlayerSpawn:
PHP код:
timerpHunger[playerid] = SetTimer("progress_pHunger", 360000, true);
timerpThirst[playerid] = SetTimer("progress_pThirst", 360000, true);
timerpSleep[playerid] = SetTimer("progress_pSleep", 360000, true);
Re: Timer Lombrado -
BykiLler - 12.11.2017
Matematicamente estб certo
PHP код:
360.000 ms * 100 = 36.000.000 ms
36.000.000 ms / 60.000 ms = 600 min
600 min / 60 min = 10 h
Acho que voce deveria colocar:
PHP код:
if(!IsPlayerConnected(i))continue;// Caso o jogador nгo tiver on-line irб pular
Re: Timer Lombrado -
Andre02 - 12.11.2017
Os timers/temporizadores do SAMP estao quase sempre, 25% fora do valor indicado.
Use isso:
https://sampforum.blast.hk/showthread.php?tid=289675 e veja se funciona melhor.
Se nao funcionar, quer dizer que o problema й do seu script.