SetPedExitVehicle: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Removed version comment and rephrased some notes)
(Remove obsolete Requirements section)
 
(One intermediate revision by one other user not shown)
Line 23: Line 23:


==Example==
==Example==
{{Needs Example}}
This example adds a command to make all synced peds exit their vehicles.
 
<syntaxhighlight lang="lua">
==Requirements==
function exitPedVehicles()
{{Requirements|1.5.8-9.20740|1.5.8-9.20740}}
-- For all streamed-in peds
for k,ped in ipairs(getElementsByType("ped", root, true)) do
-- Are we syncing it and is it in a vehicle
if isElementSyncer(ped) and isPedInVehicle(ped) then
setPedExitVehicle(ped)
end
end
end
addCommandHandler("getout", exitPedVehicles)
</syntaxhighlight>


==See Also==
==See Also==
{{Client ped functions}}
{{Client ped functions}}

Latest revision as of 17:23, 7 November 2024

This function makes a ped exit a vehicle, similar to the enter_exit control state.

[[{{{image}}}|link=|]] Note: This function only works on synced peds and vehicles (i.e. created server-side).

Syntax

bool setPedExitVehicle ( ped thePed )

Required Arguments

  • thePed: The player or ped to exit the vehicle.

Returns

Returns true if the function was successful, false otherwise.

When this function returns true, the client will ask server for permission to exit a vehicle.

This function returns false in the following cases

  • Invalid arguments were parsed.
  • Time passed since last enter/exit for this ped is less than 1500 ms.
  • The ped is already being jacked.

Example

This example adds a command to make all synced peds exit their vehicles.

function exitPedVehicles()
	-- For all streamed-in peds
	for k,ped in ipairs(getElementsByType("ped", root, true)) do
		-- Are we syncing it and is it in a vehicle
		if isElementSyncer(ped) and isPedInVehicle(ped) then
			setPedExitVehicle(ped)
		end
	end
end
addCommandHandler("getout", exitPedVehicles)

See Also