PlayerEnteredVehicle: Difference between revisions

From RAGE Multiplayer Wiki
(Created page with "This event is triggered when a player is in the car. ==Parameters== * '''player''' - player, which sits down. * '''vehicle''' - vehicle in which the player sits. ==Example=...")
 
m (Replaced HTML with template)
 
(4 intermediate revisions by 4 users not shown)
Line 7: Line 7:
==Example==
==Example==
This example outputs chat message, when player is in the car.
This example outputs chat message, when player is in the car.
<div class="header" style="background-color: #E4F1FE; color: #4183D7; width: 100%; border: 2px solid #81CFE0;">
{{ServersideCode|
<div style="margin: 4px 0px 4px 10px;"><b>Server-side</b></div>
<pre>
</div>
<div class="content" style="background-color: #E4F1FE; color: #4183D7; width: 100%; border: 2px solid #81CFE0; display: flex; justify-content: center; align-items: center;">
<syntaxhighlight lang="javascript" style="width: 98%; background-color: #E4F1FE;">
function playerEnteredVehicleHandler(player, vehicle) {
function playerEnteredVehicleHandler(player, vehicle) {
   const playerName = player.name
   const playerName = player.name;
   const vehicleID = vehicle.id
   const vehicleID = vehicle.id;
   const srt = playerName + " got into the car: " + vehicleID
 
  mp.players.broadcast(str)
   mp.players.broadcast(`${playerName} got into the car with ID: ${vehicleID}`);
}
}


mp.events.add("playerEnteredVehicle", playerEnteredVehicleHandler);
mp.events.add("playerEnteredVehicle", playerEnteredVehicleHandler);
</syntaxhighlight>
</pre>
</div>
}}
 
==See also==
{{Player_events}}

Latest revision as of 11:50, 26 October 2018

This event is triggered when a player is in the car.

Parameters

  • player - player, which sits down.
  • vehicle - vehicle in which the player sits.

Example

This example outputs chat message, when player is in the car.

Server-Side
function playerEnteredVehicleHandler(player, vehicle) {
   const playerName = player.name;
   const vehicleID = vehicle.id;

   mp.players.broadcast(`${playerName} got into the car with ID: ${vehicleID}`);
}

mp.events.add("playerEnteredVehicle", playerEnteredVehicleHandler);

See also

Checkpoint

Colshape

Entity

Player

Streaming

Vehicle

Waypoint