sm-plugins/FakePopulation/scripting/FakePopulation.sp

147 lines
4.3 KiB
SourcePawn
Raw Normal View History

#include <sourcemod>
#pragma semicolon 1
#pragma newdecls required
2019-08-25 02:40:15 +02:00
#define NUMBEROFNAMES 48
char g_cName[NUMBEROFNAMES][] = {"Dwelitram", "Gwyri", "Caredus", "Arerawia", "Vilali", "Astiwiel", "Vardonydd", "Ybaossa", "Umyk", "Nico50Pax", "Onand", "Thelian", "Nydaleth", "Chomarin", "Traedien", "Miev", "Kaaede", "Koamond", "TheRottenBenson", "BigLegend2017", "TRIGGEREDHarambexXx", "InPepe2016", "xXxMaster2012", "InBoixXx", "TheKopsing", "Cornelius", "Gustavo", "Bryant", "Winfred", "Nicolas", "Mitchel", "Dana", "Carrol", "Darell", "Ruben", "Jeromy", "Wade", "Scotty", "Salvatore", "Kory", "Don", "Morgan", "Kurtis", "Federico", "Darin", "css-ru", "aimbot", "lastkraftwagenfahrzeug"};
bool g_bFakePopulation[MAXPLAYERS+1];
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Plugin myinfo =
{
name = "ImprovedHitboxes", //camouflage
2019-08-25 02:40:15 +02:00
author = "Neon + Dogan",
description = "Handle Hitboxes via Plugin",
version = "2.0",
url = "https://steamcommunity.com/id/n3ontm"
};
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnPluginStart()
{
RegAdminCmd("sm_debugfakes", Command_DebugFakes, ADMFLAG_RCON, "");
CheckPopulation();
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnPluginEnd()
{
2019-08-25 02:40:15 +02:00
for(int i = 1; i <= MaxClients; i++)
{
if(g_bFakePopulation[i])
{
g_bFakePopulation[i] = false;
KickClientEx(i);
}
2019-08-25 02:40:15 +02:00
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Command_DebugFakes(int client, int argc)
{
2019-08-25 02:40:15 +02:00
int iFakes = 0;
for(int i = 1; i <= MaxClients; i++)
{
if (g_bFakePopulation[i])
2019-08-25 02:40:15 +02:00
iFakes++;
}
ReplyToCommand(client, "[SM] There are currently %d Fake Players.", iFakes);
return Plugin_Handled;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnClientConnected(int client)
{
if ((client > 0) && (!IsFakeClient(client)))
CheckPopulation();
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnClientDisconnect(int client)
{
if (client > 0)
{
if(g_bFakePopulation[client])
g_bFakePopulation[client] = false;
if (!IsFakeClient(client))
CheckPopulation();
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void CheckPopulation()
{
int iPlayers = 0;
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientConnected(i) && !IsFakeClient(i))
iPlayers++;
}
int iFakes = 0;
2019-08-25 02:40:15 +02:00
for(int i = 1; i <= MaxClients; i++)
{
if (g_bFakePopulation[i])
2019-08-25 02:40:15 +02:00
iFakes++;
}
int iFakesNeeded = 0;
2019-08-25 02:40:15 +02:00
if (iPlayers >= 61)
iFakesNeeded = 0;
else if(iPlayers >= 60)
iFakesNeeded = 1;
else if(iPlayers >= 55)
iFakesNeeded = 3;
else if (iPlayers >= 40)
iFakesNeeded = 4;
else if (iPlayers >= 20)
iFakesNeeded = 3;
else if (iPlayers >= 10)
iFakesNeeded = 2;
else if (iPlayers >= 5)
iFakesNeeded = 1;
else
2019-08-25 02:40:15 +02:00
iFakesNeeded = 0;
if(iFakesNeeded == iFakes)
return;
while (iFakes < iFakesNeeded)
{
int RandomName = GetRandomInt(0, NUMBEROFNAMES - 1);
int iIndex = CreateFakeClient(g_cName[RandomName]);
g_bFakePopulation[iIndex] = true;
2019-08-25 02:40:15 +02:00
iFakes++;
}
2019-08-25 02:40:15 +02:00
while (iFakes > iFakesNeeded)
{
for(int i = 1; i <= MaxClients; i++)
{
if(g_bFakePopulation[i])
2019-08-25 02:40:15 +02:00
{
g_bFakePopulation[i] = false;
KickClientEx(i);
2019-08-25 02:40:15 +02:00
iFakes--;
break;
}
}
}
}