FakePopulation --> FakeClients

prepare fakes for the weekend
This commit is contained in:
Dogan 2019-11-05 17:02:52 +01:00
parent 99c9688908
commit b67178fe4e

View File

@ -10,11 +10,17 @@ char g_cName[NUMBEROFNAMES][] = {"Dwelitram", "Gwyri", "Caredus", "Arerawia", "V
bool g_bFakePopulation[MAXPLAYERS + 1];
bool g_bMapEnded;
int g_iBaseLatency[MAXPLAYERS + 1];
int g_iLatency[MAXPLAYERS + 1];
int g_iAdminFakes;
bool g_bCheckRequested;
int g_iBlockInstantFakeConnects;
bool g_bBlockInstantFakeConnects;
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
@ -23,7 +29,7 @@ public Plugin myinfo =
name = "ImprovedHitboxes", //camouflage
author = "Neon + Dogan + Botox",
description = "Handle Hitboxes via Plugin",
version = "4.0",
version = "5.0.0",
url = "https://steamcommunity.com/id/n3ontm"
};
@ -32,13 +38,19 @@ public Plugin myinfo =
//----------------------------------------------------------------------------------------------------
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_fakes", Command_Fakes, ADMFLAG_RCON, "Shows the fake-clients on server");
g_iAdminFakes = -1;
g_bMapEnded = false;
g_bBlockInstantFakeConnects = false;
g_iBlockInstantFakeConnects = 0;
CreateTimer(4.0, BlockInstantFakeConnects, _, TIMER_REPEAT);
CreateTimer(3.0, RandomizePing, _, TIMER_REPEAT);
CreateTimer(150.0, RandomizeNames, _, TIMER_REPEAT);
HookUserMessage(GetUserMessageId("SayText2"), UserMessage_SayText2, true);
RequestFrame(CheckPopulation);
}
@ -76,6 +88,21 @@ public void OnMapEnd()
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:
//----------------------------------------------------------------------------------------------------
@ -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:
//----------------------------------------------------------------------------------------------------
@ -115,6 +193,12 @@ public Action Command_DebugFakes(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)
{
ReplyToCommand(client, "[SM] Usage: sm_setfakes <amount of fakes>");
@ -257,17 +341,17 @@ public void CheckPopulation()
}
else if (iPlayers > 10)
{
iFakesNeeded = 3;
iFakesNeeded = 4;
iFakesInTeamNeeded = 1;
}
else if (iPlayers > 5)
{
iFakesNeeded = 2;
iFakesInTeamNeeded = 0;
iFakesNeeded = 4;
iFakesInTeamNeeded = 1;
}
else
{
iFakesNeeded = 0;
iFakesNeeded = 4;
iFakesInTeamNeeded = 0;
}
@ -276,7 +360,7 @@ public void CheckPopulation()
if (iFakes != iFakesNeeded)
{
while (iFakes < iFakesNeeded)
while (iFakes < iFakesNeeded && !g_bBlockInstantFakeConnects)
{
int RandomName = GetRandomInt(0, NUMBEROFNAMES - 1);
int iIndex = CreateFakeClient(g_cName[RandomName]);
@ -297,6 +381,9 @@ public void CheckPopulation()
SetUserAdmin(iIndex, FakeAdmin, true);
CS_SetClientClanTag(iIndex, "UNLOZE");
iFakes++;
if(g_iBlockInstantFakeConnects <= 4)
g_bBlockInstantFakeConnects = true;
}
while (iFakes > iFakesNeeded)
@ -352,6 +439,9 @@ public void CheckPopulation()
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnGameFrame()
{
for(int i = 1; i <= MaxClients; i++)