- register_native("CoinsMenu","native_CoinsMenu",1)
i tried to add Coins Menu + Level Menu to this admin menu but i failed , can any one help me !
- #include <zombie_escape>
- native CoinsMenu(id)
- native LevelMenu(id)
- new const ZE_SETTINGS_FILE[] = "zombie_escape.ini"
- new g_szAccess_Make_Zombie[2] = "d"
- new g_szAccess_Make_Human[2] = "d"
- new g_szAccess_SetLevel[2] = "k"
- new g_szAccess_SetCoins[2] = "k"
- new g_iMaxPlayers, bool:g_bIsZombieReleased, bool:g_bIsRoundEnded
- new g_pCvarAMXShowActivity, g_pCvarLogAdminCmds
- public plugin_natives()
- {
- register_native("ze_open_admin_menu", "_ze_open_admin_menu", 1)
- }
- public plugin_precache()
- {
- if (!amx_load_setting_string(ZE_SETTINGS_FILE, "Access Flags", "Make Zombie", g_szAccess_Make_Zombie, charsmax(g_szAccess_Make_Zombie)))
- amx_save_setting_string(ZE_SETTINGS_FILE, "Access Flags", "Make Zombie", g_szAccess_Make_Zombie)
- if (!amx_load_setting_string(ZE_SETTINGS_FILE, "Access Flags", "Make Human", g_szAccess_Make_Human, charsmax(g_szAccess_Make_Human)))
- amx_save_setting_string(ZE_SETTINGS_FILE, "Access Flags", "Make Human", g_szAccess_Make_Human)
- if (!amx_load_setting_string(ZE_SETTINGS_FILE, "Access Flags", "Level Menu", g_szAccess_SetLevel, charsmax(g_szAccess_SetLevel)))
- amx_save_setting_string(ZE_SETTINGS_FILE, "Access Flags", "Level Menu", g_szAccess_SetLevel)
- if (!amx_load_setting_string(ZE_SETTINGS_FILE, "Access Flags", "Coins Menu", g_szAccess_SetCoins, charsmax(g_szAccess_SetCoins)))
- amx_save_setting_string(ZE_SETTINGS_FILE, "Access Flags", "Coins Menu", g_szAccess_SetCoins)
- }
- public plugin_init()
- {
- register_plugin("[ZE] Addons: Admin szMenu", "1.0", "Jack GamePlay")
- register_clcmd("say /am", "Open_Admin_Menu")
- register_concmd("ze_zombie", "Zombie_Cmd", _, "<target> - Turn someone into a zombie", 0)
- register_concmd("ze_human", "Human_Cmd", _, "<target> - Turn someone back to human", 0)
- g_pCvarLogAdminCmds = register_cvar("ze_log_admin_commands", "1")
- g_iMaxPlayers = get_member_game(m_nMaxPlayers)
- }
- public ze_zombie_appear()
- {
- g_bIsZombieReleased = false
- g_bIsRoundEnded = false
- }
- public ze_game_started()
- {
- g_bIsZombieReleased = false
- g_bIsRoundEnded = false
- }
- public ze_zombie_release()
- {
- g_bIsZombieReleased = true
- g_bIsRoundEnded = false
- }
- public ze_roundend()
- {
- g_bIsRoundEnded = true
- g_bIsZombieReleased = false
- }
- public plugin_cfg()
- {
- g_pCvarAMXShowActivity = get_cvar_pointer("amx_show_activity")
- }
- public Open_Admin_Menu(id)
- {
- static szMenu[250]
- new iMenuID
- formatex(szMenu, charsmax(szMenu), "\y%L:^n^n", LANG_PLAYER, "MENU_ADMIN_TITLE")
- iMenuID = menu_create(szMenu, "Admin_Menu_Handler")
- if (get_user_flags(id) & (read_flags(g_szAccess_Make_Zombie) | read_flags(g_szAccess_Make_Human)))
- formatex(szMenu, charsmax(szMenu), "\w%L^n", LANG_PLAYER, "MAKE_HM_ZM")
- else
- formatex(szMenu, charsmax(szMenu), "\d%L^n", LANG_PLAYER, "MAKE_HM_ZM")
- menu_additem(iMenuID, szMenu)
- if (get_user_flags(id) & (read_flags(g_szAccess_SetLevel))
- formatex(szMenu, charsmax(szMenu), "\w%L^n", LANG_PLAYER, "LEVEL_MENU")
- else
- formatex(szMenu, charsmax(szMenu), "\d%L^n", LANG_PLAYER, "LEVEL_MENU")
- menu_additem(iMenuID, szMenu)
- if (get_user_flags(id) & (read_flags(g_szAccess_SetCoins))
- formatex(szMenu, charsmax(szMenu), "\w%L^n", LANG_PLAYER, "COINS_MENU")
- else
- formatex(szMenu, charsmax(szMenu), "\d%L^n", LANG_PLAYER, "COINS_MENU")
- menu_additem(iMenuID, szMenu)
- menu_display(id, iMenuID, 0, 30)
- }
- public Admin_Menu_Handler(id, iMenuID, iKey)
- {
- // Player disconnected?
- if (!is_user_connected(id))
- return PLUGIN_HANDLED
- switch (iKey)
- {
- case 0:
- {
- if (get_user_flags(id) & (read_flags(g_szAccess_Make_Zombie) | read_flags(g_szAccess_Make_Human)))
- {
- Show_Player_Menu(id)
- }
- else
- {
- ze_colored_print(id, "%L", LANG_PLAYER, "CMD_NOT_ACCESS")
- Open_Admin_Menu(id)
- }
- {
- case 1:
- {
- if (get_user_flags(id) & (read_flags(g_szAccess_SetLevel))
- {
- LevelMenu(id)
- }
- else
- {
- ze_colored_print(id, "%L", LANG_PLAYER, "CMD_NOT_ACCESS")
- Open_Admin_Menu(id)
- }
- {
- case 2:
- {
- if (get_user_flags(id) & (read_flags(g_szAccess_SetCoins))
- {
- CoinsMenu(id)
- }
- else
- {
- ze_colored_print(id, "%L", LANG_PLAYER, "CMD_NOT_ACCESS")
- Open_Admin_Menu(id)
- }
- }
- }
- menu_destroy(iMenuID)
- return PLUGIN_HANDLED
- }
- public Show_Player_Menu(id)
- {
- static szMenu[128], szAdminName[32], szPlayerName[32]
- new iIndex, iMenuID, iItemData[2]
- get_user_name(id, szAdminName, charsmax(szAdminName))
- formatex(szMenu, charsmax(szMenu), "%L:^n^n", LANG_PLAYER, "MAKE_HM_ZM")
- iMenuID = menu_create(szMenu, "Player_Menu_Handler")
- for (iIndex = 0; iIndex <= g_iMaxPlayers; iIndex++)
- {
- if (!is_user_connected(iIndex))
- continue
- get_user_name(iIndex, szPlayerName, charsmax(szPlayerName))
- if (ze_is_user_zombie(iIndex))
- {
- if ((get_user_flags(id) & read_flags(g_szAccess_Make_Human)) && is_user_alive(iIndex) && g_bIsZombieReleased && !g_bIsRoundEnded)
- {
- if (equali(szPlayerName, szAdminName))
- formatex(szMenu, charsmax(szMenu), "\y%s \d[\r%L\d]", szPlayerName, LANG_PLAYER, "CLASS_ZOMBIE")
- else
- formatex(szMenu, charsmax(szMenu), "\w%s \d[\r%L\d]", szPlayerName, LANG_PLAYER, "CLASS_ZOMBIE")
- }
- else
- formatex(szMenu, charsmax(szMenu), "\d%s [%L]", szPlayerName, LANG_PLAYER, "CLASS_ZOMBIE")
- }
- else
- {
- if ((get_user_flags(id) & read_flags(g_szAccess_Make_Zombie)) && is_user_alive(iIndex) && g_bIsZombieReleased && !g_bIsRoundEnded)
- {
- if (equali(szPlayerName, szAdminName))
- formatex(szMenu, charsmax(szMenu), "\y%s \d[\r%L\d]", szPlayerName, LANG_PLAYER, "CLASS_HUMAN")
- else
- formatex(szMenu, charsmax(szMenu), "\w%s \d[\r%L\d]", szPlayerName, LANG_PLAYER, "CLASS_HUMAN")
- }
- else
- formatex(szMenu, charsmax(szMenu), "\d%s [%L]", szPlayerName, LANG_PLAYER, "CLASS_HUMAN")
- }
- iItemData[0] = iIndex
- iItemData[1] = 0
- menu_additem(iMenuID, szMenu, iItemData)
- }
- // Back - Next - Exit
- formatex(szMenu, charsmax(szMenu), "%L", LANG_PLAYER, "BACK")
- menu_setprop(iMenuID, MPROP_BACKNAME, szMenu)
- formatex(szMenu, charsmax(szMenu), "%L", LANG_PLAYER, "NEXT")
- menu_setprop(iMenuID, MPROP_NEXTNAME, szMenu)
- formatex(szMenu, charsmax(szMenu), "%L", LANG_PLAYER, "EXIT")
- menu_setprop(iMenuID, MPROP_EXITNAME, szMenu)
- menu_display(id, iMenuID, 0, 30)
- }
- public Player_Menu_Handler(id, iMenuID, iKey)
- {
- if (iKey == MENU_EXIT)
- {
- menu_destroy(iMenuID)
- Open_Admin_Menu(id)
- return PLUGIN_HANDLED
- }
- new iItemData[2], iDummy, iPlayer
- menu_item_getinfo(iMenuID, iKey, iDummy, iItemData, charsmax(iItemData), _, _, iDummy)
- iPlayer = iItemData[0]
- if (is_user_connected(iPlayer))
- {
- if (ze_is_user_zombie(iPlayer))
- {
- if ((get_user_flags(id) & read_flags(g_szAccess_Make_Human)) && is_user_alive(iPlayer) && g_bIsZombieReleased && !g_bIsRoundEnded)
- {
- ze_admin_command_human(id, iPlayer)
- Show_Player_Menu(id)
- }
- else
- ze_colored_print(id, "%L", LANG_PLAYER, "CMD_NOT")
- }
- else
- {
- if ((get_user_flags(id) & read_flags(g_szAccess_Make_Zombie)) && is_user_alive(iPlayer) && g_bIsZombieReleased && !g_bIsRoundEnded)
- {
- ze_admin_command_zombie(id, iPlayer)
- Show_Player_Menu(id)
- }
- else
- ze_colored_print(id, "%L", LANG_PLAYER, "CMD_NOT")
- }
- }
- menu_destroy(iMenuID)
- return PLUGIN_HANDLED
- }
- public ze_admin_command_human(Admin_ID, Player_ID)
- {
- if (!is_user_connected(Admin_ID))
- {
- log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", Admin_ID)
- return false
- }
- if (!is_user_alive(Player_ID))
- {
- log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", Player_ID)
- return false
- }
- Cmd_Human(Admin_ID, Player_ID)
- return true
- }
- public ze_admin_command_zombie(Admin_ID, Player_ID)
- {
- if (!is_user_connected(Admin_ID))
- {
- log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", Admin_ID)
- return false
- }
- if (!is_user_alive(Player_ID))
- {
- log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", Player_ID)
- return false
- }
- Cmd_Zombie(Admin_ID, Player_ID)
- return true
- }
- public Human_Cmd(Admin_ID, level, cid)
- {
- // Check for access flag - Make Human
- if (!cmd_access(Admin_ID, read_flags(g_szAccess_Make_Human), cid, 2))
- return PLUGIN_HANDLED
- // Retrieve arguments
- new szArg[32], Player_ID
- read_argv(1, szArg, charsmax(szArg))
- Player_ID = cmd_target(Admin_ID, szArg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF))
- // Invalid target
- if (!Player_ID || !g_bIsZombieReleased || g_bIsRoundEnded)
- return PLUGIN_HANDLED
- // Target not allowed to be human
- if (!ze_is_user_zombie(Player_ID))
- {
- new szPlayerName[32]
- get_user_name(Player_ID, szPlayerName, charsmax(szPlayerName))
- client_print(Admin_ID, print_console, "[ZE] %L (%s).", LANG_PLAYER, "ALREADY_HUMAN", szPlayerName)
- return PLUGIN_HANDLED
- }
- Cmd_Human(Admin_ID, Player_ID)
- return PLUGIN_HANDLED
- }
- public Zombie_Cmd(Admin_ID, level, cid)
- {
- // Check for access flag - Make Human
- if (!cmd_access(Admin_ID, read_flags(g_szAccess_Make_Zombie), cid, 2))
- return PLUGIN_HANDLED
- // Retrieve arguments
- new szArg[32], Player_ID
- read_argv(1, szArg, charsmax(szArg))
- Player_ID = cmd_target(Admin_ID, szArg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF))
- // Invalid target
- if (!Player_ID || !g_bIsZombieReleased || g_bIsRoundEnded)
- return PLUGIN_HANDLED
- // Target not allowed to be human
- if (ze_is_user_zombie(Player_ID))
- {
- new szPlayerName[32]
- get_user_name(Player_ID, szPlayerName, charsmax(szPlayerName))
- client_print(Admin_ID, print_console, "[ZE] %L (%s).", LANG_PLAYER, "ALREADY_ZOMBIE", szPlayerName)
- return PLUGIN_HANDLED
- }
- Cmd_Zombie(Admin_ID, Player_ID)
- return PLUGIN_HANDLED
- }
- public Cmd_Human(Admin_ID, Player_ID)
- {
- // Prevent infecting last zombie
- //if (ze_is_last_zombie(Player_ID))
- if (ze_get_zombies_number() == 1)
- {
- ze_colored_print(Admin_ID, "%L", LANG_PLAYER, "CMD_CANT_LAST_ZOMBIE")
- return
- }
- // Zombies have not been released yet
- if (!g_bIsZombieReleased)
- {
- ze_colored_print(Admin_ID, "%L", LANG_PLAYER, "CMD_ONLY_AFTER_GAME_MODE")
- return
- }
- ze_set_user_human(Player_ID)
- // Get user names
- new szAdminName[32], szPlayerName[32]
- get_user_name(Admin_ID, szAdminName, charsmax(szAdminName))
- get_user_name(Player_ID, szPlayerName, charsmax(szPlayerName))
- // Show activity?
- if (g_pCvarAMXShowActivity)
- {
- switch (get_pcvar_num(g_pCvarAMXShowActivity))
- {
- case 1: ze_colored_print(0, "!tAdmin !y- !g%s !t%L", szPlayerName, LANG_PLAYER, "CMD_CURED")
- case 2: ze_colored_print(0, "!tAdmin !g%s !y- !g%s !t%L", szAdminName, szPlayerName, LANG_PLAYER, "CMD_CURED")
- }
- }
- // Log to Zombie Plague log file?
- if (get_pcvar_num(g_pCvarLogAdminCmds))
- {
- new szAuthid[32], szIP[16]
- get_user_authid(Admin_ID, szAuthid, charsmax(szAuthid))
- get_user_ip(Admin_ID, szIP, charsmax(szIP), 1)
- ze_log("Admin [%s (%s - %s)] - [%s] [%L]", szAdminName, szAuthid, szIP, szPlayerName, LANG_PLAYER, "CMD_CURED")
- }
- }
- public Cmd_Zombie(Admin_ID, Player_ID)
- {
- // Prevent infecting last zombie
- //if (ze_is_last_human(Player_ID))
- if (ze_get_humans_number() == 1)
- {
- ze_colored_print(Admin_ID, "%L", LANG_PLAYER, "CMD_CANT_LAST_HUMAN")
- return
- }
- // Game is already started
- if (ze_is_game_started())
- {
- // Zombie released
- if (!g_bIsZombieReleased)
- {
- ze_colored_print(Admin_ID, "%L", LANG_PLAYER, "CMD_ONLY_AFTER_GAME_MODE")
- return
- }
- }
- ze_set_user_zombie(Player_ID)
- // Get user names
- new szAdminName[32], szPlayerName[32]
- get_user_name(Admin_ID, szAdminName, charsmax(szAdminName))
- get_user_name(Player_ID, szPlayerName, charsmax(szPlayerName))
- // Show activity?
- if (g_pCvarAMXShowActivity)
- {
- switch (get_pcvar_num(g_pCvarAMXShowActivity))
- {
- case 1: ze_colored_print(0, "!tAdmin !y- !g%s !t%L", szPlayerName, LANG_PLAYER, "CMD_INFECTED")
- case 2: ze_colored_print(0, "!tAdmin !g%s !y- !g%s !t%L", szAdminName, szPlayerName, LANG_PLAYER, "CMD_INFECTED")
- }
- }
- // Log to Zombie Plague log file?
- if (get_pcvar_num(g_pCvarLogAdminCmds))
- {
- new szAuthid[32], szIP[16]
- get_user_authid(Admin_ID, szAuthid, charsmax(szAuthid))
- get_user_ip(Admin_ID, szIP, charsmax(szIP), 1)
- ze_log("Admin [%s(%s - %s)]-[%s] [%L]", szAdminName, szAuthid, szIP, szPlayerName, LANG_PLAYER, "CMD_INFECTED")
- }
- }
- stock ze_log(const szMessageFmt[], any:...)
- {
- static szMessage[256], szFileName[32], szDate[16]
- vformat(szMessage, charsmax(szMessage), szMessageFmt, 2)
- format_time(szDate, charsmax(szDate), "%Y%m%d")
- formatex(szFileName, charsmax(szFileName), "ZombieEscape_%s.log", szDate)
- log_to_file(szFileName, "%s", szMessage)
- }
- public _ze_open_admin_menu(id)
- {
- if (!is_user_connected(id))
- {
- log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
- return false
- }
- Open_Admin_Menu(id)
- return true
- }
- register_native("LevelMenu","native_LevelMenu",1)