FakePopulation --> FakeClients
prepare fakes for the weekend
This commit is contained in:
		
							parent
							
								
									c7e84ac2cb
								
							
						
					
					
						commit
						7e27a3e5e0
					
				@ -10,11 +10,17 @@ char g_cName[NUMBEROFNAMES][] = {"Dwelitram", "Gwyri", "Caredus", "Arerawia", "V
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
bool g_bFakePopulation[MAXPLAYERS + 1];
 | 
					bool g_bFakePopulation[MAXPLAYERS + 1];
 | 
				
			||||||
bool g_bMapEnded;
 | 
					bool g_bMapEnded;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int g_iBaseLatency[MAXPLAYERS + 1];
 | 
					int g_iBaseLatency[MAXPLAYERS + 1];
 | 
				
			||||||
int g_iLatency[MAXPLAYERS + 1];
 | 
					int g_iLatency[MAXPLAYERS + 1];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int g_iAdminFakes;
 | 
					int g_iAdminFakes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool g_bCheckRequested;
 | 
					bool g_bCheckRequested;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int g_iBlockInstantFakeConnects;
 | 
				
			||||||
 | 
					bool g_bBlockInstantFakeConnects;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//----------------------------------------------------------------------------------------------------
 | 
					//----------------------------------------------------------------------------------------------------
 | 
				
			||||||
// Purpose:
 | 
					// Purpose:
 | 
				
			||||||
//----------------------------------------------------------------------------------------------------
 | 
					//----------------------------------------------------------------------------------------------------
 | 
				
			||||||
@ -23,7 +29,7 @@ public Plugin myinfo =
 | 
				
			|||||||
	name        = "ImprovedHitboxes", //camouflage
 | 
						name        = "ImprovedHitboxes", //camouflage
 | 
				
			||||||
	author      = "Neon + Dogan + Botox",
 | 
						author      = "Neon + Dogan + Botox",
 | 
				
			||||||
	description = "Handle Hitboxes via Plugin",
 | 
						description = "Handle Hitboxes via Plugin",
 | 
				
			||||||
	version     = "4.0",
 | 
						version     = "5.0.0",
 | 
				
			||||||
	url         = "https://steamcommunity.com/id/n3ontm"
 | 
						url         = "https://steamcommunity.com/id/n3ontm"
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -32,13 +38,19 @@ public Plugin myinfo =
 | 
				
			|||||||
//----------------------------------------------------------------------------------------------------
 | 
					//----------------------------------------------------------------------------------------------------
 | 
				
			||||||
public void OnPluginStart()
 | 
					public void OnPluginStart()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	RegAdminCmd("sm_debugfakes", Command_DebugFakes, ADMFLAG_RCON, "Shows the amount of fake-clients on server");
 | 
						RegAdminCmd("sm_debugfakes", Command_DebugFakes, ADMFLAG_GENERIC, "Shows the amount of fake-clients on server");
 | 
				
			||||||
 | 
						RegAdminCmd("sm_fakes", Command_Fakes, ADMFLAG_GENERIC, "Shows the fake-clients on server");
 | 
				
			||||||
	RegAdminCmd("sm_setfakes", Command_SetFakes, ADMFLAG_RCON, "Manually sets the amount of fake-clients");
 | 
						RegAdminCmd("sm_setfakes", Command_SetFakes, ADMFLAG_RCON, "Manually sets the amount of fake-clients");
 | 
				
			||||||
	RegAdminCmd("sm_fakes", Command_Fakes, ADMFLAG_RCON, "Shows the fake-clients on server");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	g_iAdminFakes = -1;
 | 
						g_iAdminFakes = -1;
 | 
				
			||||||
	g_bMapEnded = false;
 | 
						g_bMapEnded = false;
 | 
				
			||||||
 | 
						g_bBlockInstantFakeConnects = false;
 | 
				
			||||||
 | 
						g_iBlockInstantFakeConnects = 0;
 | 
				
			||||||
 | 
						CreateTimer(4.0, BlockInstantFakeConnects, _, TIMER_REPEAT);
 | 
				
			||||||
	CreateTimer(3.0, RandomizePing, _, TIMER_REPEAT);
 | 
						CreateTimer(3.0, RandomizePing, _, TIMER_REPEAT);
 | 
				
			||||||
 | 
						CreateTimer(150.0, RandomizeNames, _, TIMER_REPEAT);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						HookUserMessage(GetUserMessageId("SayText2"), UserMessage_SayText2, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	RequestFrame(CheckPopulation);
 | 
						RequestFrame(CheckPopulation);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -76,6 +88,21 @@ public void OnMapEnd()
 | 
				
			|||||||
	g_iAdminFakes = -1;
 | 
						g_iAdminFakes = -1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//----------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					// Purpose:
 | 
				
			||||||
 | 
					//----------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					public Action BlockInstantFakeConnects(Handle timer)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						g_iBlockInstantFakeConnects++;
 | 
				
			||||||
 | 
						g_bBlockInstantFakeConnects = false;
 | 
				
			||||||
 | 
						RequestFrame(CheckPopulation);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if(g_iBlockInstantFakeConnects > 4)
 | 
				
			||||||
 | 
							return Plugin_Stop;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return Plugin_Continue;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//----------------------------------------------------------------------------------------------------
 | 
					//----------------------------------------------------------------------------------------------------
 | 
				
			||||||
// Purpose:
 | 
					// Purpose:
 | 
				
			||||||
//----------------------------------------------------------------------------------------------------
 | 
					//----------------------------------------------------------------------------------------------------
 | 
				
			||||||
@ -88,6 +115,57 @@ public Action RandomizePing(Handle timer)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//----------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					// Purpose:
 | 
				
			||||||
 | 
					//----------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					public Action RandomizeNames(Handle timer)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						for(int i = 1; i <= MaxClients; i++)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							if(g_bFakePopulation[i])
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								int RandomName = GetRandomInt(0, NUMBEROFNAMES - 1);
 | 
				
			||||||
 | 
								SetClientName(i, g_cName[RandomName]);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//----------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					// Purpose:
 | 
				
			||||||
 | 
					//----------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					public Action UserMessage_SayText2(UserMsg msg_id, BfRead msg, const int[] players, int playersNum, bool reliable, bool init)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if(!reliable)
 | 
				
			||||||
 | 
							return Plugin_Continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						int client;
 | 
				
			||||||
 | 
						char sMessage[32];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if(GetUserMessageType() == UM_Protobuf) //fuck cs go but "ClEaN CoDe"
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							PbReadString(msg, "msg_name", sMessage, sizeof(sMessage));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if(!(sMessage[0] == '#' && StrContains(sMessage, "Name_Change")))
 | 
				
			||||||
 | 
								return Plugin_Continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							client = PbReadInt(msg, "ent_idx");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							client = BfReadByte(msg);
 | 
				
			||||||
 | 
							BfReadByte(msg);
 | 
				
			||||||
 | 
							BfReadString(msg, sMessage, sizeof(sMessage));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if(!(sMessage[0] == '#' && StrContains(sMessage, "Name_Change")))
 | 
				
			||||||
 | 
								return Plugin_Continue;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if(g_bFakePopulation[client])
 | 
				
			||||||
 | 
							return Plugin_Handled;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return Plugin_Continue;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//----------------------------------------------------------------------------------------------------
 | 
					//----------------------------------------------------------------------------------------------------
 | 
				
			||||||
// Purpose:
 | 
					// Purpose:
 | 
				
			||||||
//----------------------------------------------------------------------------------------------------
 | 
					//----------------------------------------------------------------------------------------------------
 | 
				
			||||||
@ -115,6 +193,12 @@ public Action Command_DebugFakes(int client, int argc)
 | 
				
			|||||||
//----------------------------------------------------------------------------------------------------
 | 
					//----------------------------------------------------------------------------------------------------
 | 
				
			||||||
public Action Command_SetFakes(int client, int argc)
 | 
					public Action Command_SetFakes(int client, int argc)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						if(g_iBlockInstantFakeConnects <= 4)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							ReplyToCommand(client, "[SM] Not available right now, because the Plugin is still loading. Try again in couple seconds.");
 | 
				
			||||||
 | 
							return Plugin_Handled;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (argc < 1)
 | 
						if (argc < 1)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		ReplyToCommand(client, "[SM] Usage: sm_setfakes <amount of fakes>");
 | 
							ReplyToCommand(client, "[SM] Usage: sm_setfakes <amount of fakes>");
 | 
				
			||||||
@ -257,17 +341,17 @@ public void CheckPopulation()
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	else if (iPlayers > 10)
 | 
						else if (iPlayers > 10)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		iFakesNeeded = 3;
 | 
							iFakesNeeded = 4;
 | 
				
			||||||
		iFakesInTeamNeeded = 1;
 | 
							iFakesInTeamNeeded = 1;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	else if (iPlayers > 5)
 | 
						else if (iPlayers > 5)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		iFakesNeeded = 2;
 | 
							iFakesNeeded = 4;
 | 
				
			||||||
		iFakesInTeamNeeded = 0;
 | 
							iFakesInTeamNeeded = 1;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		iFakesNeeded = 0;
 | 
							iFakesNeeded = 4;
 | 
				
			||||||
		iFakesInTeamNeeded = 0;
 | 
							iFakesInTeamNeeded = 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -276,7 +360,7 @@ public void CheckPopulation()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	if (iFakes != iFakesNeeded)
 | 
						if (iFakes != iFakesNeeded)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		while (iFakes < iFakesNeeded)
 | 
							while (iFakes < iFakesNeeded && !g_bBlockInstantFakeConnects)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			int RandomName = GetRandomInt(0, NUMBEROFNAMES - 1);
 | 
								int RandomName = GetRandomInt(0, NUMBEROFNAMES - 1);
 | 
				
			||||||
			int iIndex = CreateFakeClient(g_cName[RandomName]);
 | 
								int iIndex = CreateFakeClient(g_cName[RandomName]);
 | 
				
			||||||
@ -297,6 +381,9 @@ public void CheckPopulation()
 | 
				
			|||||||
			SetUserAdmin(iIndex, FakeAdmin, true);
 | 
								SetUserAdmin(iIndex, FakeAdmin, true);
 | 
				
			||||||
			CS_SetClientClanTag(iIndex, "UNLOZE");
 | 
								CS_SetClientClanTag(iIndex, "UNLOZE");
 | 
				
			||||||
			iFakes++;
 | 
								iFakes++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if(g_iBlockInstantFakeConnects <= 4)
 | 
				
			||||||
 | 
									g_bBlockInstantFakeConnects = true;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		while (iFakes > iFakesNeeded)
 | 
							while (iFakes > iFakesNeeded)
 | 
				
			||||||
@ -352,6 +439,9 @@ public void CheckPopulation()
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//----------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					// Purpose:
 | 
				
			||||||
 | 
					//----------------------------------------------------------------------------------------------------
 | 
				
			||||||
public void OnGameFrame()
 | 
					public void OnGameFrame()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	for(int i = 1; i <= MaxClients; i++)
 | 
						for(int i = 1; i <= MaxClients; i++)
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user