/stats error
#3

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.

PHP Code:
CMD:stats(playeridparams[]) 
{
    new 
player1;
    if (
sscanf(params"i"player1)) player1 playerid;
    
ShowStatsForPlayer(playeridplayer1);
    return 
1;
}
ShowStatsForPlayer(viewertarget)
{
    new 
string[500], hms;
    
TotalGameTime(targethms);
    
format(stringsizeof 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] == ? ("Yes") : ("No"),
        
PlayerInfo[target][LoggedIn] == ? ("Yes") : ("No"),
        
PlayerInfo[target][Hide] == PlayerInfo[target][Level],
        
GetPlayerScore(target),
        
hms,
        
GetPlayerPing(target),
        
GetPlayerCountryName(target),
        
GetPlayerMoney(target),
        
PlayerInfo[target][Bank],
        
GetPlayerSkin(target),
        
GetPlayerWantedLevel(target),
        
PlayerInfo[target][Kills],
        
PlayerInfo[target][Deaths],
        
PlayerInfo[target][Deaths] == ? (FloatPlayerInfo[target][Kills] / Float1) : (FloatPlayerInfo[target][Kills] / FloatPlayerInfo[target][Deaths]));
    return 
ShowPlayerDialog(playerid0DIALOG_STYLE_MSGBOX"Stats"string"Ok""");

Reply


Messages In This Thread
/stats error - by Filbert - 02.07.2018, 14:12
Re: /stats error - by Mike861 - 02.07.2018, 14:37
Re: /stats error - by Calisthenics - 02.07.2018, 14:41

Forum Jump:


Users browsing this thread: 1 Guest(s)