SA-MP Forums Archive
[HELP] Array if statement - 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: [HELP] Array if statement (/showthread.php?tid=594585)



[HELP] Array if statement - Hayden_Almeida - 20.11.2015


I Have this array with Vehicles ID:

Код:
new VeiculosDeOrg[3] = { 523,599,596 };
OnPlayerEnterVehicle i have:
Код:
new VehicleModel = GetVehicleModel(vehicleid);
if(VehicleModel != VeiculosDeOrg[0])
{
       SendClientMessage(playerid, COLOR_WHITE, "TEST.");
}
Even if i enter um Vehicle with this IDs in array, its printing. Why?


Re: [HELP] Array if statement - Karan007 - 20.11.2015

PHP код:
new VehicleModel GetVehicleModel(vehicleid);
if(
VehicleModel != VeiculosDeOrg[4])
{
       
SendClientMessage(playeridCOLOR_WHITE"TEST.");

Try this, maybe it works or simply use a loop to check it he has enter in that vehicle.


Re: [HELP] Array if statement - Hayden_Almeida - 20.11.2015

Quote:
Originally Posted by Karan007
Посмотреть сообщение
PHP код:
new VehicleModel GetVehicleModel(vehicleid);
if(
VehicleModel != VeiculosDeOrg[4])
{
       
SendClientMessage(playeridCOLOR_WHITE"TEST.");

Try this, maybe it works or simply use a loop to check it he has enter in that vehicle.
if a put [4] it gives me an error:
Код:
error 032: array index out of bounds (variable "VeiculosDeOrg")



Re: [HELP] Array if statement - DeathCore - 20.11.2015

PHP код:
for(new asizeof(VeiculosDeOrg); a++)
if(
GetVehicleModel(VeiculosDeOrg) != VeiculosDeOrg[a])return printf("TEST."); 



Re: [HELP] Array if statement - Hayden_Almeida - 20.11.2015

Quote:
Originally Posted by DeathCore
Посмотреть сообщение
PHP код:
for(new asizeof(VeiculosDeOrg); a++)
if(
GetVehicleModel(VeiculosDeOrg) != VeiculosDeOrg[a])return printf("TEST."); 
Код:
error 035: argument type mismatch (argument 1)



Re: [HELP] Array if statement - [ABK]Antonio - 20.11.2015

Check the vehicle id with vehicle id unless you're checking both of their models.


Re: [HELP] Array if statement - zPain - 20.11.2015

PHP код:
new VehicleModel GetVehicleModel(vehicleid);
for(new 
index 0index sizeof VeiculosDeOrg; ++index) {
    if(
VehicleModel != VeiculosDeOrg[index]) {
        
SendClientMessage(playerid, -1"TEST.");
    }




Re: [HELP] Array if statement - DeathCore - 21.11.2015

Код:
if(GetVehicleModel(VeiculosDeOrg[a]) != VeiculosDeOrg[a])return printf("TEST.");