RemovePedFromVehicle: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: {{Server function}} __NOTOC__ This function removes a ped from a vehicle immediately. This works for drivers and passengers. Note that this removes the ped from the vehicle and puts him in...)
 
Line 15: Line 15:


==Example==  
==Example==  
Small example to show how to remove a ped from any vehicle it's in.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
-- TODO
function setupForRace ( )
    RacerPed = createPed ( 252, 0, 0, 3 )                        -- create a ped called "RacerPed".
    local RaceVehicle = createVehicle ( 411, 4, 0, 3 )            -- create a vehicle.
    warpPedIntoVehicle ( RacerPed, RaceVehicle )                  -- warp the ped straight into the vehicle
    setTimer(removeThePed, 5000, 1)                              -- Setup a timer which will remove the ped from the vehicle after 5 seconds.
end
addCommandHandler ( "startrace", setupForRace )                  -- add a command to start race
 
 
function removeThePed ( )
removePedFromVehicle ( RacerPed )                                -- Removes the ped from any vehicle.
end
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Ped functions}}
{{Ped functions}}

Revision as of 10:06, 3 June 2008

This function removes a ped from a vehicle immediately. This works for drivers and passengers. Note that this removes the ped from the vehicle and puts him in the exact position where the command was initiated.

Syntax

bool removePedFromVehicle ( ped thePed )           

Required Arguments

  • thePed: The ped you wish to remove from a vehicle

Returns

Returns true if the operation was successful, false otherwise.

Example

Small example to show how to remove a ped from any vehicle it's in.

function setupForRace ( )
    RacerPed = createPed ( 252, 0, 0, 3 )                         -- create a ped called "RacerPed".
    local RaceVehicle = createVehicle ( 411, 4, 0, 3 )            -- create a vehicle.
    warpPedIntoVehicle ( RacerPed, RaceVehicle )                  -- warp the ped straight into the vehicle
    setTimer(removeThePed, 5000, 1)                               -- Setup a timer which will remove the ped from the vehicle after 5 seconds.
end
addCommandHandler ( "startrace", setupForRace )                   -- add a command to start race


function removeThePed ( )
removePedFromVehicle ( RacerPed )                                 -- Removes the ped from any vehicle. 
end

See Also