SA-MP Forums Archive
Array 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)
+--- Thread: Array Must Be Indexed (/showthread.php?tid=306438)



Array Must Be Indexed - vincee - 26.12.2011

So I'm creating my code for a taxi radio, and I get a error

pawn Код:
if(strcmp(cmd, "/tr", true) == 0 || strcmp(cmd, "/taxiradio", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new wstring[128];
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[128];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "[USAGE] /tr [message]");
                return 1;
            }
            if(Muted[playerid])
            {
                SendClientMessage(playerid, COLOR_RED, "[ERROR] You can't use the radio, your muted.");
                return 1;
            }
            if(Taxijob == 1)
            {
                format(wstring, sizeof(wstring), "(DPSCOM) %s : %s",GetPlayerNameEx(playerid),result);
                SendTaxiMessage(COLOR_YELLOW, wstring);
                return 1;
            }
        }
        return 1;
    }
Код:
C:\Users\machine\Desktop\PCRPbeta\gamemodes\pcrp.pwn(7513) : error 033: array must be indexed (variable "Taxijob")



Re: Array Must Be Indexed - Stefan_Toretto - 26.12.2011

Where do you defined 'Taxijob'?


Re: Array Must Be Indexed - vincee - 26.12.2011

pawn Код:
new Taxijob[MAX_PLAYERS];
that's it?


Re: Array Must Be Indexed - vincee - 26.12.2011

FIXED.

I forgot to add [playerid]


Re: Array Must Be Indexed - Stefan_Toretto - 26.12.2011

Quote:
Originally Posted by vincee
Посмотреть сообщение
FIXED.

I forgot to add [playerid]
Exactly...