OnPlayerHealthChange

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

This event is triggered when a player's health changes.

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.onPlayerHealthChange += OnPlayerHealthChangeHandler;
}

Usage example(s)

private void OnPlayerHealthChangeHandler(Client entity, int oldValue)
{
	if(entity.health>oldValue){
		API.sendChatMessageToAll("~g~"+entity.name+" got healed!");
	}else{
		API.sendChatMessageToAll("~r~"+entity.name+" got damaged!");
	}
}

References