[bot] Implement n_IsPlayerConnected(...)

This commit is contained in:
RD42 2024-06-01 18:40:37 +08:00
parent 0e726e656e
commit e4770acd44
3 changed files with 10 additions and 2 deletions

View File

@ -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);

View File

@ -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];
};
};

View File

@ -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;
}
//----------------------------------------------------------------------------------