instead of randomly picking eligble clients we sort eligble clients by lowest tier
This commit is contained in:
parent
208ddb392d
commit
ca9f7b0d13
26
env/include/unloze_playtime.inc
vendored
Executable file
26
env/include/unloze_playtime.inc
vendored
Executable file
@ -0,0 +1,26 @@
|
||||
#if defined _unloze_playtime_included_
|
||||
#endinput
|
||||
#endif
|
||||
#define _unloze_playtime_included_
|
||||
|
||||
/**
|
||||
* @returns the average playtime of all connected players excluding autism bots, fakeclients, AFKS and nosteamers
|
||||
*/
|
||||
native int GetAveragePlayerTimeOnServer();
|
||||
|
||||
/**
|
||||
* @returns the players rtv amount boost
|
||||
*/
|
||||
native int GetPlayerWorthRTV_boost_(int client);
|
||||
|
||||
/**
|
||||
* returns a players hours for a specific server
|
||||
*
|
||||
* @int the actual client
|
||||
* @int Game time hours that the client has on the server.
|
||||
* @int Game time minutes the client has on the server.
|
||||
*/
|
||||
|
||||
native int GetPlayerTier_native(int client); //just the clients tier
|
||||
forward void GetPlayerHoursServer(int client, int hours, int minutes);
|
||||
forward void GetPlayerTier(int client, int tier);
|
||||
@ -32,6 +32,7 @@
|
||||
|
||||
#tryinclude "AFKManager.inc"
|
||||
#tryinclude "TeamManager.inc"
|
||||
#include "unloze_playtime.inc"
|
||||
|
||||
/* Restore old REQUIRE_PLUGIN value if necessary */
|
||||
#if defined TEMP_REQUIRE_PLUGIN
|
||||
@ -704,18 +705,24 @@ public Action:InfectMotherZombie(Handle:timer)
|
||||
// Infect one of the main candidates.
|
||||
if (candidatesMain)
|
||||
{
|
||||
// Get a random array index.
|
||||
new i = Math_GetRandomInt(0, candidatesMain - 1);
|
||||
// Find lowest tier candidate.
|
||||
new lowestIndex = 0;
|
||||
new lowestTier = GetPlayerTier_native(GetArrayCell(aCandidatesMain, 0));
|
||||
for (new n = 1; n < candidatesMain; n++)
|
||||
{
|
||||
new tier = GetPlayerTier_native(GetArrayCell(aCandidatesMain, n));
|
||||
if (tier < lowestTier)
|
||||
{
|
||||
lowestTier = tier;
|
||||
lowestIndex = n;
|
||||
}
|
||||
}
|
||||
new client = GetArrayCell(aCandidatesMain, lowestIndex);
|
||||
|
||||
// Get the client stored in the random array index.
|
||||
new client = GetArrayCell(aCandidatesMain, i);
|
||||
|
||||
// Infect player.
|
||||
if (InfectHumanToZombie(client, _, true))
|
||||
infected++;
|
||||
|
||||
// Remove player from eligible client list.
|
||||
RemoveFromArray(aCandidatesMain, i);
|
||||
RemoveFromArray(aCandidatesMain, lowestIndex);
|
||||
candidatesMain--;
|
||||
}
|
||||
else
|
||||
@ -735,18 +742,24 @@ public Action:InfectMotherZombie(Handle:timer)
|
||||
// Infect one of the alternate candidates.
|
||||
if (candidatesAlt)
|
||||
{
|
||||
// Get a random array index.
|
||||
new i = Math_GetRandomInt(0, candidatesAlt - 1);
|
||||
// Find lowest tier candidate.
|
||||
new lowestIndex = 0;
|
||||
new lowestTier = GetPlayerTier_native(GetArrayCell(aCandidatesAlt, 0));
|
||||
for (new n = 1; n < candidatesAlt; n++)
|
||||
{
|
||||
new tier = GetPlayerTier_native(GetArrayCell(aCandidatesAlt, n));
|
||||
if (tier < lowestTier)
|
||||
{
|
||||
lowestTier = tier;
|
||||
lowestIndex = n;
|
||||
}
|
||||
}
|
||||
new client = GetArrayCell(aCandidatesAlt, lowestIndex);
|
||||
|
||||
// Get the client stored in the random array index.
|
||||
new client = GetArrayCell(aCandidatesAlt, i);
|
||||
|
||||
// Infect player.
|
||||
if (InfectHumanToZombie(client, _, true))
|
||||
infected++;
|
||||
|
||||
// Remove player from eligible client list.
|
||||
RemoveFromArray(aCandidatesAlt, i);
|
||||
RemoveFromArray(aCandidatesAlt, lowestIndex);
|
||||
candidatesAlt--;
|
||||
}
|
||||
else // We have no candidates at all. time to fuck over random people!
|
||||
|
||||
Loading…
Reference in New Issue
Block a user