if(strcmp(cmd, "/stats", true) == 0) {
new player1, tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
ShowScore(playerid);
return 1; }
player1 = strval(tmp);
if(IsPlayerConnected(player1)) {
GetPlayerName(player1, playername, sizeof(playername));
format(string, sizeof(string), "<> %s's Stats: Kills: %d | Deaths: %d | Ratio: %0.2f | Money: $%d ",playername, PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths],Float:PlayerInfo[player1][Deaths]/Float:PlayerInfo[player1][Deaths],GetPlayerMoney(player1));
SendClientMessage(playerid, green, string);
return 1;
} else {
SendClientMessage(playerid, COLOR_WHITE, "Player Not Connected!");
return 1; }
}
CMD:stats(playerid,params[])
{
new string[128];
new Float:health;
GetPlayerHealth(playerid,health);
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(string,128,"|STATS| Name:[%s] Money:[%d] Score:[%d] Health:[%d]",pName,GetPlayerMoney(playerid),GetPlayerScore(playerid),health);
SendClientMessage(playerid,0x00A300AA,string);
return 1;
}
Ironboy: Your code makes huge numbers of assumptions about what there is in the script, Montis123's makes none and is thus a much better example! What is "ShowScore" in your code and how is it defined? Where and how is PlayerInfo defined? (I ask because it's a TERRIBLE name for a global variable!) Why is your green colour a variable (or why does it look like a variable)? "Float:PlayerInfo[player1][Deaths]/Float:PlayerInfo[player1][Deaths]" <- always 1! Finally why are you not using sscanf to get another player given that it allows you to type an ID or a name instead of just an ID?
Markx: To get online time use getdate in OnPlayerConnect and OnPlayerDisconnect. This will return a unix timestamp and you add the difference between join and leave to a saved running total. |
new Year, Month, Day; getdate(Year, Month, Day); printf("%02d/%02d/%d", Day, Month, Year); new Days = getdate(); printf("Days since the start of the year: %d", Days)
It is good, but i need it to save when a player disconnects, and load it when he connects
|