Skip to content

function getPlayerPing

Note

The function can return -1 if player isn't connected.

This function will get the player ping. Ping gets updated after each 2500 miliseconds.
Original: getPlayerPing

Declaration

async def getPlayerPing(id : int) -> int

Parameters

int id: the player id.

Returns

str: the current player ping.

Source code in src/pyg2o/functions/player.py
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
async def getPlayerPing(id : int) -> int:
    """
    !!! note
        The function can return `-1` if player isn't connected.
    This function will get the player ping. Ping gets updated after each 2500 miliseconds.
    Original: [getPlayerPing](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-functions/player/getPlayerPing/)

    ## Declaration
    ```python
    async def getPlayerPing(id : int) -> int
    ```
    ## Parameters
    `int` **id**: the player id.
    ## Returns
    `str`: the current player ping.
    """
    data = f'return {get_call_repr()}'

    server = await PythonWebsocketServer.get_server()
    result = await server.make_request(data)
    return result