What is wrong in STATS Command?
#1

Hello, Im making a /STATS Command but its not work given me some errors... how to fix it

ERRORS:

Код:
error 028: invalid subscript (not an array or too many subscripts): "PlayerInfo"
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
Код:
CMD:stats(playerid, parms[])
{
  if(IsPlayerConnected(playerid))
  {
	new admin = PlayerInfo[playerid][pAdminLevel];
	new VIP = PlayerInfo[playerid][pVIPLevel];
	new money = PlayerInfo[playerid][pMoney];
	new score = PlayerInfo[playerid][pScore];
	new Deaths = PlayerInfo[playerid][pDeaths];
	new Kills = PlayerInfo[playerid][pKills];
	new Cookies = PlayerInfo[playerid][pCookies];
	format(string1,sizeof string1, "{2BFF00}Admin: {FFFFFF}[$%d] |- {2BFF00}V.I.P: {FFFFFF}[$%d] |- {2BFF00}Money: {FFFFFF}[$%d] |- {2BFF00}Score: {FFFFFF}[%d] |- {2BFF00}Deaths: {FFFFFF}[%d] |- {2BFF00}Kills: {FFFFFF}[%d] |- {2BFF00}Cookies: {FFFFFF}[%d]", admin,vip,money,score,deaths,kills,cookies);
	format(stats,sizeof stats, "%s", string1);
	ShowPlayerDialog(playerid,998,DIALOG_STYLE_MSGBOX,"{01B6F7}ACCOUNT STATS{F5F5F5}:",stats,"OK","");
  }
  return 1;
}
Here the enum
PHP код:
enum PlayerInfo
{
    
Pass[129],
    
Adminlevel,
    
VIPlevel,
    
Money,
    
Scores,
    
Kills,
    
Cookies,
    
Deaths
}
//News
new pInfo[MAX_PLAYERS][PlayerInfo]; 
Reply
#2

Your enum is make a good look on your enum,
for example, "Cookies", it should be PlayerInfo[playerid][Cookies] but instead you used PlayerInfo[playerid][pCookies]
Reply
#3

Why all that code, you could obtain this in 2 lines.

Why double format? And why assigning the variables? Simply use them in format, e g:

Quote:

format(string1, sizeof(string1), "Admin Level: %d",PlayerInfo[playerid][pAdminLevel]);

And show string1 in dialog instead of reformatting.


PS: string1 & stats are global variables?
Reply
#4

Quote:
Originally Posted by Thanks
Посмотреть сообщение
Hello, Im making a /STATS Command but its not work given me some errors... how to fix it

ERRORS:

Код:
error 028: invalid subscript (not an array or too many subscripts): "PlayerInfo"
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
Код:
CMD:stats(playerid, parms[])
{
  if(IsPlayerConnected(playerid))
  {
	new admin = PlayerInfo[playerid][pAdminLevel];
	new VIP = PlayerInfo[playerid][pVIPLevel];
	new money = PlayerInfo[playerid][pMoney];
	new score = PlayerInfo[playerid][pScore];
	new Deaths = PlayerInfo[playerid][pDeaths];
	new Kills = PlayerInfo[playerid][pKills];
	new Cookies = PlayerInfo[playerid][pCookies];
	format(string1,sizeof string1, "{2BFF00}Admin: {FFFFFF}[$%d] |- {2BFF00}V.I.P: {FFFFFF}[$%d] |- {2BFF00}Money: {FFFFFF}[$%d] |- {2BFF00}Score: {FFFFFF}[%d] |- {2BFF00}Deaths: {FFFFFF}[%d] |- {2BFF00}Kills: {FFFFFF}[%d] |- {2BFF00}Cookies: {FFFFFF}[%d]", admin,vip,money,score,deaths,kills,cookies);
	format(stats,sizeof stats, "%s", string1);
	ShowPlayerDialog(playerid,998,DIALOG_STYLE_MSGBOX,"{01B6F7}ACCOUNT STATS{F5F5F5}:",stats,"OK","");
  }
  return 1;
}
Here the enum
PHP код:
enum PlayerInfo
{
    
Pass[129],
    
Adminlevel,
    
VIPlevel,
    
Money,
    
Scores,
    
Kills,
    
Cookies,
    
Deaths
}
//News
new pInfo[MAX_PLAYERS][PlayerInfo]; 
Your code is wrong, why you double format the string? And i recommended to use %i. Fix it like this :

PHP код:
CMD:stats(playeridparms[])
{
  new 
stats[256];
  if(
IsPlayerConnected(playerid))
  {
    new 
admin pInfo[playerid][AdminLevel];
    new 
vip pInfo[playerid][VIPLevel];
    new 
money pInfo[playerid][Money];
    new 
score pInfo[playerid][Score];
    new 
deaths pInfo[playerid][Deaths];
    new 
kills pInfo[playerid][Kills];
    new 
cookies pInfo[playerid][Cookies];
    
format(stats,sizeof(stats), "{2BFF00}Admin: {FFFFFF}[$%i] |- {2BFF00}V.I.P: {FFFFFF}[$%i] |- {2BFF00}Money: {FFFFFF}[$%i] |- {2BFF00}Score: {FFFFFF}[%i] |- {2BFF00}Deaths: {FFFFFF}[%i] |- {2BFF00}Kills: {FFFFFF}[%i] |- {2BFF00}Cookies: {FFFFFF}[%i]"admin,vip,money,score,deaths,kills,cookies);
    
ShowPlayerDialog(playerid,998,DIALOG_STYLE_MSGBOX,"{01B6F7}ACCOUNT STATS{F5F5F5}:",stats,"OK","");
  }
  return 
1;

Reply
#5

try it

PHP код:
CMD:stats(playeridparams[])
{
new 
string1[128];
  if(
IsPlayerConnected(playerid))
  {
    new 
admin PlayerInfo[playerid][pAdminLevel];
    new 
VIP PlayerInfo[playerid][pVIPLevel];
    new 
money PlayerInfo[playerid][pMoney];
    new 
score PlayerInfo[playerid][pScore];
    new 
Deaths PlayerInfo[playerid][pDeaths];
    new 
Kills PlayerInfo[playerid][pKills];
    new 
Cookies PlayerInfo[playerid][pCookies];
    
format(string1sizeof(string1), "{2BFF00}Admin: {FFFFFF}[$%d] \n|- {2BFF00}V.I.P: {FFFFFF}[$%d] \n|- {2BFF00}Money: {FFFFFF}[$%d] \n|- {2BFF00}Score: {FFFFFF}[%d] \n|- {2BFF00}Deaths: {FFFFFF}[%d] \n|- {2BFF00}Kills: {FFFFFF}[%d] \n|- {2BFF00}Cookies: {FFFFFF}[%d]"admin,vip,money,score,deaths,kills,cookies);
    
ShowPlayerDialog(playerid,998,DIALOG_STYLE_MSGBOX,"{01B6F7}ACCOUNT STATS{F5F5F5}:",string1,"OK","");
  }
  return 
1;

Reply
#6

Quote:
Originally Posted by haikalbintang
Посмотреть сообщение
And i recommended to use %i.
That's the same thing.
Reply
#7

PHP код:
CMD:stats(playeridparams[])
{
    new 
string1[128];
    if(
IsPlayerConnected(playerid))
        
format(string1sizeof(string1), "{2BFF00}Admin: {FFFFFF}[$%d] \n|- {2BFF00}V.I.P: {FFFFFF}[$%d] \n|- {2BFF00}Money: {FFFFFF}[$%d] \n|- {2BFF00}Score: {FFFFFF}[%d] \n|- {2BFF00}Deaths: {FFFFFF}[%d] \n|- {2BFF00}Kills: {FFFFFF}[%d] \n|- {2BFF00}Cookies: {FFFFFF}[%d]"PlayerInfo[playerid][pAdminLevel],PlayerInfo[playerid][pVIPLevel],PlayerInfo[playerid][pMoney],PlayerInfo[playerid][pScore],PlayerInfo[playerid][pDeaths],PlayerInfo[playerid][pKills],PlayerInfo[playerid][pCookies]);
        
ShowPlayerDialog(playerid,998,DIALOG_STYLE_MSGBOX,"{01B6F7}ACCOUNT STATS{F5F5F5}:",string1,"OK","");
    return 
1;

Thats what i meant
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)