From 148efc2fa6bae65772db2cc98b91b3ca10dabc21 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Sat, 6 Jul 2024 22:45:04 +0800 Subject: [PATCH] [bot] Implement/match `n_GetPlayerKeys(...)` * Implement/match `CNetGame::GetPlayerKeys(...)` --- bot/net/netgame.cpp | 32 ++++++++++++++++++++++++++++++++ bot/net/netgame.h | 1 + bot/scrcustom.cpp | 16 +++++++++++++++- 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/bot/net/netgame.cpp b/bot/net/netgame.cpp index b02a688..4d55530 100644 --- a/bot/net/netgame.cpp +++ b/bot/net/netgame.cpp @@ -188,6 +188,38 @@ BYTE CNetGame::GetPlayerArmour(PLAYERID playerId) } } +BOOL CNetGame::GetPlayerKeys(PLAYERID playerId, WORD *udAnalog, WORD *lrAnalog, WORD *wKeys) +{ + if(playerId >= MAX_PLAYERS) return FALSE; + if(bPlayerSlotState[playerId] == FALSE) return FALSE; + + if(bytePlayerState[playerId] == PLAYER_STATE_ONFOOT) + { + *udAnalog = unnamed_3[playerId].udAnalog; + *lrAnalog = unnamed_3[playerId].lrAnalog; + *wKeys = unnamed_3[playerId].wKeys; + return TRUE; + } + else if(bytePlayerState[playerId] == PLAYER_STATE_DRIVER) + { + *udAnalog = unnamed_4[playerId].udAnalog; + *lrAnalog = unnamed_4[playerId].lrAnalog; + *wKeys = unnamed_4[playerId].wKeys; + return TRUE; + } + else if(bytePlayerState[playerId] == PLAYER_STATE_PASSENGER) + { + *udAnalog = unnamed_5[playerId].udAnalog; + *lrAnalog = unnamed_5[playerId].lrAnalog; + *wKeys = unnamed_5[playerId].wKeys; + return TRUE; + } + else + { + return FALSE; + } +} + //---------------------------------------------------- // MATCH BOOL CNetGame::IsPlayerAdded(PLAYERID playerId) diff --git a/bot/net/netgame.h b/bot/net/netgame.h index cc39c6a..e33ec40 100644 --- a/bot/net/netgame.h +++ b/bot/net/netgame.h @@ -113,6 +113,7 @@ public: BYTE GetPlayerArmedWeapon(PLAYERID playerId); BYTE GetPlayerHealth(PLAYERID playerId); BYTE GetPlayerArmour(PLAYERID playerId); + BOOL GetPlayerKeys(PLAYERID playerId, WORD *udAnalog, WORD *lrAnalog, WORD *wKeys); BOOL IsVehicleAdded(VEHICLEID VehicleID); void StopRecordingPlayback(); diff --git a/bot/scrcustom.cpp b/bot/scrcustom.cpp index 409052a..e700dcf 100644 --- a/bot/scrcustom.cpp +++ b/bot/scrcustom.cpp @@ -231,7 +231,21 @@ static cell AMX_NATIVE_CALL n_IsVehicleStreamedIn(AMX *amx, cell *params) // native GetPlayerKeys(playerid, &keys, &updown, &leftright) static cell AMX_NATIVE_CALL n_GetPlayerKeys(AMX *amx, cell *params) { - // TODO: n_GetPlayerKeys + CPlayerPool *pPlayerPool = pNetGame->GetPlayerPool(); + WORD wKeys=0, udAnalog=0, lrAnalog=0; + + if(pPlayerPool->GetSlotState((PLAYERID)params[1]) && + pNetGame->GetPlayerKeys((PLAYERID)params[1], &udAnalog, &lrAnalog, &wKeys)) + { + cell* cptr; + amx_GetAddr(amx, params[2], &cptr); + *cptr = (cell)wKeys; + amx_GetAddr(amx, params[3], &cptr); + *cptr = (short)udAnalog; + amx_GetAddr(amx, params[4], &cptr); + *cptr = (short)lrAnalog; + return 1; + } return 0; }