OnPedVehicleEnter: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 20: Line 20:
Sending a message to every player when ped has entered to a vehicle
Sending a message to every player when ped has entered to a vehicle
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function sendMessage()
function sendMessage(theVehicle, seat)
   for _, player in pairs(getElementsByType("player")) do
   local vehicleName = getVehicleName(theVehicle) -- Get name of the vehicle
       outputChatBox("Ped has entered to a vehicle", player)
  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
end
end

Revision as of 10:58, 29 January 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

Accessories-text-editor.png Script Example Missing Event OnPedVehicleEnter needs a script example, help out by writing one.

Before submitting check out Editing Guidelines Script Examples.
Click to collapse [-]
Server

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