Error 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: Error array must be indexed (
/showthread.php?tid=607573)
Error array must be indexed -
Eymeric69 - 21.05.2016
Hello everybody,
i don't know how to fix this problem i have see that human[MAX_PLAYER] but it's not working
there is the code :
PHP код:
CMD:humanclass(playerid, params[])
{
if (human == 2) // line 53
{
return 1;
}
else
{
SendClientMessage(playerid, COULEUR_ROUGE, "Tu n'est pas un humain.");
}
return 1;
}
new :
PHP код:
new zombie[1], human[2];
error :
Код:
C:\Users\mickael\Desktop\Zombie Serveur Test\filterscripts\Zombie&HumanSurvivalScript.pwn(53) : error 033: array must be indexed (variable "human")
thanks for helping me.
Re: Error array must be indexed -
SyS - 21.05.2016
try it
PHP код:
CMD:humanclass(playerid, params[])
{
if (human[playerid] == 2) // line 53
{
return 1;
}
else
{
SendClientMessage(playerid, COULEUR_ROUGE, "Tu n'est pas un humain.");
}
return 1;
}
Re: Error array must be indexed -
Eymeric69 - 21.05.2016
thanks fixed
Re: Error array must be indexed -
Konstantinos - 21.05.2016
It may compiled but you will get a run time error 4 if you run that code.
First think what you want to do because I look those:
and I'm pretty sure you meant to do something else. Having an array with size of 1 makes it only accessible at index 0 and human at index 0 and 1.
Were you supposed to define them as teams? If yes, it'd be:
pawn Код:
#define zombie 1
#define human 2
(even though we used to define a symbol in caps with #define pattern)
or
pawn Код:
enum
{
zombie = 1,
human
};
Re: Error array must be indexed -
SyS - 21.05.2016
Quote:
Originally Posted by Eymeric69
Hello everybody,
i don't know how to fix this problem i have see that human[MAX_PLAYER] but it's not working
|
Sorry i didnt see that but he said he have human[MAX_PLAYERS] on top thats why i told him to do like that
Re: Error array must be indexed -
Darrenr - 21.05.2016
Quote:
Originally Posted by Konstantinos
...
|
Following on from Konstantinos's post..
pawn Код:
#define zombie 1
#define human 2
new playerGang[MAX_PLAYERS];
pawn Код:
CMD:humanclass(playerid, params[])
{
if (playerGang[playerid]== human) // line 53
{
return 1;
}
else
{
SendClientMessage(playerid, COULEUR_ROUGE, "Tu n'est pas un humain.");
}
return 1;
}
I think that's how you can do it?