From 8a4b1ed7a07d402e85ffdd40eea0c2c6c9fc7290 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Sun, 7 Jul 2024 22:37:45 +0800 Subject: [PATCH] [bot] Implement/match `n_SetMyPos(...)` * Implement/match `CNetGame::SetMyPos(...)` --- bot/net/netgame.cpp | 18 ++++++++++++++++++ bot/net/netgame.h | 1 + bot/scrcustom.cpp | 9 +++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/bot/net/netgame.cpp b/bot/net/netgame.cpp index 577f3f3..2ef4476 100644 --- a/bot/net/netgame.cpp +++ b/bot/net/netgame.cpp @@ -237,6 +237,24 @@ BOOL CNetGame::IsVehicleAdded(VEHICLEID VehicleID) return bVehicleSlotState[VehicleID] != FALSE; } +//---------------------------------------------------- +//---------------------------------------------------- +void CNetGame::SetMyPos(PVECTOR Vector) +{ + if(byteState == PLAYER_STATE_ONFOOT) + { + ofSync.vecPos.X = Vector->X; + ofSync.vecPos.Y = Vector->Y; + ofSync.vecPos.Z = Vector->Z; + } + else if (byteState == PLAYER_STATE_DRIVER) + { + icSync.vecPos.X = Vector->X; + icSync.vecPos.Y = Vector->Y; + icSync.vecPos.Z = Vector->Z; + } +} + //---------------------------------------------------- float CNetGame::GetMyZAngle() { diff --git a/bot/net/netgame.h b/bot/net/netgame.h index c6d100c..6543da7 100644 --- a/bot/net/netgame.h +++ b/bot/net/netgame.h @@ -115,6 +115,7 @@ public: BYTE GetPlayerArmour(PLAYERID playerId); BOOL GetPlayerKeys(PLAYERID playerId, WORD *udAnalog, WORD *lrAnalog, WORD *wKeys); BOOL IsVehicleAdded(VEHICLEID VehicleID); + void SetMyPos(PVECTOR Vector); float GetMyZAngle(); void StopRecordingPlayback(); diff --git a/bot/scrcustom.cpp b/bot/scrcustom.cpp index 1386c03..faffe2d 100644 --- a/bot/scrcustom.cpp +++ b/bot/scrcustom.cpp @@ -259,8 +259,13 @@ static cell AMX_NATIVE_CALL n_GetMyPos(AMX *amx, cell *params) // native SetMyPos(Float:x, Float:y, Float:z) static cell AMX_NATIVE_CALL n_SetMyPos(AMX *amx, cell *params) { - // TODO: n_SetMyPos - return 0; + if(!pNetGame->GetPlayerPool()) return 0; + VECTOR vecPos; + vecPos.X = amx_ctof(params[1]); + vecPos.Y = amx_ctof(params[2]); + vecPos.Z = amx_ctof(params[3]); + pNetGame->SetMyPos(&vecPos); + return 1; } // native GetMyFacingAngle(&Float:ang)