GetPlayerPing

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

Gets the current player ping.


Syntax

API.getPlayerPing(Client player);

Required Arguments

  • player: parameter input should be in Client type.

NOTE: This function returns data in int type.

Usage example(s)

The command bellow tells your current ping, if it's under 40, you receive a message saying it's awesome.

In C#
Server-Side Function

[Command("myping")]
public void MyPing(Client player)
{
    if(API.getPlayerPing(player) <= 40)
    {
        API.sendChatMessageToPlayer(player, "Dude, your ping is awesome! (" + API.getPlayerPing(player) + ")");
        return;
    }
    API.sendChatMessageToPlayer(player, "Your ping is (" + API.getPlayerPing(player) + ")");
}


References