OnPedVehicleEnter: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server event}}
{{Server event}}
{{New feature/item|3.0160|1.5.8|20740|This event is triggered when a ped enters a vehicle.}}
{{Added feature/item|1.5.9|1.5.8|20740|This event is triggered when a [[ped]] enters a [[vehicle]].}}


==Parameters==  
==Parameters==  
Line 8: Line 8:
</syntaxhighlight>  
</syntaxhighlight>  


*'''theVehicle''': a [[vehicle]] element representing the vehicle that was entered.
*'''theVehicle''': A [[vehicle]] element representing the [[vehicle]] that was entered.
*'''seat''': an [[int]] representing the seat in which the ped is entering.
*'''seat''': An [[int]] representing the seat in which the [[ped]] is entering.
*'''jacked''': a [[player]] or [[ped]] element representing who has been jacked.
*'''jacked''': A [[player]] or [[ped]] element representing who has been jacked.


==Source==
==Source==
The [[event system#Event source|source]] of this event is the [[ped]] that entered the vehicle.
The [[event system#Event source|source]] of this event is the [[ped]] that entered the [[vehicle]].


==Example==  
==Example==
{{Needs Example}}
Sending a message to every [[player]] when [[ped]] has entered to a [[vehicle]]:
<section name="Server" class="server" show="true">
Sending a message to every player when ped has entered to a vehicle
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function sendMessage(theVehicle, seat)
function sendMessage (theVehicle, seat)
   local vehicleName = getVehicleName(theVehicle) -- Get name of the vehicle
   local vehicleName = getVehicleName (theVehicle) -- Get name of the vehicle
   if seat==0 then -- if the ped is a driver
   if seat == 0 then -- if the ped is a driver
       outputChatBox("Ped is now a driver of "..vehicleName, root)
       outputChatBox ("Ped is now a driver of "..vehicleName, root)
   else -- if not
   else -- if not
       outputChatBox("Ped has entered to "..vehicleName, root)
       outputChatBox ("Ped has entered to "..vehicleName, root)
   end
   end
end
end
addEventHandler("onPedVehicleEnter", root, sendMessage)
 
addEventHandler ("onPedVehicleEnter", root, sendMessage)
</syntaxhighlight>
</syntaxhighlight>
</section>
 
==Requirements==
{{Requirements|1.5.8-9.20740|n/a|}}
 
{{See also/Server event|Ped events}}
{{See also/Server event|Ped events}}

Latest revision as of 21:20, 23 September 2021

This event is triggered when a ped enters a vehicle.

Parameters

vehicle theVehicle, int seat, ped jacked
  • theVehicle: A vehicle element representing the vehicle that was entered.
  • seat: An int representing the seat in which the ped is entering.
  • jacked: A player or ped element representing who has been jacked.

Source

The source of this event is the ped that entered the vehicle.

Example

Sending a message to every player when ped has entered to a vehicle:

function sendMessage (theVehicle, seat)
   local vehicleName = getVehicleName (theVehicle) -- Get name of the vehicle
   if seat == 0 then -- if the ped is a driver
      outputChatBox ("Ped is now a driver of "..vehicleName, root)
   else -- if not
      outputChatBox ("Ped has entered to "..vehicleName, root)
   end
end

addEventHandler ("onPedVehicleEnter", root, sendMessage)

Requirements

Minimum server version 1.5.8-9.20740
Minimum client version n/a

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" />

See Also

Ped events


Event functions