mercredi 20 juillet 2016

Recording total playing time

I'm trying to save how long a person has played in the server. I get a warning:

Code:

warning 204: symbol is assigned a value that is never used: "time"
Here is what my code is.

PHP Code:

new gPlayerJoin[MAX_PLAYERS]; enum pInfo
{
       
pTotalTime
}
new 
PlayerInfo[MAX_PLAYERS][pInfo];
public 
LoadUser_data(playerid,name[],value[])
{
    
INI_Int("TotalTime",PlayerInfo[playerid][pTotalTime]);
}
public 
OnPlayerConnect(playerid)
{
          
gPlayerJoin[playerid] = gettime();
        return 
1;
}

public 

OnPlayerDisconnect(playeridreason);
{
           new 
time gettime() - gPlayerJoin[playerid];
        new 
INI:File INI_Open(UserPath(playerid));
        
INI_SetTag(File"data");
        
INI_WriteInt(File,"TotalTime",PlayerInfo[playerid][pTotalTime]);
        
INI_Close(File);
        return 
1;
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
....
                
Register...
                
INI_WriteInt(File,"TotalTime",0);Login
                    PlayerInfo
[playerid][pTotalTime] = GetPVarInt(playerid"TotalTime");
       return 
1;

I'm also trying to make this /checkplayer command. However I'm not too sure how to do it with getting just the seconds from the gettime();

PHP Code:

CMD:checkplayer(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >= 1)
    {
        new 
IDstring[256],str[256], hms;
        if(
sscanf(params,"i"ID)) return SendClientMessage(playeridCOLOR_ADMIN"Usage: /checkplayer [ID]");
        if(
IsPlayerConnected(ID) && ID  != INVALID_PLAYER_ID && ID != playerid)
        {
            if(!
strlen(params)) ID playerid;
            else 
ID strval(params);
            
PlayerInfo[playerid][pTotalTime](IDhms);
             
format(stringsizeof(string),
             
"{6EF83C}Score: {FFFFFF}%d\n{6EF83C}Money: {FFFFFF}$%d\n{6EF83C}Hours: {FFFFFF}%d\n{6EF83C}Min: {FFFFFF}%d\n{6EF83C}Sec: {FFFFFF}%d"GetPlayerScore(ID), GetPlayerMoney(ID),h,m,s);
            
format(str,sizeof(str),"{6EF83C}%s's {FFFFFF}Player Stats",GetName(ID));
            return 
ShowPlayerDialog(playerid2002DIALOG_STYLE_MSGBOXstrstring"OK","");
        }
    }
    else
      {
           return 
0;
    }
    return 
1;

With the command I get 1 error and 2 warnings.

Code:

(1979)warning 215: expression has no effect
(1978) : error 001: expected token: ";", but found "("
(1978) : warning 215: expression has no effect
The line all these are on is

PHP Code:

        PlayerInfo[playerid][pTotalTime](IDhms); 

Let's block ads! (Why?)



Recording total playing time

Aucun commentaire:

Enregistrer un commentaire