02.04.2011, 01:37
How can i make if player does /stats, it will show how long the player played in the server by hours and time?
SetTimerEx("UpdateTime", 60*1000, 1, "i", playerid);
forward UpdateTime(playerid);
public UpdateTime(playerid)
{
SetPVarInt(playerid, "Time", GetPVarInt(playerid, "Time")+1);
return 1;
}
CMD:stats(playerid, params[])
{
new AdminRank[30];
new string[128];
new Name[MAX_PLAYER_NAME];
switch (PlayerData[playerid][AdminLevel])
{
case 0: format(AdminRank, 30, "(Not Admin)");
case 1: format(AdminRank, 30, "(Server Moderator)");
case 2: format(AdminRank, 30, "(Global Moderator)");
case 3: format(AdminRank, 30, "(Administrator)");
case 4: format(AdminRank, 30, "(Server Owner)");
}
GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
format(string, sizeof(string), " {FFB300}Name: %s \n\n Adminlevel: %d %s\n\n Vip: %d\n\n Cash: %d\n\n Score: %d",Name,PlayerData[playerid][AdminLevel],AdminRank,PlayerData[playerid][vip],GetPlayerMoney(playerid),GetPlayerScore(playerid));
ShowPlayerDialog(playerid,10000,DIALOG_STYLE_MSGBOX, "Stats",string,"Close","");
return 1;
}
GetPVarInt(playerid, "Time");
enum pData
{
AdminLevel,
Cash,
Score,
vip,
Hour,
Minute
};
new PlayerData[MAX_PLAYERS][pData];
SetTimerEx("Hours",3600000, 1, "i", playerid);
SetTimerEx("Minutes", 60*1000, 1, "i", playerid);
dini_IntSet(file, "Hours",PlayerData[playerid][Hour]);
dini_IntSet(file, "Minutes",PlayerData[playerid][Minute]);
dini_IntSet(file, "Hours",PlayerData[playerid][Hour]);
dini_IntSet(file, "Minutes",PlayerData[playerid][Minute]);
SetPVarInt(playerid,"Minutes",dini_Int(file, "Minutes"));
SetPVarInt(playerid,"Hours",dini_Int(file, "Hours"));
forward Hours(playerid);
public Hours(playerid)
{
SetPVarInt(playerid, "Hours", GetPVarInt(playerid, "Hours")+1);
return 1;
}
forward Minutes(playerid);
public Minutes(playerid)
{
SetPVarInt(playerid, "Minutes", GetPVarInt(playerid, "Minutes")+1);
return 1;
}