PlayerEnterVehicle

From RAGE Multiplayer Wiki
Jump to navigation Jump to search

This event is triggered when a player entered vehicle.

Server-Side
Event

C.png C# Js.png JavaScript




C# Syntax
C.png


JavaScript Syntax
Jslogo.png

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.png C# Js.png JavaScript



C# Syntax
C.png

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
Jslogo.png

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

Streaming

Vehicle

Waypoint