From 72a7c19498fca77795d91b6515dc8248899d1492 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Sun, 7 Jul 2024 22:40:49 +0800 Subject: [PATCH] [bot] Implement/match `n_GetMyPos(...)` * Implement/match `CNetGame::GetMyPos(...)` --- bot/net/netgame.cpp | 24 ++++++++++++++++++++++++ bot/net/netgame.h | 1 + bot/scrcustom.cpp | 17 +++++++++++++++-- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/bot/net/netgame.cpp b/bot/net/netgame.cpp index 2ef4476..22ca0c2 100644 --- a/bot/net/netgame.cpp +++ b/bot/net/netgame.cpp @@ -238,6 +238,30 @@ BOOL CNetGame::IsVehicleAdded(VEHICLEID VehicleID) } //---------------------------------------------------- + +//---------------------------------------------------- +PVECTOR CNetGame::GetMyPos(PVECTOR Vector) +{ + if(byteState == PLAYER_STATE_ONFOOT) + { + Vector->X = ofSync.vecPos.X; + Vector->Y = ofSync.vecPos.Y; + Vector->Z = ofSync.vecPos.Z; + return Vector; + } + else if(byteState == PLAYER_STATE_DRIVER) + { + Vector->X = icSync.vecPos.X; + Vector->Y = icSync.vecPos.Y; + Vector->Z = icSync.vecPos.Z; + return Vector; + } + else + { + return NULL; + } +} + //---------------------------------------------------- void CNetGame::SetMyPos(PVECTOR Vector) { diff --git a/bot/net/netgame.h b/bot/net/netgame.h index 6543da7..e2a172b 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); + PVECTOR GetMyPos(PVECTOR Vector); void SetMyPos(PVECTOR Vector); float GetMyZAngle(); diff --git a/bot/scrcustom.cpp b/bot/scrcustom.cpp index faffe2d..01fa993 100644 --- a/bot/scrcustom.cpp +++ b/bot/scrcustom.cpp @@ -249,11 +249,24 @@ static cell AMX_NATIVE_CALL n_GetPlayerKeys(AMX *amx, cell *params) return 0; } + // native GetMyPos(&Float:x, &Float:y, &Float:z) static cell AMX_NATIVE_CALL n_GetMyPos(AMX *amx, cell *params) { - // TODO: n_GetMyPos - return 0; + if(!pNetGame->GetPlayerPool()) return 0; + + VECTOR vecPos; + pNetGame->GetMyPos(&vecPos); + + cell* cptr; + amx_GetAddr(amx, params[1], &cptr); + *cptr = amx_ftoc(vecPos.X); + amx_GetAddr(amx, params[2], &cptr); + *cptr = amx_ftoc(vecPos.Y); + amx_GetAddr(amx, params[3], &cptr); + *cptr = amx_ftoc(vecPos.Z); + + return 1; } // native SetMyPos(Float:x, Float:y, Float:z)