task TimeOnServer[1000]()
#1

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;

Reply
#2

Which line? I not see any problem
Reply
#3

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

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

Код:
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; 
}
Reply
#6

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

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

Seems like aldenj's script's part.
Reply
#9

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;

Reply
#10

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


Forum Jump:


Users browsing this thread: 2 Guest(s)