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=425422)



Array must be indexed. - Andriensis - 25.03.2013

so, i've got a problem here.

Код:
new pclan[20][MAX_PLAYERS];
CMD:f (playerid,params[])
{
if (logged[playerid] == 1 && pclan[playerid] != "Nessuno")
{
new str[60], s[256];
if(sscanf(params,"s[60]",str)) return SendClientMessage(playerid,GREY,"USO: /f [testo]");
format(s,sizeof(s),"[F-OOC] %s : %s",GetName(playerid),str);
for (new i=0; i<MAX_PLAYERS;i++)
{
SendClientMessage(i,ORANGE,s);
}
else
{
SendClientMessage(playerid,RED,"Non sei in un clan/non sei loggato.");
}
}
return 1;
}
I got an error on this line:
if (logged[playerid] == 1 && pclan[playerid] != "Nessuno")

Error:
prison.pwn(205 : error 033: array must be indexed (variable "pclan")


Re: Array must be indexed. - MyPony - 25.03.2013

You have something like:

new pclan[20][MAX_PLAYERS];

So, in that line you didn't include that [20]. I don't know what's the use if it, but check this out.


Re: Array must be indexed. - Andriensis - 25.03.2013

I use [20] because I give to this variable a string, so I must do it.
So.. how can I fix this?


Re: Array must be indexed. - MyPony - 25.03.2013

Change

new pclan[20][MAX_PLAYERS];

to

new pclan[MAX_PLAYERS][20];

Should work fine.


Re: Array must be indexed. - park4bmx - 25.03.2013

that is a string you cant check it that way.
pawn Код:
if (logged[playerid] == 1 && strcmp(!pclan[playerid], "Nessuno"))



Re: Array must be indexed. - Andriensis - 25.03.2013

Quote:
Originally Posted by park4bmx
Посмотреть сообщение
that is a string you cant check it that way.
pawn Код:
if (logged[playerid] == 1 && strcmp(!pclan[playerid], "Nessuno"))
Thanks, my dear. :>