PlayerEnterVehicle
This event is triggered when a player entered vehicle.
Server-Side Event
C# | JavaScript |
---|
C# Syntax
See OnPlayerEnterVehicle.
JavaScript Syntax
Parameters
- player: Player - The player which entered vehicle.
- vehicle: Vehicle - The current vehicle the player is sitting in.
- seat: Number - The seat ID the player sits down on.
Example
This example outputs chat message, when player is in the car.
function playerEnterVehicleHandler(player, vehicle, seat) { player.outputChatBox(`${player.name} got into the car with ID: ${vehicle.id}. Seat: ${seat}`); } mp.events.add("playerEnterVehicle", playerEnterVehicleHandler);
Client-Side Event
C# | JavaScript |
---|
C# Syntax
public delegate void OnPlayerEnterVehicleDelegate(Vehicle vehicle, int seatId);
Parameters
- vehicle - vehicle RAGE.Elements.Vehicle
- seatId - the id of the seat, expectsSystem.Int32
Example
The example below sends a chat message to play when they enter a vehicle, showing whether they are driver or passenger.
Events.OnPlayerEnterVehicle += OnPlayerEnterVehicle;
public void OnPlayerEnterVehicle(RAGE.Elements.Vehicle vehicle, int seatId, RAGE.Events.CancelEventArgs cancel)
{
if (seatId == -1)
{
RAGE.Chat.Output("You got in the driver's seat");
}
else
{
RAGE.Chat.Output("You got in a passenger seat");
}
}
JavaScript Syntax
Parameters
- vehicle: Vehicle - The current vehicle the player entered.
- seat: Number - The seat ID the player sits down on.
Example
function playerEnterVehicleHandler(vehicle, seat) { mp.gui.chat.push(`You got into the car with ID: ${vehicle.id}. Seat: ${seat}`); } mp.events.add("playerEnterVehicle", playerEnterVehicleHandler);
See also
Checkpoint
Colshape
Entity
Player
- playerChat
- playerCommand
- playerDamage
- playerDeath
- playerJoin
- playerQuit
- playerReady
- playerSpawn
- playerWeaponChange
Streaming
Vehicle
- playerStartEnterVehicle
- playerEnterVehicle
- playerStartExitVehicle
- playerExitVehicle
- trailerAttached
- vehicleDamage
- vehicleDeath
- vehicleHornToggle
- vehicleSirenToggle