SetPedExitVehicle: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}
{{Added feature/item|3.0159|1.5.9|1.5.8|20740|This function makes a [[ped]] exit a [[vehicle]], similar to the enter_exit control state.}}
{{Added feature/item|1.5.9|1.5.8|20740|This function makes a [[ped]] exit a [[vehicle]], similar to the enter_exit control state.}}
 
{{Note|This function only works on synced peds and vehicles (i.e. created server-side).}}
{{Note|For this function to work on peds, the server and all clients are required to be on version '''1.5.8 r20740''' or newer.}}
{{Note|This function only works on synced peds and vehicles (i.e. created serverside).}}


==Syntax==  
==Syntax==  
Line 17: Line 15:
Returns ''true'' if the function was successful, ''false'' otherwise.
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. Exiting can still fail in the following cases
When this function returns ''true'', the client will ask server for permission to exit a vehicle.
*The function is used on a ped, but another client is not on version '''1.5.8 r20740''' or newer.


This function returns ''false'' in the following cases
This function returns ''false'' in the following cases
*Invalid arguments were parsed.
*Invalid arguments were parsed.
*The function is used on a ped but the server is not on version '''1.5.8 r20740''' or newer.
*Time passed since last enter/exit for this ped is less than 1500 ms.
*Time passed since last enter/exit for this ped is less than 1500 ms.
*The ped is getting jacked.
*The ped is already being jacked.


==Example==
==Example==
{{Needs Example}}
This example adds a command to make all synced peds exit their vehicles.
<syntaxhighlight lang="lua">
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)
</syntaxhighlight>


==Requirements==
==Requirements==

Latest revision as of 17:27, 2 January 2022

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)

Requirements

Minimum server version 1.5.8-9.20740
Minimum client version 1.5.8-9.20740

Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version server="1.5.8-9.20740" client="1.5.8-9.20740" />

See Also

Shared