If Player Is In Vechile
#1

How To Set This To If Player Is In ComTruck it doesnt do the else return

pawn Code:
if(GetPlayerVehicleID(playerid) <= ComTruck[0] && GetPlayerVehicleID(playerid) >= ComTruck[12])
{
 else return SendClientMessage(playerid, GREY, "    You can only deliver in a truck.");
                    }
Reply
#2

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 . Your if/else structure is also wrong.

pawn Code:
new vehicleid = GetPlayerVehicleID(playerid);

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


Forum Jump:


Users browsing this thread: 1 Guest(s)