/stats command
#10

All wrong:

You're using format incorrectly.
Quote:
Originally Posted by willbedie
Посмотреть сообщение
PHP код:
CMD:stats(playeridparams[])
{
    if(
connected[playerid] == true) return GameTextForPlayer(playerid"~r~Spawn First"50005);
    new 
string[256], stats[256], name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    
format(stringsizeof(string), "{4286f4}Name{FFFFFF}: %s\n"name);
    
format(statsstring);
    
format(stringsizeof(string), "{4286f4}Admin Level{FFFFFF}: %i\n"pInfo[playerid][Admin]);
    
format(statsstring);
    
format(stringsizeof(string), "{4286f4}Score{FFFFFF}: %i\n"pInfo[playerid][Score]);
    
format(statsstring);
    
format(stringsizeof(string), "{4286f4}Kills{FFFFFF}: %i\n"PlayerKills[playerid]);
    
format(statsstring);
    
format(stringsizeof(string), "{4286f4}Deaths:{FFFFFF}: %i\n"PlayerDeaths[playerid]);
    
format(statsstring);
    
format(stringsizeof(string), "{4286f4}Points:{FFFFFF}: %i\n"pInfo[playerid][Points]);
    
format(statsstring);
    
ShowPlayerDialog(playerid55DIALOG_STYLE_MSGBOX"Stats"stats"Ok""");
    return 
1;

OP:

format() the string in a holder then use strcat to concatenate the two. Example:

PHP код:
CMD:wooplayeridparams[] ) {
    new 
szPrimaryStr600 ], szSubStr128 ];
    
formatszSubStrsizeof szSubStr"My player ID is : %i\n"playerid );
    
strcatszPrimaryStrszSubStr );
    return 
1;

In that example, you would show szPrimaryStr as the dialogs text.

Regarding OnPlayerDeath,

you need to add a statement to check if the killerID is not INVALID_PLAYER_ID when it's relevant. i.e:
PHP код:
if( killerid != INVALID_PLAYER_ID ) {
     
gPlayerKillskillerid ] ++; 

If a player suicides, killerID will be 65535 and you'll end up accessing an out of bound index.
Reply


Messages In This Thread
/stats command - by ivndosos - 04.02.2018, 17:37
Re: /stats command - by jasperschellekens - 04.02.2018, 17:42
Re: /stats command - by ivndosos - 04.02.2018, 17:49
Re: /stats command - by jasperschellekens - 04.02.2018, 18:00
Re: /stats command - by ivndosos - 04.02.2018, 18:02
Re: /stats command - by jasperschellekens - 04.02.2018, 18:09
Re: /stats command - by ivndosos - 04.02.2018, 18:14
Re: /stats command - by solstice_ - 04.02.2018, 21:24
Re: /stats command - by ivndosos - 05.02.2018, 06:09
Re: /stats command - by Kane - 05.02.2018, 07:49

Forum Jump:


Users browsing this thread: 1 Guest(s)