SA-MP Forums Archive
loop certain vehicles - 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: loop certain vehicles (/showthread.php?tid=523401)



loop certain vehicles - Pillhead2007 - 02.07.2014

is there anyway to loop through a certain type of vehicle etc..
so it loops through and checks for taxi id 420 that's unoccupied and add attachment to the them taxi ids

for(new i = 0; i<MAX_VEHICLES;i++)
{
if(vehicleid == 420)
{
///etc code here
}
}

please help thanks


Re: loop certain vehicles - Jefff - 02.07.2014

replace vehicleid to GetVehicleModel(i)


Re: loop certain vehicles - Dignity - 02.07.2014

Quote:
Originally Posted by Jefff
Посмотреть сообщение
replace vehicleid to GetVehicleModel(i)
Also, use http://pastebin.com/Crt916CT to check whether a car is occupied or not.


Re: loop certain vehicles - OKStyle - 02.07.2014

pawn Код:
for(new i = 1, occupiedhicle; i < MAX_VEHICLES; i++)
{
    if(GetVehicleModel(i) != 420) continue;
   
    for(new j = GetMaxPlayers() - 1; j != -1; j--)
    {
        if(!IsPlayerInVehicle(j, i)) continue;
        occupiedhicle += 1;
        break;
    }
    if(occupiedhicle > 0)
    {
        occupiedhicle = 0;
        continue;
    }
    else Attach...
}



Re: loop certain vehicles - Pillhead2007 - 02.07.2014

thanks guys