GetPlayerHealth Shared function

From Gothic 2 Online: Wiki
Jump to navigation Jump to search

This function was added in version: Client: 0.0.4.1, Server: 0.0.0

This function returns player's health.

Syntax

int getPlayerHealth(int id);

Parameters

  • id: The ID of player.

Returns

  • Return player's health.

Example

Client

local function onCommandHandler(cmd, params)
{
    if (cmd == "hp")
    {
        local hp= getPlayerHealth(heroId);
        print("My health: " + hp);
    }
}

addEventHandler("onCommand", onCommandHandler);

Server

local function onPlayerCommandHandler(pid, cmd, params)
{
    if (cmd == "hp")
    {
        local hp= getPlayerHealth(pid);
        sendMessageToPlayer(pid, 255, 255, 255, "My health: " + hp);
    }
}

addEventHandler("onPlayerCommand", onPlayerCommandHandler);

Related functions

Server

Shared