02.07.2018, 14:41
AdminLevel1 should be an integer.
When you have repeated code, make it a function.
You can use ternary operator for "Yes"/"No".
Based on its name, when "Hide" is 1 shouldn't have been admin level 0? If not, change it in the code.
When you have repeated code, make it a function.
You can use ternary operator for "Yes"/"No".
Based on its name, when "Hide" is 1 shouldn't have been admin level 0? If not, change it in the code.
PHP Code:
CMD:stats(playerid, params[])
{
new player1;
if (sscanf(params, "i", player1)) player1 = playerid;
ShowStatsForPlayer(playerid, player1);
return 1;
}
ShowStatsForPlayer(viewer, target)
{
new string[500], h, m, s;
TotalGameTime(target, h, m, s);
format(string, sizeof string,
"{ff4d4d}Stats of %s\n\n{FFFFFF}Registered: %s\nLoggedIn: %s\nAdmin Level: %d\nScore: %d\nTime: %d hrs %d mins %d secs\nPing: %d\nCountry: %s\
\n\n{33AA33}Cash: $%d\nBank: $%d\n\n{FFFFFF}Skin: %d\nWanted level: %d\n\n{FFFF00}Kills and Deaths\n{FFFFFF}Kills: %d\nDeaths: %d\nRatio: %f",
pName(target),
PlayerInfo[target][Registered] == 1 ? ("Yes") : ("No"),
PlayerInfo[target][LoggedIn] == 1 ? ("Yes") : ("No"),
PlayerInfo[target][Hide] == 1 ? 0 : PlayerInfo[target][Level],
GetPlayerScore(target),
h, m, s,
GetPlayerPing(target),
GetPlayerCountryName(target),
GetPlayerMoney(target),
PlayerInfo[target][Bank],
GetPlayerSkin(target),
GetPlayerWantedLevel(target),
PlayerInfo[target][Kills],
PlayerInfo[target][Deaths],
PlayerInfo[target][Deaths] == 0 ? (Float: PlayerInfo[target][Kills] / Float: 1) : (Float: PlayerInfo[target][Kills] / Float: PlayerInfo[target][Deaths]));
return ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "Stats", string, "Ok", "");
}