SA-MP Forums Archive
task TimeOnServer[1000]() - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: task TimeOnServer[1000]() (/showthread.php?tid=622055)



task TimeOnServer[1000]() - NealPeteros - 18.11.2016

It says that it's an invalid function or declaration. Full code:

PHP код:
task TimeOnServer[1000]()
{
    foreach(
Playeri)
    {
        if(
pInfo[i][pLogged] == true)
         {
            
pInfo[i][pSec] ++;
            if(
pInfo[i][pSec] >= 60)
            {
                
pInfo[i][pMin]++;
                  
pInfo[i][pSec]=0;
            }
            if(
pInfo[i][pMin] >= 60)
             {
                  
pInfo[i][pMin]=0;
                
pInfo[i][pHour]++;
                
SetPlayerScore(i,pInfo[i][pHour]);
             }
          }
    }
    return 
1;




Respuesta: task TimeOnServer[1000]() - Swedky - 18.11.2016

Which line? I not see any problem


Re: task TimeOnServer[1000]() - NealPeteros - 18.11.2016

Sorry for that.

PHP код:
(419) : error 010invalid function or declaration
(421) : error 010invalid function or declaration
(423) : error 010invalid function or declaration
(426) : error 010invalid function or declaration
(431) : error 010invalid function or declaration
(439) : error 010invalid function or declaration 
419 is where the code starts


Re: task TimeOnServer[1000]() - Vince - 18.11.2016

This is poor design overall. You only need to store seconds: 60 seconds in a minute, 3600 seconds in an hour, 86400 seconds in a day, etc. Second point (no pun intended) is that the time on the server can be calculated with either gettime() or NetStats_GetConnectedTime(). This eradicates the need for an expensive timer entirely.


Re: task TimeOnServer[1000]() - justice96 - 18.11.2016

Код:
ptask TimeOnServer[1000](playerid) 
{ 
    if(pInfo[playerid][pLogged])
    { 
        pInfo[playerid][pSec]++; 
        if(pInfo[playerid][pSec] == 60) 
        { 
        	pInfo[playerid][pSec] = 0;
            pInfo[playerid][pMin]++;  
        } 
        if(pInfo[playerid][pMin] == 60) 
     	{ 
          	pInfo[playerid][pMin] = 0; 
            pInfo[playerid][pHour]++; 
            SetPlayerScore(playerid,pInfo[playerid][pHour]); 
     	} 
    } 
    return 1; 
}



Re: task TimeOnServer[1000]() - NealPeteros - 18.11.2016

Quote:
Originally Posted by justice96
Посмотреть сообщение
Код:
ptask TimeOnServer[1000](playerid) 
{ 
    if(pInfo[playerid][pLogged])
    { 
        pInfo[playerid][pSec]++; 
        if(pInfo[playerid][pSec] == 60) 
        { 
        	pInfo[playerid][pSec] = 0;
            pInfo[playerid][pMin]++;  
        } 
        if(pInfo[playerid][pMin] == 60) 
     	{ 
          	pInfo[playerid][pMin] = 0; 
            pInfo[playerid][pHour]++; 
            SetPlayerScore(playerid,pInfo[playerid][pHour]); 
     	} 
    } 
    return 1; 
}
Still gives the same errors.


Re: task TimeOnServer[1000]() - NealPeteros - 18.11.2016

Quote:
Originally Posted by Vince
Посмотреть сообщение
This is poor design overall. You only need to store seconds: 60 seconds in a minute, 3600 seconds in an hour, 86400 seconds in a day, etc. Second point (no pun intended) is that the time on the server can be calculated with either gettime() or NetStats_GetConnectedTime(). This eradicates the need for an expensive timer entirely.
I just borrowed this from Kitten's DayZ


Re: task TimeOnServer[1000]() - iLearner - 18.11.2016

Seems like aldenj's script's part.


Re: task TimeOnServer[1000]() - NealPeteros - 18.11.2016

Found a fix. Next problem:

Код:
(421) : error 017: undefined symbol "playerid"
(423) : error 017: undefined symbol "playerid"
(424) : error 017: undefined symbol "playerid"
(426) : error 017: undefined symbol "playerid"
(428) : error 017: undefined symbol "playerid"
(430) : error 017: undefined symbol "playerid"
(431) : error 017: undefined symbol "playerid"
(432) : error 017: undefined symbol "playerid"
PHP код:
Timer:TimeOnServer[1000](playerid)
{
    if(
pInfo[playerid][pLogged]) /* Line 421 */
    
{
        
pInfo[playerid][pSec]++;
        if(
pInfo[playerid][pSec] == 60)
        {
            
SetPlayerScore(playerid,pInfo[playerid][pSec]);
        }
        if(
pInfo[playerid][pMin] == 60)
         {
              
pInfo[playerid][pMin] = 0;
            
pInfo[playerid][pHour]++;
            
SetPlayerScore(playerid,pInfo[playerid][pHour]);
         }
    }
    return 
1;




Respuesta: task TimeOnServer[1000]() - Swedky - 18.11.2016

I think it should be "ptask" and not "Timer:"