diff --git a/bot/net/netgame.h b/bot/net/netgame.h index 0a6fadc..671a154 100644 --- a/bot/net/netgame.h +++ b/bot/net/netgame.h @@ -70,6 +70,7 @@ public: int GetGameState() { return m_iGameState; }; + CPlayerPool * GetPlayerPool() { return m_pPlayerPool; }; RakClientInterface * GetRakClient() { return m_pRakClient; }; void Init(PCHAR szHostOrIp,int iPort,PCHAR szPlayerName,PCHAR szPass,PCHAR szNpcMode); diff --git a/bot/net/playerpool.h b/bot/net/playerpool.h index ff0a5c5..3b16a89 100644 --- a/bot/net/playerpool.h +++ b/bot/net/playerpool.h @@ -25,4 +25,10 @@ public: BOOL Delete(PLAYERID playerId, BYTE byteReason); + // Find out if the slot is inuse. + BOOL GetSlotState(PLAYERID playerId) { + if(playerId >= MAX_PLAYERS) { return FALSE; } + return m_bPlayerSlotState[playerId]; + }; + }; \ No newline at end of file diff --git a/bot/scrcustom.cpp b/bot/scrcustom.cpp index febe3db..671bb09 100644 --- a/bot/scrcustom.cpp +++ b/bot/scrcustom.cpp @@ -248,8 +248,9 @@ static cell AMX_NATIVE_CALL n_GetPlayerName(AMX *amx, cell *params) // native IsPlayerConnected(playerid) static cell AMX_NATIVE_CALL n_IsPlayerConnected(AMX *amx, cell *params) { - // TODO: n_IsPlayerConnected - return 0; + PLAYERID playerId = (PLAYERID)params[1]; + if (playerId >= MAX_PLAYERS || pNetGame->GetPlayerPool()->GetSlotState(playerId)) return 0; + return 1; } //----------------------------------------------------------------------------------