Skip to content

function createNpc

Note

By default npcs won't be added to world. In order to do that, you have to call spawnPlayer.

Note

Remote NPC id will always begins from max slots value.

This function creates remote NPC.
Original: createNpc

Declaration

async def createNpc(name : str, instance : str = 'PC_HERO') -> int

Parameters

str name: the displayed name of the npc.
str instance: the instance name of for the npc.

Source code in src/pyg2o/functions/npc.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
async def createNpc(name : str, instance : str = 'PC_HERO') -> int:
    """
    !!! note
        By default npcs won't be added to world. In order to do that, you have to call [spawnPlayer](../player/spawnPlayer.md).
    !!! note
        Remote NPC id will always begins from max slots value.
    This function creates remote NPC.
    Original: [createNpc](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-functions/npc/createNpc/)

    ## Declaration
    ```python
    async def createNpc(name : str, instance : str = 'PC_HERO') -> int
    ```
    ## Parameters
    `str` **name**: the displayed name of the npc.
    `str` **instance**: the instance name of for the npc.
    """
    data = f'return {get_call_repr()}'

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