GetPlayerPing Shared function

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

This function was added in version: 0.0.4

This function is used to get the current player ping.

Syntax

int getPlayerPing(int id)

Required Arguments

  • id: The ID of player.

Returns

  • The ping of player.

Example

Client

local function onCommandHandler(cmd, params) 
{     
    if(cmd == "ping")     
    {
        local ping = getPlayerPing(heroId); //Get my ping.    
        print("My ping: " + ping);     
    } 
}

addEventHandler("onCommand", onCommandHandler);

Server

local function onPlayerCommandHandler(pid, cmd, params) 
{     
    if(cmd == "ping")     
    {
        local ping = getPlayerPing(pid); //Get my ping.    
        sendMessageToPlayer(pid, 255, 255, 255, "My ping: " + ping);   
    } 
}

addEventHandler("onPlayerCommand", onPlayerCommandHandler);

Related functions

Server

Shared