SetPlayerHealth

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

This function sets the health of the given player.


Syntax

API.setPlayerHealth(Client player, int health);

Required Arguments

  • player: parameter input should be in Client type.
  • health: parameter input should be in int type.


Usage example(s)

/sethealth command that sets your health to the given value:

In C#
Server-Side Function

[Command("sethealth")]
public void CMD_SetHealth(Client player, int amount)
{
    API.setPlayerHealth(player, amount);
    API.sendChatMessageToPlayer(player, "Health set to: " + amount);
}

/givehealth command that increases your health by the given value:

In C#
Server-Side Function

[Command("givehealth")]
public void CMD_GiveHealth(Client player, int amount)
{
    API.setPlayerHealth(player, API.getPlayerHealth(player) + amount);
    API.sendChatMessageToPlayer(player, "Health increased by: " + amount);
}

References