PlayerStartEnterVehicle
This event is triggered when a player starts to get into a vehicle. This event is cancellable.
Server-Side Event
JavaScript |
---|
JavaScript Syntax
Parameters
- player: Player - player, which sits down (serverside only)
- vehicle: Vehicle - vehicle in which the player sits.
- seat: Number - the place where he sits down.
Example
This example outputs a chat message when a player gets into a vehicle.
function playerStartEnterVehicleHandler(player, vehicle, seat) { const playerName = player.name; const vehicleID = vehicle.id; mp.players.broadcast(`${playerName} started to get into the car ID: ${vehicleID}. Seat: ${seat}`); } mp.events.add("playerStartEnterVehicle", playerStartEnterVehicleHandler);
Client-Side Event
C# | JavaScript |
---|
C# Syntax
public delegate void OnPlayerStartEnterVehicleDelegate(RAGE.Elements.Vehicle vehicle, int seatId, RAGE.Events.CancelEventArgs cancel);
Parameters
- vehicle - vehicle RAGE.Elements.Vehicle
- seatId - the id of the seat, expectsSystem.Int32
- cancel - cancel, expects RAGE.Events.CancelEventArgs
Example
The example below sends a message to client when they start to get in a vehicle, showing whether they are a driver or passenger.
Events.OnPlayerStartEnterVehicle += OnPlayerStartEnterVehicle;
public void OnPlayerStartEnterVehicle(RAGE.Elements.Vehicle vehicle, int seatId, RAGE.Events.CancelEventArgs cancel)
{
if (seatId == -1)
{
RAGE.Chat.Output("You started to get in the driver's seat");
}
else
{
RAGE.Chat.Output("You started to get in a passenger seat");
}
}
JavaScript Syntax
// The player is not emmited client-side assuming it's you function playerStartEnterVehicleHandler(vehicle, seat) { const vehicleID = vehicle.id; mp.game.graphics.notify(`You started to get into the car ID: ${vehicleID}. Seat: ${seat}`); } mp.events.add("playerStartEnterVehicle", playerStartEnterVehicleHandler);
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