diff --git a/include/events.nut b/include/events.nut index fe6f838..f7196d4 100644 --- a/include/events.nut +++ b/include/events.nut @@ -594,4 +594,16 @@ addEventHandler("onPlayerUnspawnForPlayer", function(playerid, spawnid) if (_globalInstance != -1) _globalInstance._send("event", data); -}); \ No newline at end of file +}); + +addEventHandler("onPlayerChangeChunk", function(playerid, chunk_index) +{ + local data = { + event = "onPlayerChangeChunk", + playerid = playerid, + chunk_index = chunk_index + } + + if (_globalInstance != -1) + _globalInstance._send("event", data); +}); diff --git a/include/main.nut b/include/main.nut index 1f7055c..e1d3a9c 100644 --- a/include/main.nut +++ b/include/main.nut @@ -90,6 +90,8 @@ class PyG2O return "ItemGround"; else if (object instanceof Vec3) return "Vec3"; + else if (object instanceof Vec2i) + return "Vec2i"; return null; } @@ -152,4 +154,4 @@ class PyG2O _callMessage(request["type"], request); } -} \ No newline at end of file +} diff --git a/include/messages.nut b/include/messages.nut index b14417c..2ba6a42 100644 --- a/include/messages.nut +++ b/include/messages.nut @@ -11,6 +11,12 @@ function _message_call(data) data["data"]["y"] <- result.y; data["data"]["z"] <- result.z; } + else if (className == "Vec2i") + { + data["data"] = {}; + data["data"]["x"] <- result.x; + data["data"]["y"] <- result.y; + } else if (className != null) { data["data"] = {}; @@ -21,4 +27,4 @@ function _message_call(data) data["data"] = result; _send("result", data["data"], data["uuid"]); -} \ No newline at end of file +} diff --git a/pyproject.toml b/pyproject.toml index 50e4cf4..16a9eee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "PyG2O" -version = "2.3.2" +version = "2.3.3" description = "" readme = "README.md" requires-python = ">=3.13" diff --git a/src/pyg2o/functions/game.py b/src/pyg2o/functions/game.py index 773712b..20811cc 100644 --- a/src/pyg2o/functions/game.py +++ b/src/pyg2o/functions/game.py @@ -28,6 +28,13 @@ async def getHostname() -> str: server = await PythonWebsocketServer.get_server() result = await server.make_request(data) return result + +async def getOnlinePlayers(): + data = f'return {get_call_repr()}' + + server = await PythonWebsocketServer.get_server() + result = await server.make_request(data) + return result async def getMaxSlots() -> int: """ diff --git a/src/pyg2o/functions/player.py b/src/pyg2o/functions/player.py index 52f24bf..082bb31 100644 --- a/src/pyg2o/functions/player.py +++ b/src/pyg2o/functions/player.py @@ -272,6 +272,13 @@ async def getPlayerCameraPosition(id : int) -> Optional[tuple]: result = await server.make_request(data) return (result['x'], result['y'], result['z']) if result is not None else (None, None, None) +async def getPlayerChunk(id: int): + data = f'return {get_call_repr()}' + + server = await PythonWebsocketServer.get_server() + result = await server.make_request(data) + return (result['x'], result['y']) if result is not None else (None, None) + async def getPlayerCollision(id : int) -> bool: """ This function will get the player collision. diff --git a/src/pyg2o/functions/waypoint.py b/src/pyg2o/functions/waypoint.py index 6c8297b..30f8835 100644 --- a/src/pyg2o/functions/waypoint.py +++ b/src/pyg2o/functions/waypoint.py @@ -2,7 +2,7 @@ from ..server import PythonWebsocketServer from ..call_repr import get_call_repr from typing import Optional -async def getNearestWaypoint(world : str, x : int, y : int, z : int) -> Optional[tuple]: +async def getNearestWaypoint(world : str, x : int, y : int, z : int, distance: int = -1) -> Optional[tuple]: """ This function is used to retrieve the information about nearest waypoint from the specified position. Original: [getNearestWaypoint](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-functions/waypoint/getNearestWaypoint/) @@ -44,4 +44,4 @@ async def getWaypoint(world : str, name : str) -> Optional[tuple]: server = await PythonWebsocketServer.get_server() result = await server.make_request(data) - return (result['x'], result['y'], result['z']) if result is not None else (None, None, None) \ No newline at end of file + return (result['x'], result['y'], result['z']) if result is not None else (None, None, None)