Array Problem?
#1

I don't understand what i have to do here.

Код:
new VehicleOwner[MAX_OWNEDVEHICLES][MAX_PLAYER_NAME];

cmd(test, playerid, params[])
{
    for(new i=0; i < MAX_OWNEDVEHICLES; i++)
    {
        if(VehicleOwner[i] == PlayerName(playerid)) // This is the error line
	{
            // ...
	}
    }
}

error 033: array must be indexed (variable "VehicleOwner")
Код:
// And if i try this i get another error
if(VehicleOwner[i][MAX_PLAYER_NAME] == PlayerName(playerid))
 
error 032: array index out of bounds (variable "VehicleOwner")
Reply
#2

You should use strcmp to compare two string like you did,
try this:
Код:
cmd(test, playerid, params[])
{
    for(new i=0; i < MAX_OWNEDVEHICLES; i++)
    {
        if(!strcmp(VehicleOwner[i], PlayerName(playerid), true)) // This is the error line
	{
            // ...
	}
    }
}
Reply
#3

Thank you Swimor!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)