From c972dd0ade0736a4ca7ac762dc6099d806ac92d8 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Wed, 18 Sep 2024 23:40:57 +0800 Subject: [PATCH] [server] Implement/match `n_GetPlayerSurfingVehicleID(...)` --- server/player.h | 8 +++++++- server/scrcustom.cpp | 13 +++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/server/player.h b/server/player.h index 5882bab..007e8d7 100644 --- a/server/player.h +++ b/server/player.h @@ -28,7 +28,12 @@ typedef struct _PLAYER_SPAWN_INFO #pragma pack(1) typedef struct _ONFOOT_SYNC_DATA { - char _pad0[68]; + char _pad0[62]; + + WORD wSurfInfo; + + char _pad40[4]; + // TODO: _ONFOOT_SYNC_DATA } ONFOOT_SYNC_DATA; @@ -210,6 +215,7 @@ public: int field_2CDA; + ONFOOT_SYNC_DATA* GetOnFootSyncData() { return &m_ofSync; } BYTE GetState() { return m_byteState; }; diff --git a/server/scrcustom.cpp b/server/scrcustom.cpp index 8e9f93d..8f1ae79 100644 --- a/server/scrcustom.cpp +++ b/server/scrcustom.cpp @@ -955,8 +955,17 @@ static cell AMX_NATIVE_CALL n_GetPlayerVehicleSeat(AMX *amx, cell *params) static cell AMX_NATIVE_CALL n_GetPlayerSurfingVehicleID(AMX *amx, cell *params) { - // TODO: GetPlayerSurfingVehicleID - return 0; + CPlayerPool *pPlayerPool = pNetGame->GetPlayerPool(); + if(!pPlayerPool) return 0xFFFF; + + CPlayer *pPlayer = pPlayerPool->GetAt((PLAYERID)params[1]); + if(pPlayer && pPlayer->GetState() == PLAYER_STATE_ONFOOT) { + WORD wSurfInfo = pPlayer->GetOnFootSyncData()->wSurfInfo; + if(wSurfInfo != 0 && wSurfInfo < 2000) { + return wSurfInfo; + } + } + return 0xFFFF; } static cell AMX_NATIVE_CALL n_GetPlayerSurfingObjectID(AMX *amx, cell *params)