PlayerEnterVehicle: Difference between revisions
(var) |
MrPancakers (talk | contribs) m (Removed workaround examples and text, added in 'known issue' which should be removed when fixed.) |
||
| Line 1: | Line 1: | ||
__NOTOC__ | |||
This event is triggered when a player is in the car. | This event is triggered when a player is in the car. | ||
''' | |||
*'''Known issue''': Client side this event is triggered when the player starts to enter the vehicle and not once they've completely sat down. This also causes the seat parameter to return 'undefined'. | |||
==Parameters== | ==Parameters== | ||
* '''player''' | * '''player''' | ||
* '''vehicle''' - vehicle | * '''vehicle''' - The current vehicle the player is sitting in. | ||
* '''seat''' - the | * '''seat''' - The seat ID the player sits down on. | ||
==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: #408DAE; color: #FFFFFF; border: 2px solid #408DAE;"> | |||
< | <div style="margin: 10px 10px 10px 10px;"><b>Server-Side</b></div> | ||
<pre> | |||
function playerEnterVehicleHandler(player, vehicle, seat) { | function playerEnterVehicleHandler(player, vehicle, seat) { | ||
player.outputChatBox(`${player.name} got into the car with ID: ${vehicle.id}. Seat: ${seat}`); | |||
} | |||
mp.events.add("playerEnterVehicle", playerEnterVehicleHandler); | |||
} | </pre> | ||
</div> | |||
<div class="header" style="background-color: #AE4040; color: #FFFFFF; border: 2px solid #AE4040;"> | |||
< | <div style="margin: 10px 10px 10px 10px;"><b>Client-Side</b></div> | ||
// | <pre> | ||
function playerEnterVehicleHandler(vehicle) { | function playerEnterVehicleHandler(vehicle, seat) { | ||
mp.gui.chat.push(`You got into the car with ID: ${vehicle.id}. Seat: ${seat}`); | mp.gui.chat.push(`You got into the car with ID: ${vehicle.id}. Seat: ${seat}`); | ||
} | } | ||
mp.events.add("playerEnterVehicle", playerEnterVehicleHandler); | mp.events.add("playerEnterVehicle", playerEnterVehicleHandler); | ||
</ | </pre> | ||
</div> | |||
==See also== | ==See also== | ||
{{Player_events}} | {{Player_events}} | ||
Revision as of 07:46, 21 October 2018
This event is triggered when a player is in the car.
- Known issue: Client side this event is triggered when the player starts to enter the vehicle and not once they've completely sat down. This also causes the seat parameter to return 'undefined'.
Parameters
- player
- vehicle - The current vehicle the player is sitting in.
- seat - The seat ID the player sits down on.
Example
This example outputs chat message, when player is in the car.
Server-Side
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
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