Teleport as passenger?
#4

You can use this function, to detect where there is a free seat in the car, so no one gets kicked, if there are other passengers:

pawn Код:
GetVehiclePassengers(vehicleid, passengers[4])
{
    for(new i = 0; i < 4; i ++)
        passengers[i] = -1;
    for(new i = 0; i < MAX_PLAYERS; i ++)
        if(GetPlayerVehicleID(i) == vehicleid)
            passengers[GetPlayerVehicleSeat(i)] = i;
}
(Still did not test it, even i posted it sometimes already )

It is used like this:
pawn Код:
if(IsPlayerInAnyVehicle(player_tele_target))    //To detect if the target is in a vehicle
{
    new passengers[4];
    GetVehiclePassengers(GetPlayerVehicleID(player_tele_target), passengers);
    //GetVehicePassengers fills the array with the playerid at the specific seat (passengers[0] is the driver etc)
    //and with -1 if it is free, so check for -1 with a loop
    for(new i = 0; i < 4; i ++)
    {
        if(passengers[i] == -1) PutPlayerInVehicle(playerid, GetPlayerVehicleID(player_tele_target), i);
        //This will put the player on the first free seat
    }
}
Reply


Messages In This Thread
Teleport as passenger? - by WizardCM - 22.09.2010, 04:13
Re: Teleport as passenger? - by Kitten - 22.09.2010, 04:35
Re: Teleport as passenger? - by WizardCM - 22.09.2010, 06:37
Re: Teleport as passenger? - by Mauzen - 22.09.2010, 08:57
Re: Teleport as passenger? - by WizardCM - 22.09.2010, 09:23
Re: Teleport as passenger? - by WizardCM - 22.09.2010, 13:21

Forum Jump:


Users browsing this thread: 1 Guest(s)