Stats command, ZCMD +rep.
#1

Hey guys, I've made the a stats command of my won, just to incase I got some errors and I really got confused how to fix it.

PHP код:
CMD:stats(playeridparams[])
{
new 
string[200];
format(stringsizeof(string), "Name: %s | ID: %d | Score: %d | Kills: %i | Deaths: %i | Money: %d | Adminlevel: %d"GetName(playerid), playeridGetPlayerScore(playerid), PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], GetPlayerMoney(playerid), AdminLevel[playerid]);
SendClientMessage(playerid ,COLOR_WHITEstring);
return 
1;

Those the errors Im getting

Код HTML:
C:\Users\бгйчд\Desktop\RolePlay Server\gamemodes\RolePlay.pwn(860) : error 028: invalid subscript (not an array or too many subscripts): "PlayerInfo"
C:\Users\бгйчд\Desktop\RolePlay Server\gamemodes\RolePlay.pwn(860) : warning 215: expression has no effect
C:\Users\бгйчд\Desktop\RolePlay Server\gamemodes\RolePlay.pwn(860) : error 001: expected token: ";", but found "]"
C:\Users\бгйчд\Desktop\RolePlay Server\gamemodes\RolePlay.pwn(860) : error 029: invalid expression, assumed zero
C:\Users\бгйчд\Desktop\RolePlay Server\gamemodes\RolePlay.pwn(860) : fatal error 107: too many error messages on one line
Line 860:

PHP код:
format(stringsizeof(string), "Name: %s | ID: %d | Score: %d | Kills: %i | Deaths: %i | Money: %d | Adminlevel: %d"GetName(playerid), playeridGetPlayerScore(playerid), PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], GetPlayerMoney(playerid), AdminLevel[playerid]); 
My Player Info:
PHP код:
enum PlayerInfo
{
    
Pass[129], //User's password
    
Adminlevel//User's admin level
    
VIPlevel//User's vip level
    
Money//User's money
    
Scores//User's scores
    
Kills//User's kills
    
Deaths //User's deaths

Thanks for anyone who can help me, I will really apprcieate it.
Reply
#2

"PlayerInfo" is the name of the enum, not of the array. So use the name of the array. An example:
pawn Код:
enum PlayerInfo
{
    Pass[129], //User's password
    Adminlevel, //User's admin level
    VIPlevel, //User's vip level
    Money, //User's money
    Scores, //User's scores
    Kills, //User's kills
    Deaths //User's deaths
};

new pInfo[MAX_PLAYERS][PlayerInfo];
and you use this instead:
pawn Код:
CMD:stats(playerid, params[])
{
    new string[128];
    format(string, sizeof(string), "Name: %s | ID: %d | Score: %d | Kills: %i | Deaths: %i | Money: %d | Adminlevel: %d", GetName(playerid), playerid, GetPlayerScore(playerid), pInfo[playerid][Kills], pInfo[playerid][Deaths], GetPlayerMoney(playerid), pInfo[playerid][Adminlevel]);
    SendClientMessage(playerid, -1, string);
    return 1;
}
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
"PlayerInfo" is the name of the enum, not of the array. So use the name of the array. An example:
pawn Код:
enum PlayerInfo
{
    Pass[129], //User's password
    Adminlevel, //User's admin level
    VIPlevel, //User's vip level
    Money, //User's money
    Scores, //User's scores
    Kills, //User's kills
    Deaths //User's deaths
};

new pInfo[MAX_PLAYERS][PlayerInfo];
and you use this instead:
pawn Код:
CMD:stats(playerid, params[])
{
    new string[128];
    format(string, sizeof(string), "Name: %s | ID: %d | Score: %d | Kills: %i | Deaths: %i | Money: %d | Adminlevel: %d", GetName(playerid), playerid, GetPlayerScore(playerid), pInfo[playerid][Kills], pInfo[playerid][Deaths], GetPlayerMoney(playerid), pInfo[playerid][Adminlevel]);
    SendClientMessage(playerid, -1, string);
    return 1;
}
Works, thank you! really apprciate it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)