furhter adjustments based on time
This commit is contained in:
parent
c819974dd6
commit
1df4cdf8dc
@ -157,36 +157,35 @@ public void SQL_OnQueryCompleted(Database db, DBResultSet results, const char[]
|
||||
delete results;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnPluginEnd()
|
||||
{
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if(IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i))
|
||||
{
|
||||
g_iLatency[i] = 0;
|
||||
KickClient(i, "Disconnect by user.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnMapStart()
|
||||
{
|
||||
KeyValues kv = CreateKeyValues("ints_used_already");
|
||||
for (float i = 0.0; i < g_iFakesCount;)
|
||||
{
|
||||
int num = GetRandomInt(5, 150);
|
||||
char strnum[16];
|
||||
IntToString(num, strnum, sizeof(strnum));
|
||||
int found = kv.GetNum(strnum, -1);
|
||||
if (found != -1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
kv.SetNum(strnum, num);
|
||||
i += 1.0;
|
||||
CreateTimer(i * RoundToCeil(i / 3), addfakes);
|
||||
|
||||
CreateTimer(float(num), addfakes);
|
||||
}
|
||||
delete kv;
|
||||
}
|
||||
|
||||
public Action addfakes(Handle timer)
|
||||
{
|
||||
int fakes = 0;
|
||||
int spectators = 0;
|
||||
int inTeam = 0;
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if (IsClientConnected(i) && IsClientInGame(i) && IsClientAuthorized(i))
|
||||
@ -195,12 +194,25 @@ public Action addfakes(Handle timer)
|
||||
{
|
||||
fakes++;
|
||||
}
|
||||
if (GetClientTeam(i) <= CS_TEAM_SPECTATOR)
|
||||
{
|
||||
spectators++;
|
||||
}
|
||||
else
|
||||
{
|
||||
inTeam++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fakes < 16)
|
||||
int limit = 16;
|
||||
if (nightTime())
|
||||
{
|
||||
limit /= 2;
|
||||
}
|
||||
if (fakes < limit)
|
||||
{
|
||||
CreateFake();
|
||||
if (GetRandomInt(0, 10) <= 3)
|
||||
if (spectators > limit || inTeam + 2 < spectators)
|
||||
{
|
||||
SetFakeToTeam();
|
||||
}
|
||||
@ -472,6 +484,11 @@ public void KickFakes()
|
||||
public void ManageFakes(int iPlayersSpectate, int iPlayersInTeam, int iFakesInTeam, int iFakesSpectate)
|
||||
{
|
||||
int limit = 16;
|
||||
if (nightTime())
|
||||
{
|
||||
limit /= 2;
|
||||
}
|
||||
|
||||
if (iPlayersSpectate + iPlayersInTeam + 4 < iFakesSpectate + iFakesInTeam || iFakesSpectate + iFakesInTeam > limit)
|
||||
{
|
||||
KickFakes();
|
||||
@ -479,12 +496,7 @@ public void ManageFakes(int iPlayersSpectate, int iPlayersInTeam, int iFakesInTe
|
||||
else if (iPlayersSpectate + iPlayersInTeam > iFakesSpectate + iFakesInTeam && iFakesSpectate + iFakesInTeam < limit)
|
||||
{
|
||||
CreateFake();
|
||||
int max = 3;
|
||||
if (iPlayersSpectate + iFakesSpectate > limit)
|
||||
{
|
||||
max = 7;
|
||||
}
|
||||
if (GetRandomInt(0, 10) <= max)
|
||||
if (iPlayersSpectate + iFakesSpectate > limit || iPlayersInTeam + iFakesInTeam + 2 < iPlayersSpectate + iFakesSpectate)
|
||||
{
|
||||
SetFakeToTeam();
|
||||
}
|
||||
@ -504,6 +516,27 @@ public void SetFakeToTeam()
|
||||
}
|
||||
}
|
||||
|
||||
public bool nightTime()
|
||||
{
|
||||
char sTime[8];
|
||||
FormatTime(sTime, sizeof(sTime), "%H%M");
|
||||
|
||||
int CurTime = StringToInt(sTime);
|
||||
int MinTime = 2000;
|
||||
int MaxTime = 500;
|
||||
|
||||
//Wrap around.
|
||||
CurTime = (CurTime <= MinTime) ? CurTime + 2400 : CurTime;
|
||||
MaxTime = (MaxTime <= MinTime) ? MaxTime + 2400 : MaxTime;
|
||||
|
||||
if ((MinTime <= CurTime <= MaxTime))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void CreateFake()
|
||||
{
|
||||
if (g_hNames.Length == 0 || g_hClanNames.Length == 0)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user