21.07.2016, 04:01
I'm trying to save how long a person has played in the server. I get a warning:
Here is what my code is.
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();
With the command I get 1 error and 2 warnings.
The line all these are on is
Код:
warning 204: symbol is assigned a value that is never used: "time"
PHP код:
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(playerid, reason);
{
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(playerid, dialogid, response, listitem, inputtext[])
{
....
Register...
INI_WriteInt(File,"TotalTime",0);
Login
PlayerInfo[playerid][pTotalTime] = GetPVarInt(playerid, "TotalTime");
return 1;
}
PHP код:
CMD:checkplayer(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 1)
{
new ID, string[256],str[256], h, m, s;
if(sscanf(params,"i", ID)) return SendClientMessage(playerid, COLOR_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](ID, h, m, s);
format(string, sizeof(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(playerid, 2002, DIALOG_STYLE_MSGBOX, str, string, "OK","");
}
}
else
{
return 0;
}
return 1;
}
Код:
(1979)warning 215: expression has no effect (1978) : error 001: expected token: ";", but found "(" (1978) : warning 215: expression has no effect
PHP код:
PlayerInfo[playerid][pTotalTime](ID, h, m, s);