diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp index beb2d952..44b934e4 100644 --- a/core/PlayerManager.cpp +++ b/core/PlayerManager.cpp @@ -1619,8 +1619,22 @@ void CPlayer::Kick(const char *str) { MarkAsBeingKicked(); INetChannel *pNetChan = static_cast(engine->GetPlayerNetInfo(m_iIndex)); - IClient *pClient = static_cast(pNetChan->GetMsgHandler()); - pClient->Disconnect("%s", str); + if (pNetChan == NULL) + { + /* What does this even mean? Hell if I know. */ + int userid = GetUserId(); + if (userid > 0) + { + char buffer[255]; + UTIL_Format(buffer, sizeof(buffer), "kickid %d %s\n", userid, str); + engine->ServerCommand(buffer); + } + } + else + { + IClient *pClient = static_cast(pNetChan->GetMsgHandler()); + pClient->Disconnect("%s", str); + } } void CPlayer::Authorize_Post() diff --git a/core/smn_console.cpp b/core/smn_console.cpp index a12f5b81..307feb6a 100644 --- a/core/smn_console.cpp +++ b/core/smn_console.cpp @@ -200,8 +200,8 @@ static void ReplicateConVar(ConVar *pConVar) if (pPlayer && pPlayer->IsInGame() && !pPlayer->IsFakeClient()) { - INetChannel *netchan = static_cast(engine->GetPlayerNetInfo(i)); - netchan->SendData(buffer); + if (INetChannel *netchan = static_cast(engine->GetPlayerNetInfo(i))) + netchan->SendData(buffer); } } } @@ -1319,6 +1319,11 @@ static cell_t SendConVarValue(IPluginContext *pContext, const cell_t *params) } INetChannel *netchan = static_cast(engine->GetPlayerNetInfo(params[1])); + if (netchan == NULL) + { + return 0; + } + netchan->SendData(buffer); return 1; diff --git a/core/smn_player.cpp b/core/smn_player.cpp index 3303ab82..5fe397fb 100644 --- a/core/smn_player.cpp +++ b/core/smn_player.cpp @@ -720,6 +720,10 @@ static cell_t GetTimeConnected(IPluginContext *pContext, const cell_t *params) } INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client); + if (pInfo == NULL) + { + return 0; + } return sp_ftoc(pInfo->GetTimeConnected()); } @@ -739,6 +743,10 @@ static cell_t GetDataRate(IPluginContext *pContext, const cell_t *params) } INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client); + if (pInfo == NULL) + { + return 0; + } return pInfo->GetDataRate(); } @@ -758,6 +766,10 @@ static cell_t IsTimingOut(IPluginContext *pContext, const cell_t *params) } INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client); + if (pInfo == NULL) + { + return 1; + } return pInfo->IsTimingOut() ? 1 : 0; } @@ -782,6 +794,10 @@ static cell_t GetLatency(IPluginContext *pContext, const cell_t *params) } INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client); + if (pInfo == NULL) + { + return sp_ftoc(-1); + } if (params[2] == MAX_FLOWS) { @@ -815,6 +831,10 @@ static cell_t GetAvgLatency(IPluginContext *pContext, const cell_t *params) } INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client); + if (pInfo == NULL) + { + return sp_ftoc(-1); + } if (params[2] == MAX_FLOWS) { @@ -848,6 +868,10 @@ static cell_t GetAvgLoss(IPluginContext *pContext, const cell_t *params) } INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client); + if (pInfo == NULL) + { + return sp_ftoc(-1); + } if (params[2] == MAX_FLOWS) { @@ -881,6 +905,10 @@ static cell_t GetAvgChoke(IPluginContext *pContext, const cell_t *params) } INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client); + if (pInfo == NULL) + { + return sp_ftoc(-1); + } if (params[2] == MAX_FLOWS) { @@ -914,6 +942,10 @@ static cell_t GetAvgData(IPluginContext *pContext, const cell_t *params) } INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client); + if (pInfo == NULL) + { + return 0; + } if (params[2] == MAX_FLOWS) { @@ -948,6 +980,11 @@ static cell_t GetAvgPackets(IPluginContext *pContext, const cell_t *params) INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client); + if (pInfo == NULL) + { + return 0; + } + if (params[2] == MAX_FLOWS) { value = pInfo->GetAvgPackets(FLOW_INCOMING) + pInfo->GetAvgPackets(FLOW_OUTGOING); diff --git a/plugins/include/clients.inc b/plugins/include/clients.inc index 7046951b..ceee8423 100644 --- a/plugins/include/clients.inc +++ b/plugins/include/clients.inc @@ -601,7 +601,7 @@ native Float:GetClientTime(client); * * @param client Player's index. * @param flow Traffic flowing direction. - * @return Latency. + * @return Latency, or -1 if network info is not available. * @error Invalid client index, client not in game, or fake client. */ native Float:GetClientLatency(client, NetFlow:flow); @@ -611,7 +611,7 @@ native Float:GetClientLatency(client, NetFlow:flow); * * @param client Player's index. * @param flow Traffic flowing direction. - * @return Average latency. + * @return Latency, or -1 if network info is not available. * @error Invalid client index, client not in game, or fake client. */ native Float:GetClientAvgLatency(client, NetFlow:flow); @@ -621,7 +621,7 @@ native Float:GetClientAvgLatency(client, NetFlow:flow); * * @param client Player's index. * @param flow Traffic flowing direction. - * @return Average packet loss. + * @return Average packet loss, or -1 if network info is not available. * @error Invalid client index, client not in game, or fake client. */ native Float:GetClientAvgLoss(client, NetFlow:flow); @@ -631,7 +631,7 @@ native Float:GetClientAvgLoss(client, NetFlow:flow); * * @param client Player's index. * @param flow Traffic flowing direction. - * @return Average packet choke. + * @return Average packet loss, or -1 if network info is not available. * @error Invalid client index, client not in game, or fake client. */ native Float:GetClientAvgChoke(client, NetFlow:flow);