fixed amb1646 - implemented NetFlow_Both functionality
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402149
This commit is contained in:
parent
21359ea17e
commit
3342a84cf4
@ -765,115 +765,199 @@ static cell_t IsTimingOut(IPluginContext *pContext, const cell_t *params)
|
||||
static cell_t GetLatency(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
int client = params[1];
|
||||
float value;
|
||||
|
||||
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
|
||||
if (!pPlayer)
|
||||
{
|
||||
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
||||
} else if (!pPlayer->IsInGame()) {
|
||||
}
|
||||
else if (!pPlayer->IsInGame())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client %d is not in game", client);
|
||||
} else if (pPlayer->IsFakeClient()) {
|
||||
}
|
||||
else if (pPlayer->IsFakeClient())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client %d is a bot", client);
|
||||
}
|
||||
|
||||
INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
|
||||
|
||||
return sp_ftoc(pInfo->GetLatency(params[2]));
|
||||
if (params[2] == MAX_FLOWS)
|
||||
{
|
||||
value = pInfo->GetLatency(FLOW_INCOMING) + pInfo->GetLatency(FLOW_OUTGOING);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = pInfo->GetLatency(params[2]);
|
||||
}
|
||||
|
||||
return sp_ftoc(value);
|
||||
}
|
||||
|
||||
static cell_t GetAvgLatency(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
int client = params[1];
|
||||
float value;
|
||||
|
||||
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
|
||||
if (!pPlayer)
|
||||
{
|
||||
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
||||
} else if (!pPlayer->IsInGame()) {
|
||||
}
|
||||
else if (!pPlayer->IsInGame())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client %d is not in game", client);
|
||||
} else if (pPlayer->IsFakeClient()) {
|
||||
}
|
||||
else if (pPlayer->IsFakeClient())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client %d is a bot", client);
|
||||
}
|
||||
|
||||
INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
|
||||
|
||||
return sp_ftoc(pInfo->GetAvgLatency(params[2]));
|
||||
if (params[2] == MAX_FLOWS)
|
||||
{
|
||||
value = pInfo->GetAvgLatency(FLOW_INCOMING) + pInfo->GetAvgLatency(FLOW_OUTGOING);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = pInfo->GetAvgLatency(params[2]);
|
||||
}
|
||||
|
||||
return sp_ftoc(value);
|
||||
}
|
||||
|
||||
static cell_t GetAvgLoss(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
int client = params[1];
|
||||
float value;
|
||||
|
||||
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
|
||||
if (!pPlayer)
|
||||
{
|
||||
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
||||
} else if (!pPlayer->IsInGame()) {
|
||||
}
|
||||
else if (!pPlayer->IsInGame())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client %d is not in game", client);
|
||||
} else if (pPlayer->IsFakeClient()) {
|
||||
}
|
||||
else if (pPlayer->IsFakeClient())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client %d is a bot", client);
|
||||
}
|
||||
|
||||
INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
|
||||
|
||||
return sp_ftoc(pInfo->GetAvgLoss(params[2]));
|
||||
if (params[2] == MAX_FLOWS)
|
||||
{
|
||||
value = pInfo->GetAvgLoss(FLOW_INCOMING) + pInfo->GetAvgLoss(FLOW_OUTGOING);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = pInfo->GetAvgLoss(params[2]);
|
||||
}
|
||||
|
||||
return sp_ftoc(value);
|
||||
}
|
||||
|
||||
static cell_t GetAvgChoke(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
int client = params[1];
|
||||
float value;
|
||||
|
||||
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
|
||||
if (!pPlayer)
|
||||
{
|
||||
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
||||
} else if (!pPlayer->IsInGame()) {
|
||||
}
|
||||
else if (!pPlayer->IsInGame())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client %d is not in game", client);
|
||||
} else if (pPlayer->IsFakeClient()) {
|
||||
}
|
||||
else if (pPlayer->IsFakeClient())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client %d is a bot", client);
|
||||
}
|
||||
|
||||
INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
|
||||
|
||||
return sp_ftoc(pInfo->GetAvgChoke(params[2]));
|
||||
if (params[2] == MAX_FLOWS)
|
||||
{
|
||||
value = pInfo->GetAvgChoke(FLOW_INCOMING) + pInfo->GetAvgChoke(FLOW_OUTGOING);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = pInfo->GetAvgChoke(params[2]);
|
||||
}
|
||||
|
||||
return sp_ftoc(value);
|
||||
}
|
||||
|
||||
static cell_t GetAvgData(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
int client = params[1];
|
||||
float value;
|
||||
|
||||
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
|
||||
if (!pPlayer)
|
||||
{
|
||||
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
||||
} else if (!pPlayer->IsInGame()) {
|
||||
}
|
||||
else if (!pPlayer->IsInGame())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client %d is not in game", client);
|
||||
} else if (pPlayer->IsFakeClient()) {
|
||||
}
|
||||
else if (pPlayer->IsFakeClient())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client %d is a bot", client);
|
||||
}
|
||||
|
||||
INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
|
||||
|
||||
return sp_ftoc(pInfo->GetAvgData(params[2]));
|
||||
if (params[2] == MAX_FLOWS)
|
||||
{
|
||||
value = pInfo->GetAvgData(FLOW_INCOMING) + pInfo->GetAvgData(FLOW_OUTGOING);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = pInfo->GetAvgData(params[2]);
|
||||
}
|
||||
|
||||
return sp_ftoc(value);
|
||||
}
|
||||
|
||||
static cell_t GetAvgPackets(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
int client = params[1];
|
||||
float value;
|
||||
|
||||
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
|
||||
if (!pPlayer)
|
||||
{
|
||||
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
||||
} else if (!pPlayer->IsInGame()) {
|
||||
}
|
||||
else if (!pPlayer->IsInGame())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client %d is not in game", client);
|
||||
} else if (pPlayer->IsFakeClient()) {
|
||||
}
|
||||
else if (pPlayer->IsFakeClient())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client %d is a bot", client);
|
||||
}
|
||||
|
||||
INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
|
||||
|
||||
return sp_ftoc(pInfo->GetAvgPackets(params[2]));
|
||||
if (params[2] == MAX_FLOWS)
|
||||
{
|
||||
value = pInfo->GetAvgPackets(FLOW_INCOMING) + pInfo->GetAvgPackets(FLOW_OUTGOING);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = pInfo->GetAvgPackets(params[2]);
|
||||
}
|
||||
|
||||
return sp_ftoc(value);
|
||||
}
|
||||
|
||||
static cell_t GetClientOfUserId(IPluginContext *pContext, const cell_t *params)
|
||||
|
@ -35,11 +35,14 @@
|
||||
#endif
|
||||
#define _clients_included
|
||||
|
||||
/**
|
||||
* Network flow directions.
|
||||
*/
|
||||
enum NetFlow
|
||||
{
|
||||
NetFlow_Outgoing = 0, /**< Outgoing traffic */
|
||||
NetFlow_Incoming, /**< Incoming traffic */
|
||||
NetFlow_Both /**< Incoming and outgoing traffic */
|
||||
NetFlow_Both, /**< Both values added together */
|
||||
};
|
||||
|
||||
#define MAXPLAYERS 64 /**< Maximum number of players that can be in server */
|
||||
|
Loading…
Reference in New Issue
Block a user