SA-MP Forums Archive
Array Problem? - 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 Problem? (/showthread.php?tid=439078)



Array Problem? - Yuup - 23.05.2013

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")



Re: Array Problem? - Swimor - 23.05.2013

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
	{
            // ...
	}
    }
}



Re: Array Problem? - Yuup - 23.05.2013

Thank you Swimor!