@PartialCloning
as i can see in the main code i used as refference, there is no "," after "CLASS_ZOMBIE" =/ it is ":" hmmm, are you sure about it?
@Bugsy
well, this is the original code... i need to add about 6 new classes/modes to this menu
the nemesis/assassin/dragon/tyrant/alpha classes are zombie like classes ( more exactly bosses )
the survivor/sniper/ninja are human like classes ( again bosses )
So, could you please write an example on how would you write it so i can follow the pattern? this code gets me a little confused, i never understood menus, never did them, always hated them
Later Edit:
P.S -> Could you guys give me a page or something where i can find all the symbols/terms used in formatex and their meaning?
Player List part
PHP Code:
/ Player List Menu show_menu_player_list(id) { static menu[128], player_name[32] new menuid, player, buffer[2], userflags = get_user_flags(id)
// Title switch (PL_ACTION) { case ACTION_INFECT_CURE: formatex(menu, charsmax(menu), "%L\r", id, "MENU_ADMIN1") case ACTION_MAKE_NEMESIS: formatex(menu, charsmax(menu), "%L\r", id, "MENU_ADMIN2") case ACTION_MAKE_SURVIVOR: formatex(menu, charsmax(menu), "%L\r", id, "MENU_ADMIN3") case ACTION_RESPAWN_PLAYER: formatex(menu, charsmax(menu), "%L\r", id, "MENU_ADMIN4") } menuid = menu_create(menu, "menu_player_list")
// Player List for (player = 0; player <= g_MaxPlayers; player++) { // Skip if not connected if (!is_user_connected(player)) continue;
// Get player's name get_user_name(player, player_name, charsmax(player_name))
// Settings file
new const ZP_SETTINGS_FILE[] = "zombieplague.ini"
#define ACCESSFLAG_MAX_LENGTH 2
// Access flags
new g_access_make_zombie[ACCESSFLAG_MAX_LENGTH] = "d"
new g_access_make_human[ACCESSFLAG_MAX_LENGTH] = "d"
new g_access_make_nemesis[ACCESSFLAG_MAX_LENGTH] = "d"
new g_access_make_survivor[ACCESSFLAG_MAX_LENGTH] = "d"
new g_access_respawn_players[ACCESSFLAG_MAX_LENGTH] = "d"
new g_access_start_game_mode[ACCESSFLAG_MAX_LENGTH] = "d"
// Menu keys
const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|M ENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|ME NU_KEY_9|MENU_KEY_0
// CS Player PData Offsets (win32)
const OFFSET_CSMENUCODE = 205
#define MAXPLAYERS 32
// For player/mode list menu handlers
#define PL_ACTION g_menu_data[id][0]
#define MENU_PAGE_PLAYERS g_menu_data[id][1]
#define MENU_PAGE_GAME_MODES g_menu_data[id][2]
new g_menu_data[MAXPLAYERS+1][3]
new g_MaxPlayers
public plugin_init()
{
register_plugin("[ZP] Admin Menus", ZP_VERSION_STRING, "ZP Dev Team")
// Game Mode List Menu
show_menu_game_mode_list(id)
{
static menu[128], transkey[64]
new menuid, index, itemdata[2], game_mode_count = zp_gamemodes_get_count()
// Item List
for (index = 0; index < game_mode_count; index++)
{
// Add Game Mode Name
zp_gamemodes_get_name(index, menu, charsmax(menu))
// ML support for mode name
formatex(transkey, charsmax(transkey), "MODENAME %s", menu)
if (GetLangTransKey(transkey) != TransKey_Bad) formatex(menu, charsmax(menu), "%L", id, transkey)
itemdata[0] = index
itemdata[1] = 0
menu_additem(menuid, menu, itemdata)
}
// No game modes to display?
if (menu_items(menuid) <= 0)
{
menu_destroy(menuid)
return;
}
// Admin Menu
public menu_admin(id, key)
{
// Player disconnected?
if (!is_user_connected(id))
return PLUGIN_HANDLED;
new userflags = get_user_flags(id)
switch (key)
{
case ACTION_INFECT_CURE: // Infect/Cure command
{
if (userflags & (read_flags(g_access_make_zombie) | read_flags(g_access_make_human)))
{
// Show player list for admin to pick a target
PL_ACTION = ACTION_INFECT_CURE
show_menu_player_list(id)
}
else
{
zp_colored_print(id, "%L", id, "CMD_NOT_ACCESS")
show_menu_admin(id)
}
}
case ACTION_MAKE_NEMESIS: // Nemesis command
{
if (LibraryExists(LIBRARY_NEMESIS, LibType_Library) && (userflags & read_flags(g_access_make_nemesis)))
{
// Show player list for admin to pick a target
PL_ACTION = ACTION_MAKE_NEMESIS
show_menu_player_list(id)
}
else
{
zp_colored_print(id, "%L", id, "CMD_NOT_ACCESS")
show_menu_admin(id)
}
}
case ACTION_MAKE_SURVIVOR: // Survivor command
{
if (LibraryExists(LIBRARY_SURVIVOR, LibType_Library) && (userflags & read_flags(g_access_make_survivor)))
{
// Show player list for admin to pick a target
PL_ACTION = ACTION_MAKE_SURVIVOR
show_menu_player_list(id)
}
else
{
zp_colored_print(id, "%L", id, "CMD_NOT_ACCESS")
show_menu_admin(id)
}
}
case ACTION_RESPAWN_PLAYER: // Respawn command
{
if (userflags & read_flags(g_access_respawn_players))
{
// Show player list for admin to pick a target
PL_ACTION = ACTION_RESPAWN_PLAYER
show_menu_player_list(id)
}
else
{
zp_colored_print(id, "%L", id, "CMD_NOT_ACCESS")
show_menu_admin(id)
}
}
case ACTION_START_GAME_MODE: // Start Game Mode command
{
if (userflags & read_flags(g_access_start_game_mode))
show_menu_game_mode_list(id)
else
{
zp_colored_print(id, "%L", id, "CMD_NOT_ACCESS")
show_menu_admin(id)
}
}
}
return PLUGIN_HANDLED;
}
// Player List Menu
public menu_player_list(id, menuid, item)
{
// Menu was closed
if (item == MENU_EXIT)
{
MENU_PAGE_PLAYERS = 0
menu_destroy(menuid)
show_menu_admin(id)
return PLUGIN_HANDLED;
}
// Remember player's menu page
MENU_PAGE_PLAYERS = item / 7
// Retrieve player id
new buffer[2], dummy, player
menu_item_getinfo(menuid, item, dummy, buffer, charsmax(buffer), _, _, dummy)
player = buffer[0]
// Perform action on player
// Get admin flags
new userflags = get_user_flags(id)
// Make sure it's still connected
if (is_user_connected(player))
{
// Perform the right action if allowed
switch (PL_ACTION)
{
case ACTION_INFECT_CURE: // Infect/Cure command
{
if (zp_core_is_zombie(player))
{
if ((userflags & read_flags(g_access_make_human)) && is_user_alive(player))
zp_admin_commands_human(id, player)
else
zp_colored_print(id, "%L", id, "CMD_NOT")
}
else
{
if ((userflags & read_flags(g_access_make_zombie)) && is_user_alive(player))
zp_admin_commands_zombie(id, player)
else
zp_colored_print(id, "%L", id, "CMD_NOT")
}
}
case ACTION_MAKE_NEMESIS: // Nemesis command
{
if (LibraryExists(LIBRARY_NEMESIS, LibType_Library) && (userflags & read_flags(g_access_make_nemesis)) && is_user_alive(player) && !zp_class_nemesis_get(player))
zp_admin_commands_nemesis(id, player)
else
zp_colored_print(id, "%L", id, "CMD_NOT")
}
case ACTION_MAKE_SURVIVOR: // Survivor command
{
if (LibraryExists(LIBRARY_SURVIVOR, LibType_Library) && (userflags & read_flags(g_access_make_survivor)) && is_user_alive(player) && !zp_class_survivor_get(player))
zp_admin_commands_survivor(id, player)
else
zp_colored_print(id, "%L", id, "CMD_NOT")
}
case ACTION_RESPAWN_PLAYER: // Respawn command
{
if ((userflags & read_flags(g_access_respawn_players)) && allowed_respawn(player))
zp_admin_commands_respawn(id, player)
else
zp_colored_print(id, "%L", id, "CMD_NOT")
}
}
}
else
zp_colored_print(id, "%L", id, "CMD_NOT")
// Game Mode List Menu
public menu_game_mode_list(id, menuid, item)
{
// Menu was closed
if (item == MENU_EXIT)
{
MENU_PAGE_GAME_MODES = 0
menu_destroy(menuid)
show_menu_admin(id)
return PLUGIN_HANDLED;
}
// Remember game modes menu page
MENU_PAGE_GAME_MODES = item / 7
// Retrieve game mode id
new itemdata[2], dummy, game_mode_id
menu_item_getinfo(menuid, item, dummy, itemdata, charsmax(itemdata), _, _, dummy)
game_mode_id = itemdata[0]
// Attempt to start game mode
zp_admin_commands_start_mode(id, game_mode_id)