From b6b7bd1f24097f2c8f3fc40ba4801b49f4c90645 Mon Sep 17 00:00:00 2001 From: Revelts Date: Sun, 28 Jun 2026 19:26:51 +0700 Subject: [PATCH] add NPC_GetVehiclePos and NPC_GetVehicleRot natives Implements the INPC vehicle position/rotation getters added in SDK PR openmultiplayer/open.mp-sdk#71 and exposes them to PAWN as NPC_GetVehiclePos and NPC_GetVehicleRot, mirroring the existing NPC_SetVehiclePos / NPC_SetVehicleRot setters. Both getters return zero/identity when the NPC is not currently in a vehicle, matching the silent no-op semantics of the setters. Closes #1197. --- SDK | 2 +- Server/Components/NPCs/NPC/npc.cpp | 18 ++++++++++++++++++ Server/Components/NPCs/NPC/npc.hpp | 4 ++++ .../Components/Pawn/Scripting/NPC/Natives.cpp | 12 ++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/SDK b/SDK index 3ee7bc4ab..324eb8083 160000 --- a/SDK +++ b/SDK @@ -1 +1 @@ -Subproject commit 3ee7bc4ab20c22359c34c08c38f93815b44bffd5 +Subproject commit 324eb8083f8e32d973353d41288679e52544e22f diff --git a/Server/Components/NPCs/NPC/npc.cpp b/Server/Components/NPCs/NPC/npc.cpp index 0aab1c4ad..77397fe20 100644 --- a/Server/Components/NPCs/NPC/npc.cpp +++ b/Server/Components/NPCs/NPC/npc.cpp @@ -280,6 +280,24 @@ void NPC::setVehicleRotation(const GTAQuat& rotation, bool immediateUpdate) } } +Vector3 NPC::getVehiclePosition() const +{ + if (vehicle_ && vehicleSeat_ != SEAT_NONE) + { + return position_; + } + return Vector3(0.0f, 0.0f, 0.0f); +} + +GTAQuat NPC::getVehicleRotation() const +{ + if (vehicle_ && vehicleSeat_ != SEAT_NONE) + { + return rotation_; + } + return GTAQuat(); +} + int NPC::getVirtualWorld() const { return player_->getVirtualWorld(); diff --git a/Server/Components/NPCs/NPC/npc.hpp b/Server/Components/NPCs/NPC/npc.hpp index e29345b6c..83261c3ae 100644 --- a/Server/Components/NPCs/NPC/npc.hpp +++ b/Server/Components/NPCs/NPC/npc.hpp @@ -262,6 +262,10 @@ class NPC : public INPC, public PoolIDProvider, public NoCopy void setVehicleRotation(const GTAQuat& rotation, bool immediateUpdate) override; + Vector3 getVehiclePosition() const override; + + GTAQuat getVehicleRotation() const override; + void setPositionHandled(const Vector3& position, bool immediateUpdate) { if (vehicle_ && vehicleSeat_ != SEAT_NONE) diff --git a/Server/Components/Pawn/Scripting/NPC/Natives.cpp b/Server/Components/Pawn/Scripting/NPC/Natives.cpp index a148d96ff..a4f67654d 100644 --- a/Server/Components/Pawn/Scripting/NPC/Natives.cpp +++ b/Server/Components/Pawn/Scripting/NPC/Natives.cpp @@ -80,6 +80,12 @@ SCRIPT_API(NPC_SetVehiclePos, bool(INPC& npc, Vector3 position)) return true; } +SCRIPT_API(NPC_GetVehiclePos, bool(INPC& npc, Vector3& position)) +{ + position = npc.getVehiclePosition(); + return true; +} + SCRIPT_API(NPC_GetPos, bool(INPC& npc, Vector3& position)) { position = npc.getPosition(); @@ -98,6 +104,12 @@ SCRIPT_API(NPC_SetVehicleRot, bool(INPC& npc, Vector3 rotation)) return true; } +SCRIPT_API(NPC_GetVehicleRot, bool(INPC& npc, Vector3& rotation)) +{ + rotation = npc.getVehicleRotation().ToEuler(); + return true; +} + SCRIPT_API(NPC_GetRot, bool(INPC& npc, Vector3& rotation)) { rotation = npc.getRotation().ToEuler();