OnPlayerEnterVehicle

From GT-MP
Jump to: navigation, search
OnPlayerEnterVehicle
Shared Function
Utilities-terminal.png Server-Side System-users.png Client-Side
Csharp.png C# Javascript.png JavaScript

This type of event is used for handling code when the player enters any type of vehicle.

Requirements

C#: First of all, it should be defined in your Main constructor for it to be called, otherwise it wouldn't be initiated at all!

   public Main()
   {
      API.onPlayerEnterVehicle += OnPlayerEnterVehicle;
   }

Usage example(s)

   private void OnPlayerEnterVehicle(Client player, NetHandle vehicle, int targetSeat)
   {
      if(vehicle == myAwesomeVeh) // myyAwesomeVeh defined elsewhere...
      {
         API.sendChatMessageToPlayer(player, "What an awesome vehicle!");
      }
   }

JS:

API.onPlayerEnterVehicle.connect(function(veh, targetSeat) {
    if(veh == myAwesomeVeh) { // myAwesomeVeh defined elsewhere...
       API.sendChatMessage("My awesome vehicle!");
    }
});

References