PlayerEnteredVehicle: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
(Made example look cooler)
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;">
<div class="header" style="background-color: #408DAE; color: #FFFFFF; border: 2px solid #408DAE;">
<div style="margin: 4px 0px 4px 10px;"><b>Server-side</b></div>
<div style="margin: 10px 10px 10px 10px;"><b>Server-Side</b></div>
</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;">
<syntaxhighlight lang="javascript" style="width: 98%; background-color: #E4F1FE;">
function playerEnteredVehicleHandler(player, vehicle) {
function playerEnteredVehicleHandler(player, vehicle) {

Revision as of 19:54, 18 September 2017

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
   const srt = playerName + " got into the car: " + vehicleID
   mp.players.broadcast(str)
}

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

See also