Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SDK
18 changes: 18 additions & 0 deletions Server/Components/NPCs/NPC/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions Server/Components/NPCs/NPC/npc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions Server/Components/Pawn/Scripting/NPC/Natives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down