View Full Version : If Player Is In Vechile

20/06/2013, 12:03 PM
How To Set This To If Player Is In ComTruck it doesnt do the else return

if(GetPlayerVehicleID(playerid) <= ComTruck[0] && GetPlayerVehicleID(playerid) >= ComTruck[12])
else return SendClientMessage(playerid, GREY, " You can only deliver in a truck.");

20/06/2013, 12:07 PM
That is not the correct way to do this at all. You need to loop through each truck ID and check if they are in it. You can't just assume the IDs are consecutive (i.e. 4, 5, 6, 7 and 8). Your if/else structure is also wrong.

new vehicleid = GetPlayerVehicleID(playerid);

for(new i=0; i < sizeof(ComTruck); i++)
if(vehicleid == ComTruck[i])
// They are in truck 'i', code here
// Not in a truck