24.09.2013, 16:50
So, I have a /stats command. The online time is bugged.
Here is the code:
Code of /stats:
Code of TotalGameTime (used for Online time):
(Note: the TotalGameTime I got from LuxAdmin)
Here is a picture of the /stats:

Any idea on what could be happening?
Here is the code:
Code of /stats:
pawn Код:
CMD:stats(playerid, params[])
{
#pragma unused params
new Float:health;
new Float:armor;
new deaths = pInfo[playerid][Deaths];
new kills = pInfo[playerid][Kills];
new spawns = pInfo[playerid][Spawns];
new h;
new m;
new s;
new ip[16];
new level = pInfo[playerid][Level];
new money = GetPlayerMoney(playerid);
new interior = GetPlayerInterior(playerid);
new adminlvl = pInfo[playerid][ALevel];
new adminlvlname[95];
new viplvl = pInfo[playerid][DLevel];
new viplvlname[75];
new tadminlvl = pInfo[playerid][TALevel];
new tadminname[90];
new pName[MAX_PLAYER_NAME];
new score = GetPlayerScore(playerid);
new ping = GetPlayerPing(playerid);
GetPlayerHealth(playerid, health);
GetPlayerArmour(playerid, armor);
GetPlayerIp(playerid, ip, sizeof(ip));
GetPlayerName(playerid, pName, sizeof(pName));
new string[150];
switch(viplvl)
{
case 0: viplvlname = "Not a Donator";
case 1: viplvlname = "Bronze VIP";
case 2: viplvlname = "Silver VIP";
case 3: viplvlname = "Iron VIP";
case 4: viplvlname = "Gold VIP";
case 5: viplvlname = "Diamond VIP";
}
switch(adminlvl)
{
case 0: adminlvlname = "Not a staff member";
case 1: adminlvlname = "Basic Moderator";
case 2: adminlvlname = "Moderator";
case 3: adminlvlname = "Full Moderator";
case 4: adminlvlname = "Basic Administrator";
case 5: adminlvlname = "Administrator";
case 6: adminlvlname = "Full Administrator";
case 7: adminlvlname = "Co-Manager";
case 8: adminlvlname = "Manager";
case 9: adminlvlname = "Co-Owner";
case 10: adminlvlname = "Owner";
}
switch(tadminlvl)
{
case 0: tadminname = "Not a Trial Administrator";
case 1: tadminname = "Trial Administrator Level 1";
case 2: tadminname = "Trial Admimistrator Level 2";
}
TotalGameTime(playerid, h, m, s);
SendClientMessage(playerid, COLOR_YELLOW, "-| Your Stats |-");
format(string, sizeof(string), "Name: %s - Player ID: %d - IP: %s - Ping: %d", pName, playerid, ip, ping);
SendClientMessage(playerid, COLOR_ORANGE, string);
format(string, sizeof(string), "Health: %d - Armor: %d - Spawns: %d - Kills: %d - Deaths: %d", health, armor, spawns, kills, deaths);
SendClientMessage(playerid, COLOR_ORANGE, string);
format(string, sizeof(string), "Score: %d - Level: %d - Money: $%d", score, level, money);
SendClientMessage(playerid, COLOR_ORANGE, string);
format(string, sizeof(string), "Admin Level: %s (%d) - Donator Level: %s (%d)", adminlvlname, adminlvl, viplvlname, viplvl);
SendClientMessage(playerid, COLOR_ORANGE, string);
format(string, sizeof(string), "Trial Administrator: %s (%d)", tadminname, tadminlvl);
SendClientMessage(playerid, COLOR_ORANGE, string);
format(string, sizeof(string), "Interior: %d", interior);
SendClientMessage(playerid, COLOR_ORANGE, string);
format(string, sizeof(string), "Online Time: %d hours, %d minutes, %d seconds", h, m, s);
SendClientMessage(playerid, COLOR_ORANGE, string);
return 1;
}
pawn Код:
TotalGameTime(playerid, &h=0, &m=0, &s=0)
{
pInfo[playerid][TotalTime] = ( (gettime() - pInfo[playerid][ConnectTime]) + (pInfo[playerid][hours]*60*60) + (pInfo[playerid][mins]*60) + (pInfo[playerid][secs]) );
h = floatround(pInfo[playerid][TotalTime] / 3600, floatround_floor);
m = floatround(pInfo[playerid][TotalTime] / 60, floatround_floor) % 60;
s = floatround(pInfo[playerid][TotalTime] % 60, floatround_floor);
return pInfo[playerid][TotalTime];
}
Here is a picture of the /stats:

Any idea on what could be happening?