From f7ff8d45df836c91ebe2f2d37711fa45c6fc95cb Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Sun, 5 May 2024 18:52:08 +0800 Subject: [PATCH] [saco] Implement and match `CPlayerPed::GetCurrentWeapon()` --- saco/game/playerped.cpp | 13 +++++++++++++ saco/game/playerped.h | 2 ++ saco/game/scripting.h | 1 + 3 files changed, 16 insertions(+) diff --git a/saco/game/playerped.cpp b/saco/game/playerped.cpp index e6faf2c..88b6447 100644 --- a/saco/game/playerped.cpp +++ b/saco/game/playerped.cpp @@ -123,6 +123,19 @@ void CPlayerPed::SetCurrentAim(CAMERA_AIM *pAim) GameStoreRemotePlayerAim(m_bytePlayerNumber, pAim); } +//----------------------------------------------------------- + +BYTE CPlayerPed::GetCurrentWeapon() +{ + if(!m_pPed) return 0; + if(GamePool_Ped_GetAt(m_dwGTAId) == 0) return 0; + + DWORD dwRetVal; + ScriptCommand(&get_actor_armed_weapon,m_dwGTAId,&dwRetVal); + return (BYTE)dwRetVal; +} + +//----------------------------------------------------------- void CPlayerPed::GiveWeapon(int iWeaponID, int iAmmo) { if(!m_pPed) return; diff --git a/saco/game/playerped.h b/saco/game/playerped.h index 4480ba9..849dd0d 100644 --- a/saco/game/playerped.h +++ b/saco/game/playerped.h @@ -24,6 +24,8 @@ public: CAMERA_AIM * GetCurrentAim(); void SetCurrentAim(CAMERA_AIM *pAim); + BYTE GetCurrentWeapon(); + WORD GetAmmo(); void GiveWeapon(int iWeaponID, int iAmmo); diff --git a/saco/game/scripting.h b/saco/game/scripting.h index 8608bc2..56870cf 100644 --- a/saco/game/scripting.h +++ b/saco/game/scripting.h @@ -42,6 +42,7 @@ const SCRIPT_COMMAND add_to_player_money = { 0x0109, "ii" }; // PLAYER_CHAR, const SCRIPT_COMMAND destroy_racing_checkpoint = { 0x06d6, "i" }; const SCRIPT_COMMAND set_actor_armed_weapon = { 0x01b9, "ii" }; +const SCRIPT_COMMAND get_actor_armed_weapon = { 0x0470, "iv" }; const SCRIPT_COMMAND set_actor_can_be_decapitated = { 0x0446, "ii" };