OnVehicleDeath

From GT-MP
Jump to: navigation, search
OnVehicleDeath
Server-Side Function
Utilities-terminal.png Server-Side Csharp.png C#

This type of event is used for handling code when a vehicle gets destroyed.

Requirements

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.onVehicleDeath += OnVehicleDeathHandler;
   }

Usage example

Before we start, myAwesomeVeh variable is of NetHandle type defined somewhere in the script, if missing, it will output an error

   private void OnVehicleDeathHandler(NetHandle vehicle)
   {
      if (vehicle == myAwesomeVeh)
      {
         API.sendChatMessageToAll("Oh no! that awesome vehicle got destroyed!");
      }
   }

References