From 6de6425aebf7e5287d1109f280d4b1fb54f00fde Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Mon, 1 Jul 2024 23:03:22 +0800 Subject: [PATCH] [bot] Implement/match `n_GetPlayerArmedWeapon(...)` * Implement/match `CNetGame::GetPlayerArmedWeapon(...)` --- bot/net/netgame.cpp | 23 +++++++++++++++++++++++ bot/net/netgame.h | 2 ++ bot/scrcustom.cpp | 5 ++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/bot/net/netgame.cpp b/bot/net/netgame.cpp index 96438ee..663b3c4 100644 --- a/bot/net/netgame.cpp +++ b/bot/net/netgame.cpp @@ -119,6 +119,29 @@ VEHICLEID CNetGame::GetPlayerVehicleID(PLAYERID playerId) } } +BYTE CNetGame::GetPlayerArmedWeapon(PLAYERID playerId) +{ + if(playerId >= MAX_PLAYERS) return 0; + if(bPlayerSlotState[playerId] == FALSE) return 0; + + if(bytePlayerState[playerId] == PLAYER_STATE_ONFOOT) + { + return unnamed_3[playerId].byteCurrentWeapon; + } + else if(bytePlayerState[playerId] == PLAYER_STATE_DRIVER) + { + return unnamed_4[playerId].byteCurrentWeapon; + } + else if(bytePlayerState[playerId] == PLAYER_STATE_PASSENGER) + { + return unnamed_5[playerId].byteCurrentWeapon; + } + else + { + return 0; + } +} + //---------------------------------------------------- // MATCH BOOL CNetGame::IsPlayerAdded(PLAYERID playerId) diff --git a/bot/net/netgame.h b/bot/net/netgame.h index 28ed34d..cfd833f 100644 --- a/bot/net/netgame.h +++ b/bot/net/netgame.h @@ -110,6 +110,8 @@ public: BYTE GetPlayerState(PLAYERID playerId); BOOL GetPlayerPos(PLAYERID playerId, PVECTOR Vector); VEHICLEID GetPlayerVehicleID(PLAYERID playerId); + BYTE GetPlayerArmedWeapon(PLAYERID playerId); + void StopRecordingPlayback(); void PauseRecordingPlayback(); void ResumeRecordingPlayback(); diff --git a/bot/scrcustom.cpp b/bot/scrcustom.cpp index f180240..53427a0 100644 --- a/bot/scrcustom.cpp +++ b/bot/scrcustom.cpp @@ -176,7 +176,10 @@ static cell AMX_NATIVE_CALL n_GetPlayerVehicleID(AMX *amx, cell *params) // native GetPlayerArmedWeapon(playerid) static cell AMX_NATIVE_CALL n_GetPlayerArmedWeapon(AMX *amx, cell *params) { - // TODO: n_GetPlayerArmedWeapon + if(pNetGame->GetPlayerPool()->GetSlotState((PLAYERID)params[1])) + { + return (cell)pNetGame->GetPlayerArmedWeapon((PLAYERID)params[1]); + } return 0; }