From fdd891098ba7e051efb0f9694dc73a6b97780c2a Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Sat, 27 Apr 2024 18:17:22 +0800 Subject: [PATCH] [server] Implement and match `n_IsPlayerNPC(...)` --- server/playerpool.h | 2 ++ server/scrcustom.cpp | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/server/playerpool.h b/server/playerpool.h index 5b368b2..c4042a6 100644 --- a/server/playerpool.h +++ b/server/playerpool.h @@ -62,6 +62,8 @@ public: BOOL IsAdmin(PLAYERID playerId) { return m_bIsAnAdmin[playerId]; }; + BOOL IsNPC(PLAYERID playerId) { return m_bIsAnNPC[playerId]; }; + }; #endif diff --git a/server/scrcustom.cpp b/server/scrcustom.cpp index 94e62d2..de08bdf 100644 --- a/server/scrcustom.cpp +++ b/server/scrcustom.cpp @@ -397,10 +397,24 @@ static cell AMX_NATIVE_CALL n_ConnectNPC(AMX *amx, cell *params) return 0; } +// native IsPlayerNPC(playerid) static cell AMX_NATIVE_CALL n_IsPlayerNPC(AMX *amx, cell *params) { - // TODO: IsPlayerNPC - return 0; + BOOL bResult = FALSE; + + if(pNetGame) + { + CPlayerPool* pPlayerPool = pNetGame->GetPlayerPool(); + + if(pPlayerPool && pPlayerPool->GetSlotState((PLAYERID)params[1])) + { + if(pPlayerPool->IsNPC((PLAYERID)params[1])) + { + bResult = TRUE; + } + } + } + return bResult; } static cell AMX_NATIVE_CALL n_Create3DTextLabel(AMX *amx, cell *params)