From ea1a2cb2b38bc816ff10449b34a274008bc9b5a6 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Sun, 28 Apr 2024 22:32:25 +0800 Subject: [PATCH] [server] Implement and match `n_gpci(...)` --- server/playerpool.h | 5 +++++ server/scrcustom.cpp | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/server/playerpool.h b/server/playerpool.h index d083223..a9ec84e 100644 --- a/server/playerpool.h +++ b/server/playerpool.h @@ -54,6 +54,11 @@ public: return m_bPlayerSlotState[playerId]; }; + PCHAR GetPlayerClientID(PLAYERID playerId) { + if(playerId >= MAX_PLAYERS) { return NULL; } + return m_szPlayerClientID[playerId]; + }; + void ResetPlayerScoresAndMoney() { memset(&m_iPlayerScore[0],0,sizeof(int) * MAX_PLAYERS); memset(&m_iPlayerMoney[0],0,sizeof(int) * MAX_PLAYERS); diff --git a/server/scrcustom.cpp b/server/scrcustom.cpp index 0d0b961..111c2b6 100644 --- a/server/scrcustom.cpp +++ b/server/scrcustom.cpp @@ -3,10 +3,17 @@ #define CHECK_PARAMS(n) +int set_amxstring(AMX *amx,cell amx_addr,const char *source,int max); + +//---------------------------------------------------------------------------------- + +// native gpci(playerid, const clientid[], len) static cell AMX_NATIVE_CALL n_gpci(AMX *amx, cell *params) { - // TODO: gpci - return 0; + PLAYERID playerId = (PLAYERID)params[1]; + if (playerId >= MAX_PLAYERS || !pNetGame->GetPlayerPool()->GetSlotState(playerId)) return 0; + return set_amxstring(amx, params[2], pNetGame->GetPlayerPool()-> + GetPlayerClientID(playerId), params[3]); } //----------------------------------------------------------------------------------