Started on new class menus (new file). Fixed parameter name in class attributes. Made function IsClientAdmin (generic admin).
This commit is contained in:
parent
f27a723129
commit
13ab32a7bb
@ -392,12 +392,6 @@
|
|||||||
"ru" "ZHP (!zhp) - Показ здоровья зомби"
|
"ru" "ZHP (!zhp) - Показ здоровья зомби"
|
||||||
}
|
}
|
||||||
|
|
||||||
"!zclass title"
|
|
||||||
{
|
|
||||||
"en" "Zombie Class Selection:"
|
|
||||||
"ru" "Выбор Класса Зомби:"
|
|
||||||
}
|
|
||||||
|
|
||||||
"Market title"
|
"Market title"
|
||||||
{
|
{
|
||||||
"en" "Available Guns:"
|
"en" "Available Guns:"
|
||||||
@ -410,6 +404,40 @@
|
|||||||
"ru" "Купить снова"
|
"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
|
// ZAdmin Menu
|
||||||
// ===========================
|
// ===========================
|
||||||
|
@ -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,
|
* @param index Index of the class in a class cache or a client index,
|
||||||
* depending on the cache type specified.
|
* 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 maxlen The length of the destination string buffer.
|
||||||
* @param cachetype Optional. Specifies what class cache to read from. Options:
|
* @param cachetype Optional. Specifies what class cache to read from. Options:
|
||||||
* ZR_CLASS_CACHE_ORIGINAL - Unchanced class data.
|
* 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.
|
* is used, index will be used as a client index.
|
||||||
* @return Number of cells written. -1 on error.
|
* @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)
|
switch (cachetype)
|
||||||
{
|
{
|
||||||
case ZR_CLASS_CACHE_ORIGINAL:
|
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:
|
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:
|
case ZR_CLASS_CACHE_PLAYER:
|
||||||
{
|
{
|
||||||
return strcopy(name, maxlen, ClassPlayerCache[index][class_name]);
|
return strcopy(buffer, maxlen, ClassPlayerCache[index][class_name]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
130
src/zr/playerclasses/classmenus.inc
Normal file
130
src/zr/playerclasses/classmenus.inc
Normal file
@ -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)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -232,6 +232,16 @@ new ClassCount;
|
|||||||
*/
|
*/
|
||||||
new ClassSelected[MAXPLAYERS + 1][ZR_CLASS_TEAMCOUNT];
|
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/filtertools"
|
||||||
#include "zr/playerclasses/attributes"
|
#include "zr/playerclasses/attributes"
|
||||||
#include "zr/playerclasses/apply"
|
#include "zr/playerclasses/apply"
|
||||||
|
@ -11,10 +11,9 @@ new curMenuClass[MAXPLAYERS + 1];
|
|||||||
|
|
||||||
bool:ZRAdminMenu(client)
|
bool:ZRAdminMenu(client)
|
||||||
{
|
{
|
||||||
if (!GetAdminFlag(GetUserAdmin(client), Admin_Generic))
|
if (!IsClientAdmin(client))
|
||||||
{
|
{
|
||||||
ZR_PrintToChat(client, "Must be admin");
|
ZR_PrintToChat(client, "Must be admin");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,3 +251,21 @@ bool:IsClientPlayer(client)
|
|||||||
return false;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user