[Ajuda] Salvar tempo jogado
#1

Criei esse sistema de tempo jogado e ele funciona atй certa parte:

PHP код:
forward UpdateTime(playerid);
public 
UpdateTime(playerid)
{
    if ( 
USERplayerid ][ pLOGADO ] == true )
    {
        
USERplayerid ][ pSEGUNDOS ] += 1;
        if ( 
USERplayerid ][ pSEGUNDOS ] >=  60 )
        {
            
USERplayerid ][ pSEGUNDOS ] = 0;
            
USERplayerid ][ pMINUTOS ] += 1;
        }
        else if ( 
USERplayerid ][ pMINUTOS ] >= 59 && USERplayerid ][ pSEGUNDOS ] >= 59 )
        {
            
USERplayerid ][ pMINUTOS ] = 0;
            
USERplayerid ][ pSEGUNDOS ] = 0;
            
USERplayerid ][ pHORAS ] += 1;
        }
        else if ( 
USERplayerid ][ pHORAS ] >= 23 && USERplayerid ][ pMINUTOS ] >= 59 && USERplayerid ][ pSEGUNDOS ] >= 59 )
        {
            
USERplayerid ][ pMINUTOS ] = 0;
            
USERplayerid ][ pSEGUNDOS ] = 0;
            
USERplayerid ][ pHORAS ] = 0;
            
USERplayerid ][ pDIAS ] += 1;
        }
    }
    
    return 
1;

Essa lуgica й boa, n necessita quebrar a cabeзa atrбs de includes/plugins, porйm quando chega na ultima parte
Quote:

(horas >= 23 && min >= 59 && seg >= 59)

Tudo deveria ser setado para 0 e o dia para 1, porйm quando chega na hora de mudar para dia:
dia == 0, hora == 24, min == 0 e seg == 0

O dia continua 0 e a hora vira 24, o restante fica com 0.
Alguй saberia dizer o q й?

@RESOLVIDO

Eu fiz as condicionas ao contrбrio e deu certo:

PHP код:
forward UpdateTime(playerid);
public 
UpdateTime(playerid)
{
    if ( 
USERplayerid ][ pLOGADO ] == true )
    {
        
USERplayerid ][ pSEGUNDOS ] += 1;
        if ( 
USERplayerid ][ pHORAS ] >= 23 && USERplayerid ][ pMINUTOS ] >= 59 && USERplayerid ][ pSEGUNDOS ] >= 60 )
        {
            
USERplayerid ][ pHORAS ] = 0;
            
USERplayerid ][ pMINUTOS ] = 0;
            
USERplayerid ][ pSEGUNDOS ] = 0;
            
USERplayerid ][ pDIAS ] += 1;
        }
        else if ( 
USERplayerid ][ pMINUTOS ] >= 59 && USERplayerid ][ pSEGUNDOS ] >= 60 )
        {
            
USERplayerid ][ pMINUTOS ] = 0;
            
USERplayerid ][ pSEGUNDOS ] = 0;
            
USERplayerid ][ pHORAS ] += 1;
        }
        else if ( 
USERplayerid ][ pSEGUNDOS ] >=  60 )
        {
            
USERplayerid ][ pSEGUNDOS ] = 0;
            
USERplayerid ][ pMINUTOS ] += 1;
        }
        
        
SaveAccount playerid );
    }
    
    return 
1;

Reply
#2

recomendo fazer deste modo mais pratico https://sampforum.blast.hk/showthread.php?tid=479249
Reply
#3

Quote:
Originally Posted by Whoo
Посмотреть сообщение
recomendo fazer deste modo mais pratico https://sampforum.blast.hk/showthread.php?tid=479249
Obrigado, mas resolvi.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)