OnPedVehicleEnter: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Server event}} {{New feature/item|3.0160|1.5.8|20740|This event is triggered when a ped enters a vehicle.}} ==Parameters== <syntaxhighlight lang="lua"> vehicle...")
 
mNo edit summary
(4 intermediate revisions by 2 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.}}
{{New feature/item|3.0159|1.5.8|20740|This event is triggered when a ped enters a vehicle.}}


==Parameters==  
==Parameters==  
Line 15: Line 15:
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==  
<section name="Example 1" class="server" show="true">
{{Needs Example}}
Sending a message to every player when ped has entered to a vehicle
 
<syntaxhighlight lang="lua">
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)
</syntaxhighlight>
</section>
{{See also/Server event|Ped events}}
{{See also/Server event|Ped events}}

Revision as of 11:26, 11 April 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.

Click to collapse [-]
Example 1

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)

See Also

Ped events


Event functions