From 71204c1c499c570df7c52a121d8a20f6e25f5b5a Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Fri, 5 Jul 2024 22:43:08 +0800 Subject: [PATCH] [bot] Implement/match `n_IsVehicleStreamedIn(...)` * Rename `field_84D0` to `m_bVehicleSlotState` * Implement/match `CNetGame::IsVehicleAdded(...)` --- bot/net/netgame.cpp | 8 ++++++++ bot/net/netgame.h | 1 + bot/net/vehiclepool.cpp | 2 +- bot/net/vehiclepool.h | 8 +++++++- bot/scrcustom.cpp | 7 +++++-- 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/bot/net/netgame.cpp b/bot/net/netgame.cpp index d70ad27..b02a688 100644 --- a/bot/net/netgame.cpp +++ b/bot/net/netgame.cpp @@ -197,6 +197,14 @@ BOOL CNetGame::IsPlayerAdded(PLAYERID playerId) return bPlayerSlotState[playerId] != FALSE; } +//---------------------------------------------------- +BOOL CNetGame::IsVehicleAdded(VEHICLEID VehicleID) +{ + if(VehicleID >= MAX_VEHICLES) return FALSE; + + return bVehicleSlotState[VehicleID] != FALSE; +} + //---------------------------------------------------- // MATCH void CNetGame::SetMyZAngle(float fAngle) diff --git a/bot/net/netgame.h b/bot/net/netgame.h index 016bf90..cc39c6a 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 IsVehicleAdded(VEHICLEID VehicleID); void StopRecordingPlayback(); void PauseRecordingPlayback(); diff --git a/bot/net/vehiclepool.cpp b/bot/net/vehiclepool.cpp index 51ae763..51ab86e 100644 --- a/bot/net/vehiclepool.cpp +++ b/bot/net/vehiclepool.cpp @@ -8,7 +8,7 @@ CVehiclePool::CVehiclePool() { // loop through and initialize all net players to null and slot states to false for(VEHICLEID VehicleID = 0; VehicleID < MAX_VEHICLES; VehicleID++) { - field_84D0[VehicleID] = 0; + m_bVehicleSlotState[VehicleID] = FALSE; } } diff --git a/bot/net/vehiclepool.h b/bot/net/vehiclepool.h index 7f7a36b..ceac11f 100644 --- a/bot/net/vehiclepool.h +++ b/bot/net/vehiclepool.h @@ -40,7 +40,7 @@ class CVehiclePool // size: 114000 { private: char _gap0[34000]; - int field_84D0[2000]; + BOOL m_bVehicleSlotState[MAX_VEHICLES]; VEHICLE_SPAWN_INFO m_SpawnInfo[MAX_VEHICLES]; public: @@ -51,4 +51,10 @@ public: BOOL New(NEW_VEHICLE *pNewVehicle); BOOL Delete(VEHICLEID VehicleID); + + // Find out if the slot is inuse. + BOOL GetSlotState(VEHICLEID VehicleID) { + if(VehicleID >= MAX_VEHICLES) { return FALSE; } + return m_bVehicleSlotState[VehicleID]; + }; }; diff --git a/bot/scrcustom.cpp b/bot/scrcustom.cpp index e9e9515..409052a 100644 --- a/bot/scrcustom.cpp +++ b/bot/scrcustom.cpp @@ -221,8 +221,11 @@ static cell AMX_NATIVE_CALL n_IsPlayerStreamedIn(AMX *amx, cell *params) // native IsVehicleStreamedIn(vehicleid) static cell AMX_NATIVE_CALL n_IsVehicleStreamedIn(AMX *amx, cell *params) { - // TODO: n_IsVehicleStreamedIn - return 0; + if(pNetGame->GetVehiclePool()->GetSlotState((VEHICLEID)params[1])) + { + return pNetGame->IsVehicleAdded((VEHICLEID)params[1]); + } + return 0; } // native GetPlayerKeys(playerid, &keys, &updown, &leftright)