From 7b974d6b4cfdbe352d0254efa6e7920dc4b05381 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Wed, 3 Jul 2024 23:24:36 +0800 Subject: [PATCH] [bot] Implement/match `n_GetPlayerArmour(...)` * Implement/match `CNetGame::GetPlayerArmour()` --- bot/net/netgame.cpp | 23 +++++++++++++++++++++++ bot/net/netgame.h | 1 + bot/scrcustom.cpp | 5 ++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/bot/net/netgame.cpp b/bot/net/netgame.cpp index 82530b2..d70ad27 100644 --- a/bot/net/netgame.cpp +++ b/bot/net/netgame.cpp @@ -165,6 +165,29 @@ BYTE CNetGame::GetPlayerHealth(PLAYERID playerId) } } +BYTE CNetGame::GetPlayerArmour(PLAYERID playerId) +{ + if(playerId >= MAX_PLAYERS) return 0; + if(bPlayerSlotState[playerId] == FALSE) return 0; + + if(bytePlayerState[playerId] == PLAYER_STATE_ONFOOT) + { + return unnamed_3[playerId].byteArmour; + } + else if(bytePlayerState[playerId] == PLAYER_STATE_DRIVER) + { + return unnamed_4[playerId].bytePlayerArmour; + } + else if(bytePlayerState[playerId] == PLAYER_STATE_PASSENGER) + { + return unnamed_5[playerId].bytePlayerArmour; + } + else + { + return 0; + } +} + //---------------------------------------------------- // MATCH BOOL CNetGame::IsPlayerAdded(PLAYERID playerId) diff --git a/bot/net/netgame.h b/bot/net/netgame.h index b058d94..016bf90 100644 --- a/bot/net/netgame.h +++ b/bot/net/netgame.h @@ -112,6 +112,7 @@ public: VEHICLEID GetPlayerVehicleID(PLAYERID playerId); BYTE GetPlayerArmedWeapon(PLAYERID playerId); BYTE GetPlayerHealth(PLAYERID playerId); + BYTE GetPlayerArmour(PLAYERID playerId); void StopRecordingPlayback(); void PauseRecordingPlayback(); diff --git a/bot/scrcustom.cpp b/bot/scrcustom.cpp index e9b61c2..e9e9515 100644 --- a/bot/scrcustom.cpp +++ b/bot/scrcustom.cpp @@ -196,7 +196,10 @@ static cell AMX_NATIVE_CALL n_GetPlayerHealth(AMX *amx, cell *params) // native GetPlayerArmour(playerid) static cell AMX_NATIVE_CALL n_GetPlayerArmour(AMX *amx, cell *params) { - // TODO: n_GetPlayerArmour + if(pNetGame->GetPlayerPool()->GetSlotState((PLAYERID)params[1])) + { + return (cell)pNetGame->GetPlayerArmour((PLAYERID)params[1]); + } return 0; }