Skip to content

function isPlayerConnected

The function is used to check whether player is connected to the server.
Original: isPlayerConnected

Declaration

async def isPlayerConnected(id : int) -> bool

Parameters

int id: the player id.

Returns

bool: true when player is connected, otherwise false.

Source code in src/pyg2o/functions/player.py
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
async def isPlayerConnected(id : int) -> bool:
    """
    The function is used to check whether player is connected to the server.
    Original: [isPlayerConnected](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-functions/player/isPlayerConnected/)

    ## Declaration
    ```python
    async def isPlayerConnected(id : int) -> bool
    ```
    ## Parameters
    `int` **id**: the player id.
    ## Returns
    `bool`: `true` when player is connected, otherwise `false`.
    """
    data = f'return {get_call_repr()}'

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