Status: Remove buffering, done by sourcemod now.

PlayerVisibility: Fix on some maps, thx Shufen.
Spectate: Server crash exploit.
ExtraCommands: minor change
This commit is contained in:
BotoX
2017-01-22 15:20:08 +01:00
parent c37131fcbb
commit 73a725f3b2
4 changed files with 54 additions and 90 deletions
+24 -86
View File
@@ -12,9 +12,6 @@ ConVar g_Cvar_HostPort;
ConVar g_Cvar_HostName;
ConVar g_Cvar_HostTags;
Handle g_hPlayerList[MAXPLAYERS + 1] = {INVALID_HANDLE, ...};
bool g_bDataAvailable = false;
#if !defined _serverfps_included
int g_iTickRate;
#endif
@@ -43,9 +40,6 @@ public Action Command_Status(int client, const char[] command, int args)
if(!client)
return Plugin_Continue;
if(g_hPlayerList[client] != INVALID_HANDLE)
return Plugin_Handled;
static char sServerName[128];
static char sServerTags[128];
static char sServerAdress[128];
@@ -88,9 +82,6 @@ public Action Command_Status(int client, const char[] command, int args)
}
}
static char sSendBuffer[896];
int iBufLength = 0;
#if defined _serverfps_included
float fServerTickRate = 1.0 / GetTickInterval();
float fServerFPS = GetServerFPS();
@@ -103,43 +94,37 @@ public Action Command_Status(int client, const char[] command, int args)
iTickRate = iTickRate <= iServerTickRate ? iTickRate : iServerTickRate;
#endif
iBufLength += FormatEx(sSendBuffer[iBufLength], sizeof(sSendBuffer) - iBufLength,
"hostname: %s\n", sServerName);
PrintToConsole(client, "hostname: %s",
sServerName);
#if defined _serverfps_included
iBufLength += FormatEx(sSendBuffer[iBufLength], sizeof(sSendBuffer) - iBufLength,
"tickrate : %.2f/%.2f (%d%%%%)\n", fServerFPS, fServerTickRate, RoundToNearest((fServerFPS / fServerTickRate) * 100));
PrintToConsole(client, "tickrate : %.2f/%.2f (%d%%%%)",
fServerFPS, fServerTickRate, RoundToNearest((fServerFPS / fServerTickRate) * 100));
#else
iBufLength += FormatEx(sSendBuffer[iBufLength], sizeof(sSendBuffer) - iBufLength,
"tickrate : %d/%d (%d%%%%)\n", iTickRate, iServerTickRate, RoundToNearest((float(iTickRate) / float(iServerTickRate)) * 100));
PrintToConsole(client, "tickrate : %d/%d (%d%%%%)",
iTickRate, iServerTickRate, RoundToNearest((float(iTickRate) / float(iServerTickRate)) * 100));
#endif
iBufLength += FormatEx(sSendBuffer[iBufLength], sizeof(sSendBuffer) - iBufLength,
"udp/ip : %s\n", sServerAdress);
PrintToConsole(client, "udp/ip : %s",
sServerAdress);
iBufLength += FormatEx(sSendBuffer[iBufLength], sizeof(sSendBuffer) - iBufLength,
"net I/O : %.2f/%.2f KiB/s (You: %.2f/%.2f KiB/s)\n", fServerDataIn / 1024, fServerDataOut / 1024, fClientDataIn / 1024, fClientDataOut / 1024);
PrintToConsole(client, "net I/O : %.2f/%.2f KiB/s (You: %.2f/%.2f KiB/s)",
fServerDataIn / 1024, fServerDataOut / 1024, fClientDataIn / 1024, fClientDataOut / 1024);
iBufLength += FormatEx(sSendBuffer[iBufLength], sizeof(sSendBuffer) - iBufLength,
"map : %s at: %.0f x, %.0f y, %.0f z\n", sMapName, fPosition[0], fPosition[1], fPosition[2]);
PrintToConsole(client, "map : %s at: %.0f x, %.0f y, %.0f z",
sMapName, fPosition[0], fPosition[1], fPosition[2]);
iBufLength += FormatEx(sSendBuffer[iBufLength], sizeof(sSendBuffer) - iBufLength,
"tags : %s\n", sServerTags);
PrintToConsole(client, "tags : %s",
sServerTags);
iBufLength += FormatEx(sSendBuffer[iBufLength], sizeof(sSendBuffer) - iBufLength,
"edicts : %d/%d/%d (used/max/free)\n", GetEntityCount(), GetMaxEntities(), GetMaxEntities() - GetEntityCount());
PrintToConsole(client, "edicts : %d/%d/%d (used/max/free)",
GetEntityCount(), GetMaxEntities(), GetMaxEntities() - GetEntityCount());
iBufLength += FormatEx(sSendBuffer[iBufLength], sizeof(sSendBuffer) - iBufLength,
"players : %d %s | %d %s (%d/%d)\n", iRealClients, Multiple(iRealClients) ? "humans" : "human", iFakeClients, Multiple(iFakeClients) ? "bots" : "bot", iTotalClients, MaxClients);
PrintToConsole(client, "players : %d %s | %d %s (%d/%d)",
iRealClients, Multiple(iRealClients) ? "humans" : "human", iFakeClients, Multiple(iFakeClients) ? "bots" : "bot", iTotalClients, MaxClients);
iBufLength += FormatEx(sSendBuffer[iBufLength], sizeof(sSendBuffer) - iBufLength,
"# %8s %40s %24s %12s %4s %4s %s %s", "userid", "name", "uniqueid", "connected", "ping", "loss", "state", "addr");
g_hPlayerList[client] = CreateArray(ByteCountToCells(sizeof(sSendBuffer)));
PushArrayString(g_hPlayerList[client], sSendBuffer);
g_bDataAvailable = true;
sSendBuffer[0] = 0;
PrintToConsole(client, "# %8s %40s %24s %12s %4s %4s %s %s",
"userid", "name", "uniqueid", "connected", "ping", "loss", "state", "addr");
for(int player = 1; player <= MaxClients; player++)
{
@@ -147,7 +132,7 @@ public Action Command_Status(int client, const char[] command, int args)
continue;
static char sPlayerID[8];
static char sPlayerName[MAX_NAME_LENGTH];
static char sPlayerName[MAX_NAME_LENGTH + 2];
static char sPlayerAuth[24];
char sPlayerTime[12];
char sPlayerPing[4];
@@ -181,30 +166,11 @@ public Action Command_Status(int client, const char[] command, int args)
else
FormatEx(sPlayerState, sizeof(sPlayerState), "spawning");
if(GetAdminFlag(GetUserAdmin(client), Admin_Ban))
if(GetAdminFlag(GetUserAdmin(client), Admin_Custom3))
GetClientIP(player, sPlayerAddr, sizeof(sPlayerAddr));
static char sFormatted[128];
FormatEx(sFormatted, sizeof(sFormatted), "# %8s %40s %24s %12s %4s %4s %s %s\n", sPlayerID, sPlayerName, sPlayerAuth, sPlayerTime, sPlayerPing, sPlayerLoss, sPlayerState, sPlayerAddr);
int iFormattedLength = strlen(sFormatted);
if(iBufLength + iFormattedLength >= sizeof(sSendBuffer))
{
sSendBuffer[iBufLength - 1] = 0;
PushArrayString(g_hPlayerList[client], sSendBuffer);
sSendBuffer[0] = 0;
iBufLength = 0;
}
StrCat(sSendBuffer, sizeof(sSendBuffer), sFormatted);
iBufLength += iFormattedLength;
}
if(iBufLength)
{
sSendBuffer[iBufLength - 1] = 0;
PushArrayString(g_hPlayerList[client], sSendBuffer);
PrintToConsole(client, "# %8s %40s %24s %12s %4s %4s %s %s",
sPlayerID, sPlayerName, sPlayerAuth, sPlayerTime, sPlayerPing, sPlayerLoss, sPlayerState, sPlayerAddr);
}
return Plugin_Handled;
@@ -226,34 +192,6 @@ public void OnGameFrame()
fLastEngineTime = fCurEngineTime;
}
#endif
if(!g_bDataAvailable)
return;
bool bGotData = false;
for(int client = 1; client <= MaxClients; client++)
{
if(g_hPlayerList[client] == INVALID_HANDLE)
continue;
if(!IsClientInGame(client) || !GetArraySize(g_hPlayerList[client]))
{
CloseHandle(g_hPlayerList[client]);
g_hPlayerList[client] = INVALID_HANDLE;
continue;
}
static char sBuffer[896];
GetArrayString(g_hPlayerList[client], 0, sBuffer, sizeof(sBuffer));
RemoveFromArray(g_hPlayerList[client], 0);
PrintToConsole(client, sBuffer);
bGotData = true;
}
if(!bGotData)
g_bDataAvailable = false;
}
stock bool Multiple(int num)