Add mother zombie infection countdown sound.

This commit is contained in:
BotoX 2020-12-21 09:41:34 +01:00
parent 30a1d4b2ce
commit e73d61fbf3
18 changed files with 212 additions and 9 deletions

View File

@ -478,6 +478,16 @@
"en" "Could not bring back @green{1}@default to life." "en" "Could not bring back @green{1}@default to life."
} }
"CDS enable"
{
"en" "Infect countdown sound enabled."
}
"CDS disable"
{
"en" "Infect countdown sound disabled."
}
// =========================== // ===========================
// Damage (core) // Damage (core)
// =========================== // ===========================
@ -534,6 +544,11 @@
"en" "ZMarket - Customize loadouts here" "en" "ZMarket - Customize loadouts here"
} }
"Menu main cds"
{
"en" "CDS - Toggle infect countdown sound"
}
// =========================== // ===========================
// Weapons (core) // Weapons (core)
// =========================== // ===========================
@ -995,6 +1010,12 @@
"en" "ZMarket Loadout" "en" "ZMarket Loadout"
} }
"ZCookies menu main cds"
{
"#format" "{1:s}"
"en" "Infect Countdown Sound: {1}"
}
// =========================== // ===========================
// ZSpawn (module) // ZSpawn (module)
// =========================== // ===========================

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -351,6 +351,7 @@ public OnClientCookiesCached(client)
ClassOnCookiesCached(client); ClassOnCookiesCached(client);
WeaponsOnCookiesCached(client); WeaponsOnCookiesCached(client);
ZHPOnCookiesCached(client); ZHPOnCookiesCached(client);
InfectOnCookiesCached(client);
} }
/** /**

View File

@ -34,6 +34,7 @@ CookiesInit()
ClassOnCookiesCreate(); ClassOnCookiesCreate();
WeaponsOnCookiesCreate(); WeaponsOnCookiesCreate();
ZHPOnCookiesCreate(); ZHPOnCookiesCreate();
InfectOnCookiesCreate();
} }
/** /**

View File

@ -115,6 +115,7 @@ enum CvarsList
Handle:CVAR_INFECT_MZOMBIE_MIN, Handle:CVAR_INFECT_MZOMBIE_MIN,
Handle:CVAR_INFECT_MZOMBIE_MAX, Handle:CVAR_INFECT_MZOMBIE_MAX,
Handle:CVAR_INFECT_MZOMBIE_COUNTDOWN, Handle:CVAR_INFECT_MZOMBIE_COUNTDOWN,
Handle:CVAR_INFECT_MZOMBIE_COUNTDOWN_SOUND,
Handle:CVAR_INFECT_MZOMBIE_RESPAWN, Handle:CVAR_INFECT_MZOMBIE_RESPAWN,
Handle:CVAR_INFECT_EXPLOSION, Handle:CVAR_INFECT_EXPLOSION,
Handle:CVAR_INFECT_FIREBALL, Handle:CVAR_INFECT_FIREBALL,
@ -333,6 +334,7 @@ CvarsCreate()
g_hCvarsList[CVAR_INFECT_MZOMBIE_MIN] = CreateConVar("zr_infect_mzombie_min", "1", "Minimum number of mother zombies. Range mode only, cannot be zero."); g_hCvarsList[CVAR_INFECT_MZOMBIE_MIN] = CreateConVar("zr_infect_mzombie_min", "1", "Minimum number of mother zombies. Range mode only, cannot be zero.");
g_hCvarsList[CVAR_INFECT_MZOMBIE_MAX] = CreateConVar("zr_infect_mzombie_max", "3", "Maximum number of mother zombies. Range mode only, cannot be zero."); g_hCvarsList[CVAR_INFECT_MZOMBIE_MAX] = CreateConVar("zr_infect_mzombie_max", "3", "Maximum number of mother zombies. Range mode only, cannot be zero.");
g_hCvarsList[CVAR_INFECT_MZOMBIE_COUNTDOWN] = CreateConVar("zr_infect_mzombie_countdown", "0", "Counts down to the first infection of the round. Countdown is printed in the middle of the client's screen."); g_hCvarsList[CVAR_INFECT_MZOMBIE_COUNTDOWN] = CreateConVar("zr_infect_mzombie_countdown", "0", "Counts down to the first infection of the round. Countdown is printed in the middle of the client's screen.");
g_hCvarsList[CVAR_INFECT_MZOMBIE_COUNTDOWN_SOUND] = CreateConVar("zr_infect_mzombie_countdown_sound","0", "Play back countdown sound to clients. [0 = Disabled | 1 = Default Disabled | 2 = Default enabled]");
g_hCvarsList[CVAR_INFECT_MZOMBIE_RESPAWN] = CreateConVar("zr_infect_mzombie_respawn", "0", "Teleport mother zombies back to spawn on infect."); g_hCvarsList[CVAR_INFECT_MZOMBIE_RESPAWN] = CreateConVar("zr_infect_mzombie_respawn", "0", "Teleport mother zombies back to spawn on infect.");
g_hCvarsList[CVAR_INFECT_SPAWNTIME_MIN] = CreateConVar("zr_infect_spawntime_min", "30.0", "Minimum time from the start of the round until picking the mother zombie(s)."); g_hCvarsList[CVAR_INFECT_SPAWNTIME_MIN] = CreateConVar("zr_infect_spawntime_min", "30.0", "Minimum time from the start of the round until picking the mother zombie(s).");
g_hCvarsList[CVAR_INFECT_SPAWNTIME_MAX] = CreateConVar("zr_infect_spawntime_max", "50.0", "Maximum time from the start of the round until picking the mother zombie(s)."); g_hCvarsList[CVAR_INFECT_SPAWNTIME_MAX] = CreateConVar("zr_infect_spawntime_max", "50.0", "Maximum time from the start of the round until picking the mother zombie(s).");

View File

@ -76,6 +76,26 @@ new Handle:g_tInfectCountdown = INVALID_HANDLE;
*/ */
new Handle:g_hInfectCountdownData = INVALID_HANDLE; new Handle:g_hInfectCountdownData = INVALID_HANDLE;
/**
* Name of the cookie for toggle state of the infect countdown sound
*/
#define CDS_COOKIE_ENABLED "zr_cds"
/**
* Number of available/precached infect countdown sounds.
*/
new g_iInfectCountdownSounds = 0;
/**
* Array for storing infect countdown sound client settings.
*/
new g_aInfectCountdownSoundClients[MAXPLAYERS + 1];
/**
* Cookie handle for the toggle state of the countdown sound on a client.
*/
new Handle:g_hInfectCountdownSoundEnabledCookie = INVALID_HANDLE;
/** /**
* Array for flagging client as zombie. * Array for flagging client as zombie.
*/ */
@ -158,6 +178,42 @@ InfectOnLibraryRemoved(const String:name[])
} }
} }
/**
* Create infect-related cookies here.
*/
InfectOnCookiesCreate()
{
// Create cookie handle if it doesn't exist.
if (g_hInfectCountdownSoundEnabledCookie == INVALID_HANDLE)
{
g_hInfectCountdownSoundEnabledCookie = RegClientCookie(CDS_COOKIE_ENABLED, "Toggle infection countdown sound.", CookieAccess_Protected);
}
}
/**
* Called once a client's saved cookies have been loaded from the database.
*
* @param client Client index.
*/
InfectOnCookiesCached(client)
{
// Get default client setting from cvar.
new countdownsound = GetConVarInt(g_hCvarsList[CVAR_INFECT_MZOMBIE_COUNTDOWN_SOUND]);
// Get cds enabled cookie value.
decl String:cdsenabled[8];
GetClientCookie(client, g_hInfectCountdownSoundEnabledCookie, cdsenabled, sizeof(cdsenabled));
// If the cookie is empty, then set the default value.
if (!cdsenabled[0])
{
// Set cookie to default value from cvar.
CookiesSetClientCookieBool(client, g_hInfectCountdownSoundEnabledCookie, countdownsound == 2);
}
g_aInfectCountdownSoundClients[client] = CookiesGetClientCookieBool(client, g_hInfectCountdownSoundEnabledCookie);
}
/** /**
* Map is ending. * Map is ending.
*/ */
@ -187,17 +243,33 @@ InfectLoad()
decl String:sound[PLATFORM_MAX_PATH]; decl String:sound[PLATFORM_MAX_PATH];
GetConVarString(g_hCvarsList[CVAR_INFECT_SOUND], sound, sizeof(sound)); GetConVarString(g_hCvarsList[CVAR_INFECT_SOUND], sound, sizeof(sound));
// If infect sound cvar is empty, then stop. // If infect sound cvar is not empty.
if (!sound[0]) if (sound[0])
{ {
return; // Prepend sound/ to the path.
Format(sound, sizeof(sound), "sound/%s", sound);
// Add sound file to downloads table.
AddFileToDownloadsTable(sound);
} }
// Prepend sound/ to the path. // Precache countdown sounds
Format(sound, sizeof(sound), "sound/%s", sound); int count = 1;
new bool:countdownsound = GetConVarBool(g_hCvarsList[CVAR_INFECT_MZOMBIE_COUNTDOWN_SOUND]);
while (countdownsound)
{
Format(sound, sizeof(sound), "sound/zr/countdown/%i.mp3", count);
if (!FileExists(sound))
break;
// Add sound file to downloads table. AddFileToDownloadsTable(sound);
AddFileToDownloadsTable(sound); ReplaceString(sound, sizeof(sound), "sound/", "");
PrecacheSound(sound);
count++;
g_iInfectCountdownSounds = count;
}
} }
/** /**
@ -207,6 +279,7 @@ InfectOnCommandsCreate()
{ {
RegConsoleCmd("zr_infect", InfectInfectCommand, "Infect a client. Usage: zr_infect <filter> [respawn - 1/0]"); RegConsoleCmd("zr_infect", InfectInfectCommand, "Infect a client. Usage: zr_infect <filter> [respawn - 1/0]");
RegConsoleCmd("zr_human", InfectHumanCommand, "Turn a client into a human. Usage: zr_human <filter> [respawn - 1/0]"); RegConsoleCmd("zr_human", InfectHumanCommand, "Turn a client into a human. Usage: zr_human <filter> [respawn - 1/0]");
RegConsoleCmd(SAYHOOKS_KEYWORD_CDS, CDSCommand, "Toggle infection countdown sound.");
} }
/** /**
@ -266,6 +339,8 @@ InfectClientInit(client)
*/ */
InfectOnClientDisconnect(client) InfectOnClientDisconnect(client)
{ {
g_aInfectCountdownSoundClients[client] = false;
// If client is still connecting, then stop. // If client is still connecting, then stop.
if (!IsClientInGame(client)) if (!IsClientInGame(client))
{ {
@ -796,8 +871,7 @@ InfectMoveAllToCT()
*/ */
public Action:InfectCountdown(Handle:timer) public Action:InfectCountdown(Handle:timer)
{ {
new bool:countdown = GetConVarBool(g_hCvarsList[CVAR_INFECT_MZOMBIE_COUNTDOWN]); if (!GetConVarBool(g_hCvarsList[CVAR_INFECT_MZOMBIE_COUNTDOWN]))
if (!countdown)
{ {
InfectStopCountdown(); InfectStopCountdown();
return Plugin_Stop; return Plugin_Stop;
@ -820,6 +894,27 @@ public Action:InfectCountdown(Handle:timer)
{ {
// Print the countdown text to the clients. // Print the countdown text to the clients.
TranslationPrintCenterTextAll(false, "Infect countdown", RoundToNearest(length - counter)); TranslationPrintCenterTextAll(false, "Infect countdown", RoundToNearest(length - counter));
new bool:countdownsound = GetConVarBool(g_hCvarsList[CVAR_INFECT_MZOMBIE_COUNTDOWN_SOUND]);
new countdown = RoundToNearest(length - counter);
if (countdownsound && g_iInfectCountdownSounds != 0 && countdown > 0 && countdown <= g_iInfectCountdownSounds)
{
decl String:sound[PLATFORM_MAX_PATH];
Format(sound, sizeof(sound), "zr/countdown/%i.mp3", countdown);
int[] clients = new int[MaxClients];
int total = 0;
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && g_aInfectCountdownSoundClients[i])
{
clients[total++] = i;
}
}
if (total)
EmitSound(clients, total, sound);
}
} }
counter++; counter++;
@ -1665,3 +1760,62 @@ InfectMode:InfectGetModeOrFail()
return mode; return mode;
} }
/**
* Command callback (zhp)
* Shows real HP as zombie.
*
* @param client The client index.
* @param argc Argument count.
*/
public Action:CDSCommand(client, argc)
{
// If client is console, then stop and tell them this feature is for players only.
if (ZRIsConsole(client))
{
TranslationPrintToServer("Must be player");
return Plugin_Handled;
}
// Toggle CDS setting.
InfectCountdownSoundToggle(client);
// This stops the "Unknown command" message in client's console.
return Plugin_Handled;
}
/**
* Toggle infect countdown sound on a client.
*
* @param client The client index.
*/
bool:InfectCountdownSoundToggle(client)
{
// If infect countdown sound is disabled, then stop.
new bool:countdownsound = GetConVarBool(g_hCvarsList[CVAR_INFECT_MZOMBIE_COUNTDOWN_SOUND]);
if (!countdownsound)
{
// Tell client feature is disabled.
TranslationPrintToChat(client, "Feature is disabled");
// Stop.
return false;
}
// Toggle the value.
g_aInfectCountdownSoundClients[client] = !g_aInfectCountdownSoundClients[client];
// Store new value.
CookiesSetClientCookieBool(client, g_hInfectCountdownSoundEnabledCookie, !!g_aInfectCountdownSoundClients[client]);
if (g_aInfectCountdownSoundClients[client])
{
TranslationPrintToChat(client, "CDS enable");
}
else
{
TranslationPrintToChat(client, "CDS disable");
}
return true;
}

View File

@ -91,6 +91,7 @@ ZMenuMain(client)
decl String:ztele[MENU_LINE_HUGE_LENGTH]; decl String:ztele[MENU_LINE_HUGE_LENGTH];
decl String:zhp[MENU_LINE_HUGE_LENGTH]; decl String:zhp[MENU_LINE_HUGE_LENGTH];
decl String:zmarket[MENU_LINE_HUGE_LENGTH]; decl String:zmarket[MENU_LINE_HUGE_LENGTH];
decl String:cds[MENU_LINE_HUGE_LENGTH];
// Translate each line into client's language. // Translate each line into client's language.
Format(title, sizeof(title), "%t\n ", "Menu main title", SAYHOOKS_CHAT_PUBLIC_DEFAULT, SAYHOOKS_CHAT_SILENT_DEFAULT); Format(title, sizeof(title), "%t\n ", "Menu main title", SAYHOOKS_CHAT_PUBLIC_DEFAULT, SAYHOOKS_CHAT_SILENT_DEFAULT);
@ -101,6 +102,7 @@ ZMenuMain(client)
Format(ztele, sizeof(ztele), "%t", "Menu main ztele"); Format(ztele, sizeof(ztele), "%t", "Menu main ztele");
Format(zhp, sizeof(zhp), "%t", "Menu main zhp"); Format(zhp, sizeof(zhp), "%t", "Menu main zhp");
Format(zmarket, sizeof(zmarket), "%t", "Menu main zmarket"); Format(zmarket, sizeof(zmarket), "%t", "Menu main zmarket");
Format(cds, sizeof(cds), "%t", "Menu main cds");
// Add items to menu. // Add items to menu.
@ -120,6 +122,9 @@ ZMenuMain(client)
AddMenuItem(menu_main, "zhp", zhp); AddMenuItem(menu_main, "zhp", zhp);
AddMenuItem(menu_main, "zmarket", zmarket); AddMenuItem(menu_main, "zmarket", zmarket);
if (GetConVarBool(g_hCvarsList[CVAR_INFECT_MZOMBIE_COUNTDOWN_SOUND]))
AddMenuItem(menu_main, "cds", cds);
// Display menu to client. // Display menu to client.
DisplayMenu(menu_main, client, MENU_TIME_FOREVER); DisplayMenu(menu_main, client, MENU_TIME_FOREVER);
} }
@ -191,6 +196,11 @@ public ZMenuMainHandle(Handle:menu, MenuAction:action, client, slot)
// Send ZMarket menu. // Send ZMarket menu.
resend = !ZMarketMenuMain(client); resend = !ZMarketMenuMain(client);
} }
// Select CDS.
case 7:
{
InfectCountdownSoundToggle(client);
}
} }
// Resend is still true, then resend menu. // Resend is still true, then resend menu.

View File

@ -51,6 +51,7 @@
#define SAYHOOKS_KEYWORD_ZHP "zhp" #define SAYHOOKS_KEYWORD_ZHP "zhp"
#define SAYHOOKS_KEYWORD_ZMARKET "zmarket" #define SAYHOOKS_KEYWORD_ZMARKET "zmarket"
#define SAYHOOKS_KEYWORD_ZSHIELD "zshield" #define SAYHOOKS_KEYWORD_ZSHIELD "zshield"
#define SAYHOOKS_KEYWORD_CDS "cds"
/** /**
* @endsection * @endsection
*/ */

View File

@ -49,26 +49,31 @@ ZCookiesMenuMain(client)
decl String:zhpenabled[MENU_LINE_SMALL_LENGTH]; decl String:zhpenabled[MENU_LINE_SMALL_LENGTH];
decl String:overlayenabled[MENU_LINE_SMALL_LENGTH]; decl String:overlayenabled[MENU_LINE_SMALL_LENGTH];
decl String:cdsenabled[MENU_LINE_SMALL_LENGTH];
// Get the current toggle state of the cookies. // Get the current toggle state of the cookies.
ConfigBoolToSetting(CookiesGetClientCookieBool(client, g_hZHPEnabledCookie), zhpenabled, sizeof(zhpenabled), false, client); ConfigBoolToSetting(CookiesGetClientCookieBool(client, g_hZHPEnabledCookie), zhpenabled, sizeof(zhpenabled), false, client);
ConfigBoolToSetting(CookiesGetClientCookieBool(client, g_hOverlayEnabledCookie), overlayenabled, sizeof(overlayenabled), false, client); ConfigBoolToSetting(CookiesGetClientCookieBool(client, g_hOverlayEnabledCookie), overlayenabled, sizeof(overlayenabled), false, client);
ConfigBoolToSetting(CookiesGetClientCookieBool(client, g_hInfectCountdownSoundEnabledCookie), cdsenabled, sizeof(cdsenabled), false, client);
decl String:title[MENU_LINE_TITLE_LENGTH]; decl String:title[MENU_LINE_TITLE_LENGTH];
decl String:zhp[MENU_LINE_REG_LENGTH]; decl String:zhp[MENU_LINE_REG_LENGTH];
decl String:overlay[MENU_LINE_REG_LENGTH]; decl String:overlay[MENU_LINE_REG_LENGTH];
decl String:zmarket[MENU_LINE_REG_LENGTH]; decl String:zmarket[MENU_LINE_REG_LENGTH];
decl String:cds[MENU_LINE_REG_LENGTH];
// Translate each line into client's language. // Translate each line into client's language.
Format(title, sizeof(title), "%t\n ", "ZCookies Menu main title"); Format(title, sizeof(title), "%t\n ", "ZCookies Menu main title");
Format(zhp, sizeof(zhp), "%t", "ZCookies menu main zhp", zhpenabled); Format(zhp, sizeof(zhp), "%t", "ZCookies menu main zhp", zhpenabled);
Format(overlay, sizeof(overlay), "%t", "ZCookies menu main overlay", overlayenabled); Format(overlay, sizeof(overlay), "%t", "ZCookies menu main overlay", overlayenabled);
Format(zmarket, sizeof(zmarket), "%t", "ZCookies zmarket loadout"); Format(zmarket, sizeof(zmarket), "%t", "ZCookies zmarket loadout");
Format(cds, sizeof(cds), "%t", "ZCookies menu main cds", cdsenabled);
// Get conditional values for each option. // Get conditional values for each option.
new bool:zhpcvar = GetConVarBool(g_hCvarsList[CVAR_ZHP]); // For ZHP. new bool:zhpcvar = GetConVarBool(g_hCvarsList[CVAR_ZHP]); // For ZHP.
new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]); // For class overlay. new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]); // For class overlay.
new bool:zmarketenabled = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET]); // For ZMarket loadout. new bool:zmarketenabled = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET]); // For ZMarket loadout.
new bool:cdscvar = GetConVarBool(g_hCvarsList[CVAR_INFECT_MZOMBIE_COUNTDOWN_SOUND]); // For infect countdown sound.
// Add items to menu. // Add items to menu.
SetMenuTitle(zcookies_menu_main, title); SetMenuTitle(zcookies_menu_main, title);
@ -76,6 +81,9 @@ ZCookiesMenuMain(client)
AddMenuItem(zcookies_menu_main, "overlay", overlay, MenuGetItemDraw(overlaytoggle)); AddMenuItem(zcookies_menu_main, "overlay", overlay, MenuGetItemDraw(overlaytoggle));
AddMenuItem(zcookies_menu_main, "zmarket", zmarket, MenuGetItemDraw(zmarketenabled)); AddMenuItem(zcookies_menu_main, "zmarket", zmarket, MenuGetItemDraw(zmarketenabled));
if (GetConVarBool(g_hCvarsList[CVAR_INFECT_MZOMBIE_COUNTDOWN_SOUND]))
AddMenuItem(zcookies_menu_main, "cds", cds, MenuGetItemDraw(cdscvar));
// Create a "Back" button to the main menu. // Create a "Back" button to the main menu.
SetMenuExitBackButton(zcookies_menu_main, true); SetMenuExitBackButton(zcookies_menu_main, true);
@ -127,6 +135,11 @@ public ZCookiesMenuMainHandle(Handle:menu, MenuAction:action, client, slot)
// Don't resend ZCookies. // Don't resend ZCookies.
resend = false; resend = false;
} }
// Toggled infect countdown sound.
case 3:
{
InfectCountdownSoundToggle(client);
}
} }
if (resend) if (resend)