From 681ad453651e5de4769a2c8ca19cf57ef13497e3 Mon Sep 17 00:00:00 2001 From: Greyscale Date: Wed, 17 Jun 2009 14:32:46 -0700 Subject: [PATCH] Recoded sayhooks, now uses SM's silent/public chat triggers. Began making set functions for the commands that will use them later. Removed all sayhook cvars. --- .../translations/zombiereloaded.phrases.txt | 21 +- .../zombiereloaded/zombiereloaded.cfg | 25 --- src/zombiereloaded.sp | 2 - src/zr/commands.inc | 5 + src/zr/config.inc | 8 +- src/zr/cvars.inc | 10 - src/zr/event.inc | 13 +- src/zr/hitgroups.inc | 38 +++- src/zr/menu.inc | 53 ++++- src/zr/playerclasses/classcommands.inc | 26 +++ src/zr/roundstart.inc | 3 + src/zr/sayhooks.inc | 212 ++++++------------ src/zr/weapons/weapons.inc | 1 + src/zr/weapons/zmarket.inc | 45 ++-- src/zr/zadmin.inc | 49 ++++ src/zr/zhp.inc | 32 +++ src/zr/zspawn.inc | 32 +++ src/zr/ztele.inc | 32 +++ 18 files changed, 376 insertions(+), 231 deletions(-) diff --git a/cstrike/addons/sourcemod/translations/zombiereloaded.phrases.txt b/cstrike/addons/sourcemod/translations/zombiereloaded.phrases.txt index 1dac21e..cc88436 100644 --- a/cstrike/addons/sourcemod/translations/zombiereloaded.phrases.txt +++ b/cstrike/addons/sourcemod/translations/zombiereloaded.phrases.txt @@ -7,13 +7,12 @@ "General round objective" { "en" "The game is @greenHumans vs. Zombies@default, the goal for zombies is to infect all humans by knifing them." - "ru" "Битва @greenЛюдей против Зомби@default, цель для зомби - инфицировать всех людей." } "General zmenu reminder" { - "en" "For help on Zombie:Reloaded commands, type !zmenu in chat." - "ru" "Напишите !zmenu в чате для просмотра всех команд." + "#format" "{1:s},{2:s}" + "en" "For help on Zombie:Reloaded commands, type \"{1}{2}\" in chat." } // =========================== @@ -303,44 +302,44 @@ "Menu main title" { - "en" "ZR Commands:" - "ru" "ZR Команды:" + "#format" "{1:s},{2:s}" + "en" "ZR Commands:\nPrefix command with \"{1}\" or \"{2}\" (quiet) when typing in chat." } "Menu main zadmin" { "#format" "{1:s}" - "en" "ZAdmin ({1}) - Open admin menu." + "en" "ZAdmin - Open admin menu. (Command: {1})" } "Menu main zclass" { "#format" "{1:s}" - "en" "ZClass ({1}) - Configure your class settings." + "en" "ZClass - Configure your class settings.(Command: {1})" } "Menu main zspawn" { "#format" "{1:s}" - "en" "ZSpawn ({1}) - Join late? Use this to spawn." + "en" "ZSpawn - Join late? Use this to spawn.(Command: {1})" } "Menu main ztele" { "#format" "{1:s}" - "en" "ZTele ({1}) - Teleport back to your spawn location." + "en" "ZTele - Teleport back to your spawn location.(Command: {1})" } "Menu main zhp" { "#format" "{1:s}" - "en" "ZHP ({1}) - Toggle real HP display when infected." + "en" "ZHP - Toggle real HP display when infected.(Command: {1})" } "Menu main zmarket" { "#format" "{1:s}" - "en" "ZMarket ({1}) - Need a weapon? Buy them here." + "en" "ZMarket - Need a weapon? Buy them here.(Command: {1})" } // =========================== diff --git a/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg b/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg index 6fec9c4..cdaa541 100644 --- a/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg +++ b/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg @@ -302,31 +302,6 @@ zr_damage_suicide_human "1" // Default: "kill, spectate, jointeam" zr_damage_suicide_cmds "kill, spectate, jointeam" // ---------------------------------------------------------------------------- -// Say Hooks (core) -// ---------------------------------------------------------------------------- -// Stop certain in-game commands from appearing in chat. [See zr_sayhooks_quiet_filter&zr_sayhooks_quiet_flags] -// Default: "1" -zr_sayhooks_quiet "1" - -// Stops any failed in-game command from showing in chat. Ex: Typing !zspawn while alive. [Dependency: zr_sayhooks_quiet] -// Default: "1" -zr_sayhooks_quiet_filter "1" - -// Flag separate in-game commands to always hide from chat. [Dependency: zr_sayhooks_quiet] -// In-Game Command Flags: -// * Add numbers of desired flags together to produce final flag value. -// -------------------------------------------------------------------- -// 1: !zmenu [] -// 2: !zadmin [X] -// 4: !zclass [] -// 8: !zspawn [X] -// 16: !ztele [X] -// 32: !zhp [X] -// 64: !zmarket [] -// -// Default: "58" (Have [X] at the end) -zr_sayhooks_quiet_flags "58" -// ---------------------------------------------------------------------------- // Overlays (core) // ---------------------------------------------------------------------------- // How often to update overlays on players. [0.0 = Disabled] diff --git a/src/zombiereloaded.sp b/src/zombiereloaded.sp index 3e1189c..0a16839 100644 --- a/src/zombiereloaded.sp +++ b/src/zombiereloaded.sp @@ -118,9 +118,7 @@ public OnPluginStart() ToolsInit(); CommandsInit(); WeaponsInit(); - SayHooksInit(); EventInit(); - ZMarketInit(); } /** diff --git a/src/zr/commands.inc b/src/zr/commands.inc index f4465d2..b3749aa 100644 --- a/src/zr/commands.inc +++ b/src/zr/commands.inc @@ -36,6 +36,11 @@ CommandsInit() ClassOnCommandsCreate(); WeaponsOnCommandsCreate(); InfectOnCommandsCreate(); + MenuOnCommandsCreate(); + ZAdminOnCommandsCreate(); + ZSpawnOnCommandsCreate(); + ZTeleOnCommandsCreate(); + ZHPOnCommandsCreate(); VolOnCommandsCreate(); // Forward event to modules. (hook commands) diff --git a/src/zr/config.inc b/src/zr/config.inc index d20d489..f59f4ae 100644 --- a/src/zr/config.inc +++ b/src/zr/config.inc @@ -175,10 +175,10 @@ new g_ConfigData[ConfigFile][ConfigData]; */ enum ConfigKvAction { - KvAction_Create, /** Create a key. */ - KvAction_KVDelete, /** Delete a key. */ - KvAction_KVSet, /** Modify setting of a key. */ - KvAction_KVGet, /** Get setting of a key. */ + KvAction_Create, /** Create a key. */ + KvAction_KVDelete, /** Delete a key. */ + KvAction_KVSet, /** Modify setting of a key. */ + KvAction_KVGet, /** Get setting of a key. */ } /** diff --git a/src/zr/cvars.inc b/src/zr/cvars.inc index f121913..09350dd 100644 --- a/src/zr/cvars.inc +++ b/src/zr/cvars.inc @@ -305,16 +305,6 @@ CvarsCreate() g_hCvarsList[CVAR_DAMAGE_SUICIDE_HUMAN] = CreateConVar("zr_damage_suicide_human", "1", "Intercept suicide commands attempted by humans."); g_hCvarsList[CVAR_DAMAGE_SUICIDE_CMDS] = CreateConVar("zr_damage_suicide_cmds", "kill, spectate, jointeam", "List of client commands to intercept as suicide attempts. [Delimiter: \", \"]"); - - // =========================== - // Say Hooks (core) - // =========================== - g_hCvarsList[CVAR_SAYHOOKS_QUIET] = CreateConVar("zr_sayhooks_quiet", "1", "Stop certain in-game commands from appearing in chat. [See zr_sayhooks_quiet_filter&zr_sayhooks_quiet_flags]"); - g_hCvarsList[CVAR_SAYHOOKS_QUIET_FILTER] = CreateConVar("zr_sayhooks_quiet_filter", "1", "Stops any failed in-game command from showing in chat. Ex: Typing !zspawn while alive. [Dependency: zr_sayhooks_quiet]"); - g_hCvarsList[CVAR_SAYHOOKS_QUIET_FLAGS] = CreateConVar("zr_sayhooks_quiet_flags", "58", "Flag separate in-game commands to always hide from chat. [Dependency: zr_sayhooks_quiet]\n In-Game Command Flags:\n * Add numbers of desired flags together to produce final flag value.\n --------------------------------------------------------------------\n 1: !zmenu\n 2: !zadmin\n 4: !zclass\n 8: !zspawn\n 16: !ztele\n 32: !zhp\n 64: !zmarket"); - // Flags (default: 2 + 8 + 16 + 32) - - // =========================== // Overlays (core) // =========================== diff --git a/src/zr/event.inc b/src/zr/event.inc index bfa94de..9400637 100644 --- a/src/zr/event.inc +++ b/src/zr/event.inc @@ -81,9 +81,6 @@ EventHook(bool:unhook = false) */ public Action:EventRoundStart(Handle:event, const String:name[], bool:dontBroadcast) { - // Print round objective to all clients. - TranslationPrintToChatAll(true, false, "General round objective"); - // Forward event to sub-modules. OverlaysOnRoundStart(); RoundStartOnRoundStart(); @@ -196,7 +193,15 @@ public Action:EventPlayerSpawn(Handle:event, const String:name[], bool:dontBroad ZHPOnClientSpawn(index); VolOnPlayerSpawn(index); - TranslationPrintToChat(index, "General zmenu reminder"); + // Get public chat trigger prefix. + decl String:publictrigger[4]; + SayHooksGetPublicChatTrigger(publictrigger, sizeof(publictrigger)); + + // If public chat trigger is disabled, then don't print message. + if (!StrEqual(publictrigger, "N/A", false)) + { + TranslationPrintToChat(index, "General zmenu reminder", publictrigger, SAYHOOKS_KEYWORD_ZMENU); + } // Fire post player_spawn event. CreateTimer(0.0, EventPlayerSpawnPost, index); diff --git a/src/zr/hitgroups.inc b/src/zr/hitgroups.inc index 115a17a..a4de4e8 100644 --- a/src/zr/hitgroups.inc +++ b/src/zr/hitgroups.inc @@ -212,7 +212,7 @@ stock HitgroupToIndex(hitgroup) } /** - * Gets the name of a hitgroup at a given index. + * Gets the name of a hitgroup at a given index. (static) * @param index The hitgroup index. * @param hitgroup The string to return name in. * @param maxlen The max length of the string. @@ -227,7 +227,7 @@ stock HitgroupsGetName(index, String:hitgroup[], maxlen) } /** - * Retrieve hitgroup index. + * Retrieve hitgroup index. (static) * * @param index The array index. * @return The hitgroup index. @@ -242,7 +242,22 @@ stock HitgroupsGetIndex(index) } /** - * Retrieve hitgroup damage value. + * Set hitgroup damage value. (dynamic) + * + * @param index The array index. + * @param candamage True to allow damage to hitgroup, false to block damage. + */ +stock HitgroupsSetDamage(index, bool:candamage) +{ + // Get array handle of hitgroup at given index. + new Handle:arrayHitgroup = GetArrayCell(arrayHitgroups, index); + + // Return true if hitgroup can be damaged, false if not. + SetArrayCell(arrayHitgroup, _:HITGROUPS_DATA_DAMAGE, candamage); +} + +/** + * Retrieve hitgroup damage value. (dynamic) * * @param index The array index. * @return True if hitgroup can be damaged, false if not. @@ -257,7 +272,22 @@ stock bool:HitgroupsCanDamage(index) } /** - * Retrieve hitgroup knockback value. + * Set hitgroup knockback value. (dynamic) + * + * @param index The array index. + * @param knockback The knockback multiplier for the hitgroup. + */ +stock HitgroupsSetKnockback(index, Float:knockback) +{ + // Get array handle of hitgroup at given index. + new Handle:arrayHitgroup = GetArrayCell(arrayHitgroups, index); + + // Return the knockback multiplier for the hitgroup. + SetArrayCell(arrayHitgroup, _:HITGROUPS_DATA_KNOCKBACK, knockback); +} + +/** + * Retrieve hitgroup knockback value. (dynamic) * * @param index The array index. * @return The knockback multiplier of the hitgroup. diff --git a/src/zr/menu.inc b/src/zr/menu.inc index be40ccb..c409e76 100644 --- a/src/zr/menu.inc +++ b/src/zr/menu.inc @@ -25,6 +25,38 @@ * ============================================================================ */ +/** + * Create commands specific to ZMenu. + */ +MenuOnCommandsCreate() +{ + // Register ZMenu command. + RegConsoleCmd(SAYHOOKS_KEYWORD_ZMENU, ZMenuCommand, "Opens ZR's main menu."); +} + +/** + * Command callback (zmenu) + * Opens ZR's main menu. + * + * @param client The client index. + * @param argc Argument count. + */ +public Action:ZMenuCommand(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; + } + + // Send main menu. + MenuMain(client); + + // This stops the "Unknown command" message in client's console. + return Plugin_Handled; +} + /** * Show main menu to client. * @@ -38,16 +70,23 @@ MenuMain(client) // Make client global translations target. SetGlobalTransTarget(client); + decl String:publictrigger[4]; + decl String:silenttrigger[4]; + + // Get public/silent chat triggers. + SayHooksGetPublicChatTrigger(publictrigger, sizeof(publictrigger)); + SayHooksGetSilentChatTrigger(silenttrigger, sizeof(silenttrigger)); + // Set menu title. - SetMenuTitle(menu_main, "%t\n ", "Menu main title"); + SetMenuTitle(menu_main, "%t\n ", "Menu main title", publictrigger, silenttrigger); // Initialize menu lines. - decl String:zadmin[64]; - decl String:zclass[64]; - decl String:zspawn[64]; - decl String:ztele[64]; - decl String:zhp[64]; - decl String:zmarket[64]; + decl String:zadmin[256]; + decl String:zclass[256]; + decl String:zspawn[256]; + decl String:ztele[256]; + decl String:zhp[256]; + decl String:zmarket[256]; // Translate each line into client's language. Format(zadmin, sizeof(zadmin), "%t", "Menu main zadmin", SAYHOOKS_KEYWORD_ZMENU); diff --git a/src/zr/playerclasses/classcommands.inc b/src/zr/playerclasses/classcommands.inc index 23dc0be..8f937c8 100644 --- a/src/zr/playerclasses/classcommands.inc +++ b/src/zr/playerclasses/classcommands.inc @@ -27,6 +27,9 @@ ClassOnCommandsCreate() { + // Register ZClass command. + RegConsoleCmd(SAYHOOKS_KEYWORD_ZCLASS, ZClassCommand, "Opens class selection menu."); + // Create base class commands. RegConsoleCmd("zr_class_dump", ClassDumpCommand, "Dumps class data at a specified index in the specified cache. Usage: zr_class_dump "); RegAdminCmd("zr_class_modify", ClassModifyCommand, ADMFLAG_GENERIC, "Modify class data on one or more classes. Usage: zr_class_modify [is_multiplier]"); @@ -41,6 +44,29 @@ ClassOnCommandsHook() ClassOverlayOnCommandsHook(); } +/** + * Command callback (zclass) + * Opens class selection menu. + * + * @param client The client index. + * @param argc Argument count. + */ +public Action:ZClassCommand(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; + } + + // Send class menu. + ClassMenuMain(client); + + // This stops the "Unknown command" message in client's console. + return Plugin_Handled; +} + /** * Command callback. (zr_class_dump) * Dumps class data at a specified index in the specified cache. diff --git a/src/zr/roundstart.inc b/src/zr/roundstart.inc index 9bd438d..afeaf0c 100644 --- a/src/zr/roundstart.inc +++ b/src/zr/roundstart.inc @@ -35,6 +35,9 @@ */ RoundStartOnRoundStart() { + // Print round objective to all clients. + TranslationPrintToChatAll(true, false, "General round objective"); + // Kill all objective entities. RoundStartKillObjectives(); } diff --git a/src/zr/sayhooks.inc b/src/zr/sayhooks.inc index 3c97414..48639cc 100644 --- a/src/zr/sayhooks.inc +++ b/src/zr/sayhooks.inc @@ -25,6 +25,17 @@ * ============================================================================ */ +/** + * @section SM core config info. + */ +#define SAYHOOKS_CORE_KVNAME "Core" +#define SAYHOOKS_CORE_KVPATH "configs/core.cfg" +#define SAYHOOKS_CHAT_PUBLIC_DEFAULT "!" +#define SAYHOOKS_CHAT_SILENT_DEFAULT "/" +/** + * @endsection + */ + /** * Max number of characters in a chat text string. */ @@ -33,176 +44,85 @@ /** * @section Say command key words. */ -#define SAYHOOKS_KEYWORD_ZMENU "!zmenu" -#define SAYHOOKS_KEYWORD_ZADMIN "!zadmin" -#define SAYHOOKS_KEYWORD_ZCLASS "!zclass" -#define SAYHOOKS_KEYWORD_ZSPAWN "!zspawn" -#define SAYHOOKS_KEYWORD_ZTELE "!ztele" -#define SAYHOOKS_KEYWORD_ZHP "!zhp" -#define SAYHOOKS_KEYWORD_ZMARKET "!zmarket" +#define SAYHOOKS_KEYWORD_ZMENU "zmenu" +#define SAYHOOKS_KEYWORD_ZADMIN "zadmin" +#define SAYHOOKS_KEYWORD_ZCLASS "zclass" +#define SAYHOOKS_KEYWORD_ZSPAWN "zspawn" +#define SAYHOOKS_KEYWORD_ZTELE "ztele" +#define SAYHOOKS_KEYWORD_ZHP "zhp" +#define SAYHOOKS_KEYWORD_ZMARKET "zmarket" /** * @endsection */ /** - * @section Say hook quiet flags. - */ -#define SAYHOOKS_KEYWORD_FLAG_ZMENU 1 -#define SAYHOOKS_KEYWORD_FLAG_ZADMIN 2 -#define SAYHOOKS_KEYWORD_FLAG_ZCLASS 4 -#define SAYHOOKS_KEYWORD_FLAG_ZSPAWN 8 -#define SAYHOOKS_KEYWORD_FLAG_ZTELE 16 -#define SAYHOOKS_KEYWORD_FLAG_ZHP 32 -#define SAYHOOKS_KEYWORD_FLAG_ZMARKET 64 -/** - * @endsection - */ - -/** - * Say hooks module init function. - */ -SayHooksInit() -{ - // Hook client's say commands. - RegConsoleCmd("say", SayHooksCmdSay); - RegConsoleCmd("say_team", SayHooksCmdSay); -} - -/** - * Command callback. (say, say_team) - * Catches all client's say text and takes action on key words. + * Hack function to get the public chat trigger value. * - * @param client The client index. - * @param argc The number of arguments in command string. + * @param trigger The string to store value in. + * @param maxlen The maximum length of the string. */ -public Action:SayHooksCmdSay(client, argc) +SayHooksGetPublicChatTrigger(String:trigger[], maxlen) { - decl String:args[SAYHOOKS_MAX_CHAT_LENGTH]; + // Create kv handle. + new Handle:kvCore = CreateKeyValues(SAYHOOKS_CORE_KVNAME); - // Get client's command string (typically 'say "text"') - GetCmdArgString(args, sizeof(args)); + // Build path to file. + decl String:filepath[PLATFORM_MAX_PATH]; + BuildPath(Path_SM, filepath, PLATFORM_MAX_PATH, SAYHOOKS_CORE_KVPATH); - // Strip away certain characters. - ReplaceString(args, sizeof(args), "\"", ""); // Strip quotes - ReplaceString(args, sizeof(args), " ", ""); // Strip all whitespace. + // Load kv into memory. + new bool:success = FileToKeyValues(kvCore, filepath); - new chatflag = SayHooksChatToFlag(args); - - // If chatflag is invalid, then continue. - if (!chatflag) + // If the file couldn't be loaded, then return the default value. + if (!success) { - return Plugin_Continue; + strcopy(trigger, maxlen, SAYHOOKS_CHAT_PUBLIC_DEFAULT); + return; } - // Define success as true until otherwise changed. - new bool:success = true; + // Rewind and find value. + KvRewind(kvCore); + KvGetString(kvCore, "PublicChatTrigger", trigger, maxlen, SAYHOOKS_CHAT_PUBLIC_DEFAULT); - switch(chatflag) + // If trigger is disabled, then display as "N/A". + if (!trigger[0]) { - // Client triggered ZMenu flag. - case SAYHOOKS_KEYWORD_FLAG_ZMENU: - { - // Send main menu. - MenuMain(client); - } - // Client triggered ZAdmin flag. - case SAYHOOKS_KEYWORD_FLAG_ZADMIN: - { - success = ZRAdminMenu(client); - } - // Client triggered ZClass flag. - case SAYHOOKS_KEYWORD_FLAG_ZCLASS: - { - // Send class menu. - ClassMenuMain(client); - } - // Client triggered ZSpawn flag. - case SAYHOOKS_KEYWORD_FLAG_ZSPAWN: - { - // Spawns a late-joining client into the game. - success = ZSpawnClient(client); - } - // Client triggered ZTele flag. - case SAYHOOKS_KEYWORD_FLAG_ZTELE: - { - success = ZTeleClient(client); - } - // Client triggered ZHP flag. - case SAYHOOKS_KEYWORD_FLAG_ZHP: - { - // Toggle ZHP. - success = ZHPToggle(client); - } - // Client triggered ZMarket flag. - case SAYHOOKS_KEYWORD_FLAG_ZMARKET: - { - success = ZMarketMenuTypes(client); - } + strcopy(trigger, maxlen, "N/A"); } - - // If quiet cvar is disabled, then continue. - new bool:quiet = GetConVarBool(g_hCvarsList[CVAR_SAYHOOKS_QUIET]); - if (!quiet) - { - return Plugin_Continue; - } - - // If filter is enabled, and the command failed to be executed, then stop. - new bool:filter = GetConVarBool(g_hCvarsList[CVAR_SAYHOOKS_QUIET_FILTER]); - if (filter && !success) - { - return Plugin_Handled; - } - - // If word is flagged to be quieted, then stop. - new quietflags = GetConVarInt(g_hCvarsList[CVAR_SAYHOOKS_QUIET_FLAGS]); - if (quietflags & chatflag) - { - return Plugin_Handled; - } - - return Plugin_Continue; } /** - * Convert chat text into a defined flag. + * Hack function to get the silent chat trigger value. * - * @param chat The chat text to convert. - * @return Returns flag for word given, returns 0 if matches none. + * @param trigger The string to store value in. + * @param maxlen The maximum length of the string. */ -SayHooksChatToFlag(const String:chat[]) +SayHooksGetSilentChatTrigger(String:trigger[], maxlen) { - // Return flag for chatstring. + // Create kv handle. + new Handle:kvCore = CreateKeyValues(SAYHOOKS_CORE_KVNAME); - if (StrEqual(chat, SAYHOOKS_KEYWORD_ZMENU, false)) + // Build path to file. + decl String:filepath[PLATFORM_MAX_PATH]; + BuildPath(Path_SM, filepath, PLATFORM_MAX_PATH, SAYHOOKS_CORE_KVPATH); + + // Load kv into memory. + new bool:success = FileToKeyValues(kvCore, filepath); + + // If the file couldn't be loaded, then return the default value. + if (!success) { - return SAYHOOKS_KEYWORD_FLAG_ZMENU; - } - else if (StrEqual(chat, SAYHOOKS_KEYWORD_ZADMIN, false)) - { - return SAYHOOKS_KEYWORD_FLAG_ZADMIN; - } - else if (StrEqual(chat, SAYHOOKS_KEYWORD_ZCLASS, false)) - { - return SAYHOOKS_KEYWORD_FLAG_ZCLASS; - } - else if (StrEqual(chat, SAYHOOKS_KEYWORD_ZSPAWN, false)) - { - return SAYHOOKS_KEYWORD_FLAG_ZSPAWN; - } - else if (StrEqual(chat, SAYHOOKS_KEYWORD_ZTELE, false)) - { - return SAYHOOKS_KEYWORD_FLAG_ZTELE; - } - else if (StrEqual(chat, SAYHOOKS_KEYWORD_ZHP, false)) - { - return SAYHOOKS_KEYWORD_FLAG_ZHP; - } - else if (StrEqual(chat, SAYHOOKS_KEYWORD_ZMARKET, false)) - { - return SAYHOOKS_KEYWORD_FLAG_ZMARKET; + strcopy(trigger, maxlen, SAYHOOKS_CHAT_SILENT_DEFAULT); + return; } - // Return 0. - return 0; -} + // Rewind and find value. + KvRewind(kvCore); + KvGetString(kvCore, "SilentChatTrigger", trigger, maxlen, SAYHOOKS_CHAT_SILENT_DEFAULT); + + // If trigger is disabled, then display as "N/A". + if (!trigger[0]) + { + strcopy(trigger, maxlen, "N/A"); + } +} \ No newline at end of file diff --git a/src/zr/weapons/weapons.inc b/src/zr/weapons/weapons.inc index fa1e17c..a2e0df8 100644 --- a/src/zr/weapons/weapons.inc +++ b/src/zr/weapons/weapons.inc @@ -118,6 +118,7 @@ WeaponsOnCommandsCreate() { // Forward event to sub-modules. RestrictOnCommandsCreate(); + ZMarketOnCommandsCreate(); } /** diff --git a/src/zr/weapons/zmarket.inc b/src/zr/weapons/zmarket.inc index 598a7b7..d342a35 100644 --- a/src/zr/weapons/zmarket.inc +++ b/src/zr/weapons/zmarket.inc @@ -25,22 +25,6 @@ * ============================================================================ */ -/* * Copyright (C) 2009 Greyscale, Richard Helgeby - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - **/ - /** * Variable to store buyzone offset value. */ @@ -67,10 +51,12 @@ new String:g_strZMarketLastWeapon[MAXPLAYERS + 1][WeaponsSlot][WEAPONS_MAX_LENGT new bool:g_bZMarketAutoRebuy[MAXPLAYERS + 1]; /** - * Initialize market data. + * Create commands specific to ZMarket. */ -ZMarketInit() +ZMarketOnCommandsCreate() { + // Register ZMarket command. + RegConsoleCmd(SAYHOOKS_KEYWORD_ZMARKET, ZMarketCommand, "Opens custom buymenu."); } /** @@ -684,6 +670,29 @@ ZMarketRebuy(client, bool:rebuy = false) } } +/** + * Command callback (zmarket) + * Opens custom buymenu. + * + * @param client The client index. + * @param argc Argument count. + */ +public Action:ZMarketCommand(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; + } + + // Send ZMarket menu. + ZMarketMenuTypes(client); + + // This stops the "Unknown command" message in client's console. + return Plugin_Handled; +} + /** * Checks if a client is in a buyzone. * diff --git a/src/zr/zadmin.inc b/src/zr/zadmin.inc index 16e4172..7ac31a2 100644 --- a/src/zr/zadmin.inc +++ b/src/zr/zadmin.inc @@ -25,16 +25,56 @@ * ============================================================================ */ +/** + * Create commands specific to ZAdmin. + */ +ZAdminOnCommandsCreate() +{ + // Register ZAdmin command. + RegConsoleCmd(SAYHOOKS_KEYWORD_ZADMIN, ZAdminCommand, "Opens ZR admin menu."); +} + +/** + * Command callback (zadmin) + * Opens ZR admin menu. + * + * @param client The client index. + * @param argc Argument count. + */ +public Action:ZAdminCommand(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; + } + + // Send admin menu. + ZRAdminMenu(client); + + // This stops the "Unknown command" message in client's console. + return Plugin_Handled; +} + +/** + * Main admin menu. + * + * @param client The client index. + */ bool:ZRAdminMenu(client) { + // If client isn't an admin, then stop. if (!ZRIsClientAdmin(client)) { TranslationPrintToChat(client, "Must be admin"); return false; } + // Create menu handle. new Handle:menu_zadmin = CreateMenu(ZRAdminMenuHandle); + // Set translation target as the client. SetGlobalTransTarget(client); SetMenuTitle(menu_zadmin, "%t\n ", "!zadmin main title"); @@ -72,6 +112,15 @@ bool:ZRAdminMenu(client) return true; } +/** + * Menu callback (zadmin) + * Handles options selected in the admin menu. + * + * @param menu The menu handle. + * @param action Action client is doing in menu. + * @param client The client index. + * @param slot The menu slot selected. (starting from 0) + */ public ZRAdminMenuHandle(Handle:menu_admin, MenuAction:action, client, slot) { if (action == MenuAction_Select) diff --git a/src/zr/zhp.inc b/src/zr/zhp.inc index 1870cd4..226e5d9 100644 --- a/src/zr/zhp.inc +++ b/src/zr/zhp.inc @@ -35,6 +35,15 @@ new Handle:tZHP[MAXPLAYERS + 1]; */ new bool:pZHP[MAXPLAYERS + 1]; +/** + * Create commands specific to ZHP. + */ +ZHPOnCommandsCreate() +{ + // Register ZHP command. + RegConsoleCmd(SAYHOOKS_KEYWORD_ZHP, ZHPCommand, "Shows real HP as zombie."); +} + /** * Client is joining the server. * @@ -204,6 +213,29 @@ ZHPUpdateHUD(client) TranslationPrintHUDText(client, "Display HP", health); } +/** + * Command callback (zhp) + * Shows real HP as zombie. + * + * @param client The client index. + * @param argc Argument count. + */ +public Action:ZHPCommand(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 ZHP setting. + ZHPToggle(client); + + // This stops the "Unknown command" message in client's console. + return Plugin_Handled; +} + /** * Timer callback. Repetitively calls ZHPUpdateHUD() until stopped. * diff --git a/src/zr/zspawn.inc b/src/zr/zspawn.inc index 5e6fd5c..029f46c 100644 --- a/src/zr/zspawn.inc +++ b/src/zr/zspawn.inc @@ -30,6 +30,15 @@ */ new Handle:tZSpawn = INVALID_HANDLE; +/** + * Create commands specific to ZSpawn. + */ +ZSpawnOnCommandsCreate() +{ + // Register ZSpawn command. + RegConsoleCmd(SAYHOOKS_KEYWORD_ZSPAWN, ZSpawnCommand, "Spawn into the game after joining late."); +} + /** * Map is starting. */ @@ -215,6 +224,29 @@ bool:ZSpawnClient(client) return true; } +/** + * Command callback (zspawn) + * Spawn into the game after joining late. + * + * @param client The client index. + * @param argc Argument count. + */ +public Action:ZSpawnCommand(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; + } + + // Spawn client. + ZSpawnClient(client); + + // This stops the "Unknown command" message in client's console. + return Plugin_Handled; +} + /** * Timer callback, resets handle. * diff --git a/src/zr/ztele.inc b/src/zr/ztele.inc index 2f26666..e67118a 100644 --- a/src/zr/ztele.inc +++ b/src/zr/ztele.inc @@ -50,6 +50,15 @@ new Handle:tZTele[MAXPLAYERS + 1]; */ new g_iZTeleTimeLeft[MAXPLAYERS + 1]; +/** + * Create commands specific to ZTele. + */ +ZTeleOnCommandsCreate() +{ + // Register ZMenu command. + RegConsoleCmd(SAYHOOKS_KEYWORD_ZTELE, ZTeleCommand, "Teleport back to spawn if you are stuck."); +} + /** * Client is joining the server. * @@ -217,6 +226,29 @@ ZTeleTeleportClient(client) TeleportEntity(client, g_vecZTeleSpawn[client], NULL_VECTOR, NULL_VECTOR); } +/** + * Command callback (zmenu) + * Teleport back to spawn if you are stuck. + * + * @param client The client index. + * @param argc Argument count. + */ +public Action:ZTeleCommand(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; + } + + // Start teleportation process. + ZTeleClient(client); + + // This stops the "Unknown command" message in client's console. + return Plugin_Handled; +} + /** * Timer callback, counts down teleport to the client. *