OnPlayerDeath

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

This type of event is used for handling code when someone dies.

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.onPlayerDeath += OnPlayerDeathHandler;
   }

Usage example(s)

   private void OnPlayerDeathHandler(Client player, NetHandle entityKiller, int weapon) {
      Client killer = API.getPlayerFromHandle(entityKiller);
      if (killer != null) {
         API.sendNotificationToAll(killer.name + " has killed " + player.name);
      } else {
         API.sendNotificationToAll(player.name + " died");
      }
   }

References