[Ajuda] Timer Lombrado
#1

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 
0MAX_PLAYERSI++)
    {
    if(
pHunger[I] == 0)
    {
    
SetPlayerHealth(I0.0);
    
kpHunger[I] = 1;
    
pHunger[I] = -1;
    
pThirst[I] = -1;
    
pSleep[I] = -1;
    
SetPlayerProgressBarValue(IcCMbnbarsVar[0][I], pHunger[I]);
    
ShowPlayerProgressBar(IcCMbnbarsVar[0][I]);
    }
    
pHunger[I] --;
     
SetPlayerProgressBarValue(IcCMbnbarsVar[0][I], pHunger[I]);
    
ShowPlayerProgressBar(IcCMbnbarsVar[0][I]);
    if(
pHunger[I] < 5)
    {
    
SendClientMessage(I0xC8E1FFAA"| FOME | Vocк estб com muita fome, coma algo ou irб morrer!");
    }
    }
    return 
1;
}
public 
progress_pThirst()
{
    for(new 
0MAX_PLAYERSI++)
    {
    if(
pThirst[I] == 0)
    {
    
SetPlayerHealth(I0.0);
    
kpThirst[I] = 1;
    
pHunger[I] = -1;
    
pThirst[I] = -1;
    
pSleep[I] = -1;
    
SetPlayerProgressBarValue(IcCMbnbarsVar[1][I], pThirst[I]);
    
ShowPlayerProgressBar(IcCMbnbarsVar[1][I]);
    }
    
pThirst[I] --;
     
SetPlayerProgressBarValue(IcCMbnbarsVar[1][I], pThirst[I]);
    
ShowPlayerProgressBar(IcCMbnbarsVar[1][I]);
    if(
pThirst[I] < 5)
    {
    
SendClientMessage(I0xC8E1FFAA"| SEDE | Vocк estб com muita sede, beba algo ou irб morrer!");
    }
    }
    return 
1;
}
public 
progress_pSleep()
{
    for(new 
0MAX_PLAYERSI++)
    {
    if(
pSleep[I] == 0)
    {
    
SetPlayerHealth(I0.0);
    
kpSleep[I] = 1;
    
pHunger[I] = -1;
    
pThirst[I] = -1;
    
pSleep[I] = -1;
    
SetPlayerProgressBarValue(IcCMbnbarsVar[1][I], pThirst[I]);
    
ShowPlayerProgressBar(IcCMbnbarsVar[1][I]);
    }
    
pSleep[I] --;
     
SetPlayerProgressBarValue(IcCMbnbarsVar[2][I], pSleep[I]);
    
ShowPlayerProgressBar(IcCMbnbarsVar[2][I]);
    if(
pSleep[I] < 5)
    {
    
SendClientMessage(I0xC8E1FFAA"| SONO | Vocк estб com muito sono, durma ou irб morrer!");
    }
    }
    return 
1;

Chamando o timer na callback OnPlayerSpawn:
PHP код:
timerpHunger[playerid] = SetTimer("progress_pHunger"360000true);
    
timerpThirst[playerid] = SetTimer("progress_pThirst"360000true);
    
timerpSleep[playerid] = SetTimer("progress_pSleep"360000true); 
Reply
#2

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

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)