Compare commits

..

No commits in common. "TierBasedInfecting" and "master" have entirely different histories.

4 changed files with 18 additions and 175 deletions

2
.gitignore vendored
View File

@ -1,7 +1,5 @@
src/zr/hgversion.h.inc src/zr/hgversion.h.inc
cstrike/
build/ build/
release/ release/
docs/changes/ docs/changes/

View File

@ -1,26 +0,0 @@
#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);

View File

@ -32,7 +32,6 @@
#tryinclude "AFKManager.inc" #tryinclude "AFKManager.inc"
#tryinclude "TeamManager.inc" #tryinclude "TeamManager.inc"
#include "unloze_playtime.inc"
/* Restore old REQUIRE_PLUGIN value if necessary */ /* Restore old REQUIRE_PLUGIN value if necessary */
#if defined TEMP_REQUIRE_PLUGIN #if defined TEMP_REQUIRE_PLUGIN
@ -235,7 +234,6 @@ InfectClientInit(client)
if(!IsClientInGame(x)) if(!IsClientInGame(x))
continue; continue;
/*
#if defined _AFKManager_Included #if defined _AFKManager_Included
if(g_AFKManagerLoaded) if(g_AFKManagerLoaded)
{ {
@ -243,7 +241,6 @@ InfectClientInit(client)
continue; continue;
} }
#endif #endif
*/
players++; players++;
@ -707,24 +704,18 @@ public Action:InfectMotherZombie(Handle:timer)
// Infect one of the main candidates. // Infect one of the main candidates.
if (candidatesMain) if (candidatesMain)
{ {
// Find lowest tier candidate. // Get a random array index.
new lowestIndex = 0; new i = Math_GetRandomInt(0, candidatesMain - 1);
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)) if (InfectHumanToZombie(client, _, true))
infected++; infected++;
RemoveFromArray(aCandidatesMain, lowestIndex); // Remove player from eligible client list.
RemoveFromArray(aCandidatesMain, i);
candidatesMain--; candidatesMain--;
} }
else else
@ -744,24 +735,18 @@ public Action:InfectMotherZombie(Handle:timer)
// Infect one of the alternate candidates. // Infect one of the alternate candidates.
if (candidatesAlt) if (candidatesAlt)
{ {
// Find lowest tier candidate. // Get a random array index.
new lowestIndex = 0; new i = Math_GetRandomInt(0, candidatesAlt - 1);
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)) if (InfectHumanToZombie(client, _, true))
infected++; infected++;
RemoveFromArray(aCandidatesAlt, lowestIndex); // Remove player from eligible client list.
RemoveFromArray(aCandidatesAlt, i);
candidatesAlt--; candidatesAlt--;
} }
else // We have no candidates at all. time to fuck over random people! else // We have no candidates at all. time to fuck over random people!

View File

@ -30,7 +30,6 @@
*/ */
#define ZMARKET_COOKIE_AUTOREBUY "zr_zmarket_autorebuy" #define ZMARKET_COOKIE_AUTOREBUY "zr_zmarket_autorebuy"
#define ZMARKET_COOKIE_REBUY "zr_zmarket_rebuy" #define ZMARKET_COOKIE_REBUY "zr_zmarket_rebuy"
#define ZMARKET_COOKIE_RANDOMIZE "zr_zmarket_randomize"
/** /**
* @endsection * @endsection
*/ */
@ -40,14 +39,6 @@
*/ */
#define ZMARKET_REBUY_WEAPONS_SLOTS_MAX 1 #define ZMARKET_REBUY_WEAPONS_SLOTS_MAX 1
/**
* 2026 randomization of zmarket guns for round start.
*/
new Handle:g_hZMarketRandomizeCookie = INVALID_HANDLE;
new bool:g_bZMarketRandomize[MAXPLAYERS + 1];
new String:g_sZMarketRandomHistoryPrimary[MAXPLAYERS + 1][3][WEAPONS_MAX_LENGTH];
/** /**
* Array to store the client's current weapon type within menu. * Array to store the client's current weapon type within menu.
*/ */
@ -99,12 +90,6 @@ ZMarketOnCookiesCreate()
g_hZMarketLoadoutCookie[x] = RegClientCookie(rebuycookiename, rebuycookiedesc, CookieAccess_Protected); g_hZMarketLoadoutCookie[x] = RegClientCookie(rebuycookiename, rebuycookiedesc, CookieAccess_Protected);
} }
} }
// Randomize toggle cookie.
if (g_hZMarketRandomizeCookie == INVALID_HANDLE)
{
g_hZMarketRandomizeCookie = RegClientCookie(ZMARKET_COOKIE_RANDOMIZE, "Whether weapon randomization is enabled", CookieAccess_Protected);
}
} }
ZMarketLoad() ZMarketLoad()
@ -222,12 +207,6 @@ ZMarketClientInit(client)
// No weapons bought automatically. // No weapons bought automatically.
g_bZMarketWeaponsBought[client] = false; g_bZMarketWeaponsBought[client] = false;
// Clear randomize weapon history.
for (new i = 0; i < 3; i++)
{
g_sZMarketRandomHistoryPrimary[client][i][0] = '\0';
}
} }
/** /**
@ -237,10 +216,6 @@ ZMarketClientInit(client)
*/ */
ZMarketOnCookiesCached(client) ZMarketOnCookiesCached(client)
{ {
decl String:value[4];
GetClientCookie(client, g_hZMarketRandomizeCookie, value, sizeof(value));
g_bZMarketRandomize[client] = (value[0] == '1');
// Rebuy wapons (if auto-rebuy is enabled, and not bought already). // Rebuy wapons (if auto-rebuy is enabled, and not bought already).
if (!g_bZMarketWeaponsBought[client]) if (!g_bZMarketWeaponsBought[client])
{ {
@ -396,7 +371,6 @@ bool:ZMarketMenuMain(client)
decl String:editloadout[MENU_LINE_REG_LENGTH]; decl String:editloadout[MENU_LINE_REG_LENGTH];
decl String:rebuy[MENU_LINE_REG_LENGTH]; decl String:rebuy[MENU_LINE_REG_LENGTH];
decl String:weaponslist[MENU_LINE_REG_LENGTH]; decl String:weaponslist[MENU_LINE_REG_LENGTH];
decl String:randomize[MENU_LINE_REG_LENGTH];
// Format menu options. // Format menu options.
Format(title, sizeof(title), "%t\n ", "Weapons menu zmarket main title"); Format(title, sizeof(title), "%t\n ", "Weapons menu zmarket main title");
@ -404,7 +378,6 @@ bool:ZMarketMenuMain(client)
Format(editloadout, sizeof(editloadout), "%t", "Weapons menu zmarket main edit loadout"); Format(editloadout, sizeof(editloadout), "%t", "Weapons menu zmarket main edit loadout");
Format(rebuy, sizeof(rebuy), "%t", "Weapons menu zmarket main rebuy"); Format(rebuy, sizeof(rebuy), "%t", "Weapons menu zmarket main rebuy");
Format(weaponslist, sizeof(weaponslist), "%t", "Weapons menu zmarket main weapons list"); Format(weaponslist, sizeof(weaponslist), "%t", "Weapons menu zmarket main weapons list");
Format(randomize, sizeof(randomize), "Randomize Weapons: %s", g_bZMarketRandomize[client] ? "ON" : "OFF");
// Add formatted options to menu. // Add formatted options to menu.
SetMenuTitle(menu_zmarket_main, title); SetMenuTitle(menu_zmarket_main, title);
@ -412,7 +385,6 @@ bool:ZMarketMenuMain(client)
AddMenuItem(menu_zmarket_main, "Edit Loadout", editloadout, MenuGetItemDraw(zmarketrebuy || zmarketrebuyauto)); AddMenuItem(menu_zmarket_main, "Edit Loadout", editloadout, MenuGetItemDraw(zmarketrebuy || zmarketrebuyauto));
AddMenuItem(menu_zmarket_main, "Rebuy", rebuy, MenuGetItemDraw(zmarketrebuy || zmarketrebuyauto)); AddMenuItem(menu_zmarket_main, "Rebuy", rebuy, MenuGetItemDraw(zmarketrebuy || zmarketrebuyauto));
AddMenuItem(menu_zmarket_main, "Weapons List", weaponslist); AddMenuItem(menu_zmarket_main, "Weapons List", weaponslist);
AddMenuItem(menu_zmarket_main, "Randomize", randomize);
// Set exit back button. // Set exit back button.
SetMenuExitBackButton(menu_zmarket_main, true); SetMenuExitBackButton(menu_zmarket_main, true);
@ -468,18 +440,6 @@ public ZMarketMenuMainHandle(Handle:menu_zmarket_main, MenuAction:action, client
// Send the weapon types list. // Send the weapon types list.
ZMarketMenuTypes(client); ZMarketMenuTypes(client);
} }
case 4:
{
// Toggle randomize.
g_bZMarketRandomize[client] = !g_bZMarketRandomize[client];
decl String:value[4];
Format(value, sizeof(value), "%d", g_bZMarketRandomize[client] ? 1 : 0);
SetClientCookie(client, g_hZMarketRandomizeCookie, value);
PrintToChat(client, "Weapons zmarket randomize toggled: %s", g_bZMarketRandomize[client] ? "ON" : "OFF");
ZMarketMenuMain(client);
}
} }
} }
// Client closed the menu. // Client closed the menu.
@ -1345,75 +1305,6 @@ stock ZMarketSetRebuyCookie(client, WeaponsSlot:slot, const String:value[])
CloseHandle(rebuycookie); CloseHandle(rebuycookie);
} }
/**
* Picks a random weapon name from the given slot, avoiding the client's
* last 3 picks for the primiary slot.
*
* @param client The client index.
* @param slot Slot_Primary
* @param buffer Output buffer for the weapon name.
* @param maxlen Size of buffer.
*/
stock ZMarketGetRandomWeaponForSlot(client, WeaponsSlot:slot, String:buffer[], maxlen)
{
new Handle:candidates = CreateArray(WEAPONS_MAX_LENGTH);
new size = GetArraySize(arrayWeapons);
decl String:weaponname[WEAPONS_MAX_LENGTH];
for (new i = 0; i < size; i++)
{
if (WeaponsGetSlot(i) != slot)
continue;
WeaponsGetName(i, weaponname, sizeof(weaponname));
// Skip if restricted.
if (RestrictIsWeaponRestricted(i))
continue;
// Skip if in the client's last-3 history for this slot.
new bool:inHistory = false;
for (new h = 0; h < 3; h++)
{
decl String:histEntry[WEAPONS_MAX_LENGTH];
if (slot == Slot_Primary)
strcopy(histEntry, sizeof(histEntry), g_sZMarketRandomHistoryPrimary[client][h]);
if (StrEqual(histEntry, weaponname))
{
inHistory = true;
break;
}
}
if (inHistory)
continue;
PushArrayString(candidates, weaponname);
}
new candidateCount = GetArraySize(candidates);
if (candidateCount == 0)
{
buffer[0] = '\0';
CloseHandle(candidates);
return;
}
new pick = Math_GetRandomInt(0, candidateCount - 1);
GetArrayString(candidates, pick, buffer, maxlen);
CloseHandle(candidates);
// Push into history (shift, then insert at front).
if (slot == Slot_Primary)
{
strcopy(g_sZMarketRandomHistoryPrimary[client][2], WEAPONS_MAX_LENGTH, g_sZMarketRandomHistoryPrimary[client][1]);
strcopy(g_sZMarketRandomHistoryPrimary[client][1], WEAPONS_MAX_LENGTH, g_sZMarketRandomHistoryPrimary[client][0]);
strcopy(g_sZMarketRandomHistoryPrimary[client][0], WEAPONS_MAX_LENGTH, buffer);
}
}
/** /**
* Force a client to rebuy their weapons. * Force a client to rebuy their weapons.
* *
@ -1449,14 +1340,9 @@ ZMarketRebuy(client, bool:autorebuy = false)
// x = Weapon slot. // x = Weapon slot.
for (new x = 0; x < ZMARKET_REBUY_WEAPONS_SLOTS_MAX + 1; x++) for (new x = 0; x < ZMARKET_REBUY_WEAPONS_SLOTS_MAX + 1; x++)
{ {
// If randomize is enabled, override any saved loadout for primary/secondary. // If slot is empty, then use the default value.
if (g_bZMarketRandomize[client] && (x == Slot_Primary || x == Slot_Secondary)) if (!rebuyweapons[x][0])
{ {
ZMarketGetRandomWeaponForSlot(client, WeaponsSlot:x, rebuyweapons[x], sizeof(rebuyweapons[]));
}
else if (!rebuyweapons[x][0])
{
// No saved loadout, fall back to cvar default.
switch(x) switch(x)
{ {
case Slot_Primary: case Slot_Primary: