Error array must be indexed
#1

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(playeridparams[])
{
    if (
human == 2// line 53
    
{
        return 
1;
    }
    else
    {
        
SendClientMessage(playeridCOULEUR_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.
Reply
#2

try it
PHP код:
CMD:humanclass(playeridparams[]) 

    if (
human[playerid] == 2// line 53 
    

        return 
1
    } 
    else 
    { 
        
SendClientMessage(playeridCOULEUR_ROUGE"Tu n'est pas un humain."); 
    } 
    return 
1

Reply
#3

thanks fixed
Reply
#4

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:
pawn Код:
new zombie[1], human[2];
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
};
Reply
#5

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
Reply
#6

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)