SA-MP Forums Archive
[Ajuda] Salvar tempo jogado - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Salvar tempo jogado (/showthread.php?tid=602397)



Salvar tempo jogado - F1N4L - 06.03.2016

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;




Re: Salvar tempo jogado - Whoo - 06.03.2016

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


Re: Salvar tempo jogado - F1N4L - 06.03.2016

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