just adding a config file to control if the fakeclients should join a team based on player count
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
"FakeClientsTiersTeam"
|
||||
{
|
||||
"0" "0"
|
||||
"10" "2"
|
||||
"14" "3"
|
||||
"18" "4"
|
||||
"22" "5"
|
||||
"26" "6"
|
||||
}
|
||||
@@ -171,6 +171,49 @@ public void OnMapStart()
|
||||
delete kv;
|
||||
}
|
||||
|
||||
public int getFakesNeededInTeam()
|
||||
{
|
||||
//just moving them with CheckPopulation() over to a team as needed. we dont bother moving them back to spectate, mapchanges do that for us.
|
||||
char sPath[PLATFORM_MAX_PATH];
|
||||
BuildPath(Path_SM, sPath, sizeof(sPath), "configs/fakeclients_tiers_team.cfg");
|
||||
|
||||
KeyValues kv = new KeyValues("FakeClientsTiersTeam");
|
||||
if (!kv.ImportFromFile(sPath))
|
||||
{
|
||||
LogError("configs/fakeclients_tiers_team.cfg not found");
|
||||
delete kv;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!kv.GotoFirstSubKey(false))
|
||||
{
|
||||
LogError("configs/fakeclients_tiers_team.cfg is empty or malformed");
|
||||
delete kv;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int prev_bots = 0;
|
||||
do
|
||||
{
|
||||
char sKey[16], sVal[16];
|
||||
kv.GetSectionName(sKey, sizeof(sKey));
|
||||
kv.GetString(NULL_STRING, sVal, sizeof(sVal), "-1");
|
||||
|
||||
int bots = StringToInt(sVal);
|
||||
int players = StringToInt(sKey);
|
||||
if (players > g_iPlayerCount)
|
||||
{
|
||||
break;
|
||||
}
|
||||
prev_bots = bots;
|
||||
|
||||
} while (kv.GotoNextKey(false));
|
||||
|
||||
delete kv;
|
||||
//LogMessage("prev_bots: %i", prev_bots);
|
||||
return prev_bots;
|
||||
}
|
||||
|
||||
public int getFakesNeeded()
|
||||
{
|
||||
//copied from nide fakeclients plugin.
|
||||
@@ -228,10 +271,12 @@ public Action addfakes(Handle timer)
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
if (nightTime())
|
||||
{
|
||||
limit /= 2;
|
||||
}
|
||||
*/
|
||||
|
||||
if (fakes < limit)
|
||||
{
|
||||
@@ -388,7 +433,6 @@ public Action Command_DebugFakes(int client, int argc)
|
||||
}
|
||||
if (IsFakeClient(i) && GetClientTeam(i) > CS_TEAM_SPECTATOR)
|
||||
iFakesInTeam++;
|
||||
|
||||
}
|
||||
|
||||
ReplyToCommand(client, "[SM] There are currently %d Fake-Clients, from which %d are in Spectate. Real Clients %d", iFakes, iFakes - iFakesInTeam, iPlayers);
|
||||
@@ -460,10 +504,12 @@ public void CheckPopulation()
|
||||
}
|
||||
}
|
||||
int fakes_needed = getFakesNeeded();
|
||||
/*
|
||||
if (nightTime())
|
||||
{
|
||||
fakes_needed /= 2;
|
||||
}
|
||||
*/
|
||||
|
||||
if (fakes > fakes_needed && last_fake != 0)
|
||||
{
|
||||
@@ -474,6 +520,23 @@ public void CheckPopulation()
|
||||
{
|
||||
CreateFake();
|
||||
}
|
||||
|
||||
//moving fakes to a team
|
||||
int fakes_in_team = 0;
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if (IsClientConnected(i) && IsClientInGame(i) && IsClientAuthorized(i))
|
||||
{
|
||||
if (IsFakeClient(i) && !IsClientSourceTV(i) && GetClientTeam(i) > CS_TEAM_SPECTATOR)
|
||||
{
|
||||
fakes_in_team++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getFakesNeededInTeam() > fakes_in_team)
|
||||
{
|
||||
SetFakeToTeam();
|
||||
}
|
||||
}
|
||||
|
||||
public bool nightTime()
|
||||
@@ -497,8 +560,6 @@ public bool nightTime()
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//not used anymore
|
||||
public void SetFakeToTeam()
|
||||
{
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
|
||||
Reference in New Issue
Block a user