From 13ab32a7bbdcff8d6ab6b90c38305611ffca36b5 Mon Sep 17 00:00:00 2001 From: richard Date: Tue, 14 Apr 2009 23:33:06 +0200 Subject: [PATCH] Started on new class menus (new file). Fixed parameter name in class attributes. Made function IsClientAdmin (generic admin). --- .../translations/zombiereloaded.phrases.txt | 40 +++++- src/zr/playerclasses/attributes.inc | 10 +- src/zr/playerclasses/classmenus.inc | 130 ++++++++++++++++++ src/zr/playerclasses/playerclasses.inc | 10 ++ src/zr/zadmin.inc | 3 +- src/zr/zombiereloaded.inc | 18 +++ 6 files changed, 198 insertions(+), 13 deletions(-) create mode 100644 src/zr/playerclasses/classmenus.inc diff --git a/cstrike/addons/sourcemod/translations/zombiereloaded.phrases.txt b/cstrike/addons/sourcemod/translations/zombiereloaded.phrases.txt index e57a536..b609ef3 100644 --- a/cstrike/addons/sourcemod/translations/zombiereloaded.phrases.txt +++ b/cstrike/addons/sourcemod/translations/zombiereloaded.phrases.txt @@ -392,12 +392,6 @@ "ru" "ZHP (!zhp) - Показ здоровья зомби" } - "!zclass title" - { - "en" "Zombie Class Selection:" - "ru" "Выбор Класса Зомби:" - } - "Market title" { "en" "Available Guns:" @@ -409,6 +403,40 @@ "en" "Rebuy" "ru" "Купить снова" } + + // =========================== + // Class menu + // =========================== + + "!zclass title" + { + "en" "Class Selection:" + } + + "!zclass zombie" + { + "en" "Select Zombie Class" + } + + "!zclass human" + { + "en" "Select Human Class" + } + + "!zclass admin" + { + "en" "Select Admin Class" + } + + "!zclass admin mode enabled" + { + "en" "Admin mode is enabled!" + } + + "!zclass admin mode toggle" + { + "en" "Toggle Admin Mode" + } // =========================== // ZAdmin Menu diff --git a/src/zr/playerclasses/attributes.inc b/src/zr/playerclasses/attributes.inc index 23dff32..4d633d3 100644 --- a/src/zr/playerclasses/attributes.inc +++ b/src/zr/playerclasses/attributes.inc @@ -122,7 +122,7 @@ bool:ClassGetTeamDefault(index, cachetype = ZR_CLASS_CACHE_MODIFIED) * * @param index Index of the class in a class cache or a client index, * depending on the cache type specified. - * @param name The destination string buffer. + * @param buffer The destination string buffer. * @param maxlen The length of the destination string buffer. * @param cachetype Optional. Specifies what class cache to read from. Options: * ZR_CLASS_CACHE_ORIGINAL - Unchanced class data. @@ -131,21 +131,21 @@ bool:ClassGetTeamDefault(index, cachetype = ZR_CLASS_CACHE_MODIFIED) * is used, index will be used as a client index. * @return Number of cells written. -1 on error. */ -ClassGetName(index, String:name[], maxlen, cachetype = ZR_CLASS_CACHE_PLAYER) +ClassGetName(index, String:buffer[], maxlen, cachetype = ZR_CLASS_CACHE_PLAYER) { switch (cachetype) { case ZR_CLASS_CACHE_ORIGINAL: { - return strcopy(name, maxlen, ClassData[index][class_name]); + return strcopy(buffer, maxlen, ClassData[index][class_name]); } case ZR_CLASS_CACHE_MODIFIED: { - return strcopy(name, maxlen, ClassDataCache[index][class_name]); + return strcopy(buffer, maxlen, ClassDataCache[index][class_name]); } case ZR_CLASS_CACHE_PLAYER: { - return strcopy(name, maxlen, ClassPlayerCache[index][class_name]); + return strcopy(buffer, maxlen, ClassPlayerCache[index][class_name]); } } diff --git a/src/zr/playerclasses/classmenus.inc b/src/zr/playerclasses/classmenus.inc new file mode 100644 index 0000000..aeeb255 --- /dev/null +++ b/src/zr/playerclasses/classmenus.inc @@ -0,0 +1,130 @@ +/* + * ============================================================================ + * + * Zombie:Reloaded + * + * File: classmenus.inc + * Description: Provides functions for managing class menus. + * Author: Richard Helgeby, Greyscale + * + * ============================================================================ + */ + +/* + +Menu layouts + +--------------------------------------- +Class selection: + +Admin mode is enabled! + +1. Select Zombie Class + - Classic +2. Select Human Class + - Regular Human +3. Select Admin Class <-- Only active for admins + - Hidden Admin +(spacer) +4. Toggle Admin Mode + - Disabled + +0. Exit +--------------------------------------- + +*/ + +/** + * Displays the main class menu with the players class settings. + */ +ClassMenuMain(client) +{ + new Handle:classmenu = CreateMenu(ClassMenuMainHandle); + + SetGlobalTransTarget(client); + SetMenuTitle(classmenu, "%t\n", "!zclass title"); + + decl String:zombieclass[128]; + decl String:humanclass[128]; + decl String:adminclass[128]; + + decl String:zombieselect[128]; + decl String:humanselect[128]; + decl String:adminselect[128]; + + decl String:inadminmnode[128]; + decl String:adminmnode[128]; + decl String:toggleadminmnode[128]; + + // Check if the player is in admin mode. + if (ClassPlayerInAdminMode(client)) + { + // Notify the player. + Format(adminmode, sizeof(adminmode), "%t\n", "!zclass admin mode enabled"); + AddMenuItem(classmenu, "", adminmode, ITEMDRAW_RAWLINE); + } + + // List zombie class options. + ClassGetName(ClassSelected[client][ZR_CLASS_TEAM_ZOMBIES, zombieclass, sizeof(zombieclass), ZR_CLASS_CACHE_MODIFIED); + Format(zombieselect, sizeof(zombieselect), "%t\n-%s", "!zclass zombie", zombieclass); + AddMenuItem(classmenu, "", zombieselect); + + // List human class options. + ClassGetName(client, humanclass, sizeof(zombieclass)); + Format(zombieselect, sizeof(zombieselect), "%t\n-%s", "!zclass human", humanclass); + AddMenuItem(classmenu, "", zombieselect); + + // List admin class options. + ClassGetName(client, adminclass, sizeof(adminclass)); + Format(adminselect, sizeof(adminselect), "%t\n-%s", "!zclass admin", adminclass); + AddMenuItem(classmenu, "", adminselect); + + if (IsClientAdmin(client)) + { + // Show admin mode toggle option. + AddMenuItem(classmenu, "", " ", ITEMDRAW_SPACER); + + // TODO: Translate or use core phrases! + if (ClassPlayerAdminMode[client]) + { + Format(adminmnode, sizeof(adminmnode), "Enabled"); + } + else + { + Format(adminmnode, sizeof(adminmnode), "Disabled"); + } + + Format(toggleadminmode, sizeof(toggleadminmode), "%t\n-%s", "!zclass admin mode toggle", adminmode); + } + + /*for (new x = 0; x < classCount; x++) + { + GetClassName(x, display, sizeof(display)); + GetClassMenuDescription(x, menu_description, sizeof(menu_description)); + + if (pNextClass[client] == -1) + { + if (x == pClass[client]) + { + Format(display, sizeof(display), "%s (current)", display); + } + } + else if (x == pNextClass[client]) + { + Format(display, sizeof(display), "%s (current)", display); + } + + Format(display, sizeof(display), "%s\n %s", display, menu_description); + + AddMenuItem(menu_classes, "", display); + } + + SetMenuExitBackButton(menu_classes, true);*/ + + DisplayMenu(classmenu, client, MENU_TIME_FOREVER); +} + +ClassMenuMainHandle(Handle:classmenu, MenuAction:action, client, slot) +{ + +} \ No newline at end of file diff --git a/src/zr/playerclasses/playerclasses.inc b/src/zr/playerclasses/playerclasses.inc index b6a159a..8b213d7 100644 --- a/src/zr/playerclasses/playerclasses.inc +++ b/src/zr/playerclasses/playerclasses.inc @@ -232,6 +232,16 @@ new ClassCount; */ new ClassSelected[MAXPLAYERS + 1][ZR_CLASS_TEAMCOUNT]; +/** + * Specifies whether a player is currently in admin mode. + */ +new bool:ClassPlayerInAdminMode[MAXPLAYERS + 1]; + +/** + * Specifies whether a player is set to be in admin mode next spawn. + */ +new bool:ClassPlayerAdminMode[MAXPLAYERS + 1]; + #include "zr/playerclasses/filtertools" #include "zr/playerclasses/attributes" #include "zr/playerclasses/apply" diff --git a/src/zr/zadmin.inc b/src/zr/zadmin.inc index 26a92c7..23359d7 100644 --- a/src/zr/zadmin.inc +++ b/src/zr/zadmin.inc @@ -11,10 +11,9 @@ new curMenuClass[MAXPLAYERS + 1]; bool:ZRAdminMenu(client) { - if (!GetAdminFlag(GetUserAdmin(client), Admin_Generic)) + if (!IsClientAdmin(client)) { ZR_PrintToChat(client, "Must be admin"); - return false; } diff --git a/src/zr/zombiereloaded.inc b/src/zr/zombiereloaded.inc index aa9c2ca..0c66bd8 100644 --- a/src/zr/zombiereloaded.inc +++ b/src/zr/zombiereloaded.inc @@ -251,3 +251,21 @@ bool:IsClientPlayer(client) return false; } } + +/** + * Returns whether a player is a generic admin or not. + * + * @param client The client index. + * @return True if generic admin, false otherwise. + */ +bool:IsClientAdmin(client) +{ + if (GetAdminFlag(GetUserAdmin(client), Admin_Generic)) + { + return true; + } + else + { + return false; + } +}