SA-MP Forums Archive
Array must be indexted! How To Index Arrays ??? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Array must be indexted! How To Index Arrays ??? (/showthread.php?tid=73617)



Array must be indexted! How To Index Arrays ??? - Bearfist - 16.04.2009

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


Re: Array must be indexted! How To Index Arrays ??? - Rks25 - 16.04.2009

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..


Re: Array must be indexted! How To Index Arrays ??? - ICECOLDKILLAK8 - 16.04.2009

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];



Re: Array must be indexted! How To Index Arrays ??? - Bearfist - 16.04.2009

Thanks a lot guys =)
Compiling worked...

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