SA-MP Forums Archive
Oh noes (Variable must be indexed) - 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: Oh noes (Variable must be indexed) (/showthread.php?tid=156205)



Oh noes (Variable must be indexed) - Hiddos - 21.06.2010

Never though I would give up this easily. But who never asks, never wins.

I get this error:

Код:
C:\Users\Hiddos\Hiddos\scripts\gamemodes\CODSW11.pwn(4201) : error 033: array must be indexed (variable "RankAmounts")
I can't seem to find what's wrong.
Line 4201:
pawn Код:
if(GetPVarInt(playerid,"Kills") >= RankAmounts[r])
RankAmounts:
pawn Код:
new RankAmounts[][] = {
    {50},
    {125},
    {200},
    {300},
    {450},
    {700},
    {1000}
};
Yes, I am an idiot. And no, I don't see a reason why an idiot isn't allowed to ask for help.


Re: Oh noes (Variable must be indexed) - SpiderPork - 21.06.2010

Where you define RankAmounts, you have this:

pawn Код:
RankAmounts[][]
Meaning there should be two parameters when you list them, but there's only one and you also use only one where you compare the two variables.


Re: Oh noes (Variable must be indexed) - DJDhan - 21.06.2010

You declared a two dimensional array:
Код:
new RankAmounts[][] = {
And you doing something like this :
Код:
if(GetPVarInt(playerid,"Kills") >= RankAmounts[r]) //<---see? single []
it should be something like this:
Код:
if(GetPVarInt(playerid,"Kills") >= RankAmounts[0][r])



Re: Oh noes (Variable must be indexed) - Hiddos - 21.06.2010

Fixed it, thanks.