Array must be indexted! How To Index Arrays ???
#1

I want to make a Ranking System in my GangMode, but I get Errors like that "error 033: array must be indexed (variable "name2")"...the same with
variable "KillScore" and "DeathScore"...

Here is the pawn---->

public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/rank",cmdtext,true) == 0)
{
GetPlayerName(playerid,name2,sizeof(name2));
format(string,sizeof(string),"You have %d Kills",KillScore[name2]);
SendClientMessage(playerid,COLOR_YELLOW,string);
format(string,sizeof(string),"You Died %d Times",DeathScore[name2]);
SendClientMessage(playerid,COLOR_YELLOW,string);
}

if(KillScore == 1)
{
SendClientMessage(playerid,COLOR_YELLOW,"Your Rank Is-->Murder");
}
else if(KillScore == 2)
{
SendClientMessage(playerid,COLOR_YELLOW,"Your Rank Is-->P.I.M.P");
}
else if(KillScore == 3)
{
SendClientMessage(playerid,COLOR_YELLOW,"Your Rank Is-->Ganxsta");
}
else if(KillScore == 4)
{
SendClientMessage(playerid,COLOR_YELLOW,"Your Rank Is-->GangLeader");
}
else if(KillScore == 5)
{
SendClientMessage(playerid,COLOR_YELLOW,"Your Rank Is-->2 Pac");
}
else if(KillScore == 6)
{
SendClientMessage(playerid,COLOR_YELLOW,"Your Rank Is-->HoodGOD");
SendClientMessage(playerid,COLOR_YELLOW,"!You Have Reached the Highest Rank!");
}
else if(KillScore >= 6)
{
}
else if(DeathScore == 0 && DeathScore == 1)
{
SendClientMessage(playerid,COLOR_YELLOW,"Your Rank Is-->Pussy");
}
else if(DeathScore >= 2)
{
SendClientMessage(playerid,COLOR_YELLOW,"Your Rank Is-->Victim");
}
return 0;
}

MFG Bearfist
Reply
#2

A few things which i noticed.

KillScore[name2], why doing this, and not just putting the variable in the string?

And other 2 things, why getting player name, if that is useless.

And why not new killscore[MAX_PLAYERS];
and than continuing with killscore[playerid] and etc..
Reply
#3

If the variable is going to store an integer then it has to be in the format
pawn Код:
new variable;
If it is going to store a string then it has to be in the format
pawn Код:
new variable[size];
Reply
#4

Thanks a lot guys =)
Compiling worked...

I'm sry but I'm not a pro as you all are =D
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)