- #include <zombie_escape>
- #include <cstrike>
- // Setting File
- new const ZE_SETTINGS_FILE[] = "zombie_escape.ini"
- // Keys
- const OFFSET_CSMENUCODE = 205
- const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0
- // Access
- new g_szAccess_Make_Zombie[2] = "d"
- new g_szAccess_Make_Human[2] = "d"
- new g_szAccess_Make_Respawn[2] = "d"
- new g_iMaxPlayers, g_pCvarLogAdminCmds, bool:g_bIsZombieReleased, bool:g_bIsRoundEnded
- 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", "Respawn Player", g_szAccess_Make_Respawn, charsmax(g_szAccess_Make_Respawn)))
- amx_save_setting_string(ZE_SETTINGS_FILE, "Access Flags", "Respawn Player", g_szAccess_Make_Respawn)
- }
- public plugin_init()
- {
- register_plugin("[ZE] Addons: Admin szMenu", "1.0", "Jack GamePlay")
- // Cvars
- g_pCvarLogAdminCmds = register_cvar("ze_log_admin_commands", "1")
- // Menu Command
- register_clcmd("ze_am", "Open_Admin_Menu")
- // Commands
- 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)
- // Menu
- register_menu("Admin Menu", KEYSMENU, "Admin_Menu")
- // Max Players
- 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 Open_Admin_Menu(id)
- {
- static szMenu[250]
- new iLen
- // Title
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\wAdmin Menu^n^n")
- // 1. Make Zombie/Human
- if (get_user_flags(id) & (read_flags(g_szAccess_Make_Zombie) | read_flags(g_szAccess_Make_Human)))
- {
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w1. \wMake Zombie/Human^n")
- }
- // 2. Respawn Menu
- if (get_user_flags(id) & (read_flags(g_szAccess_Make_Respawn)))
- {
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w2. Respawn Menu^n")
- }
- // 0. Exit
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0. %L", id, "EXIT")
- // Fix for AMXX custom menus
- set_pdata_int(id, OFFSET_CSMENUCODE, 0)
- show_menu(id, KEYSMENU, szMenu, -1, "Admin Menu")
- }
- public Admin_Menu(id, key)
- {
- // Player disconnected?
- if (!is_user_connected(id))
- return PLUGIN_HANDLED
- switch (key)
- {
- case 0: // Make Zombie/Human
- {
- if (get_user_flags(id) & (read_flags(g_szAccess_Make_Zombie) | read_flags(g_szAccess_Make_Human)))
- {
- Make_ZMHM(id)
- }
- else
- {
- ze_colored_print(id, "!tYou have no access!y.")
- }
- }
- case 1: // Respawn Menu
- {
- if (get_user_flags(id) & (read_flags(g_szAccess_Make_Respawn)))
- {
- RespawnMenu(id)
- }
- else
- {
- ze_colored_print(id, "!tYou have no access!y.")
- }
- }
- }
- return PLUGIN_HANDLED
- }
- public Make_ZMHM(id)
- {
- static szMenu[128], szAdminName[32], szPlayerName[32]
- new iIndex, iMenuID, iItemData[2]
- get_user_name(id, szAdminName, charsmax(szAdminName))
- formatex(szMenu, charsmax(szMenu), "\wMake Zombie/Human^n")
- iMenuID = menu_create(szMenu, "Make_ZMHM_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[\rZombie\d]", szPlayerName)
- }
- else
- {
- formatex(szMenu, charsmax(szMenu), "\w%s \d[\rZombie\d]", szPlayerName)
- }
- }
- else
- {
- formatex(szMenu, charsmax(szMenu), "\d%s [Zombie]", szPlayerName)
- }
- }
- 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[\rHuman\d]", szPlayerName)
- }
- else
- {
- formatex(szMenu, charsmax(szMenu), "\w%s \d[\rHuman\d]", szPlayerName)
- }
- }
- else
- {
- formatex(szMenu, charsmax(szMenu), "\d%s [Human]", szPlayerName)
- }
- }
- 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 Make_ZMHM_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)
- Make_ZMHM(id)
- }
- else
- {
- ze_colored_print(id, "!tThis command is not available!y!")
- }
- }
- 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)
- Make_ZMHM(id)
- }
- else
- {
- ze_colored_print(id, "!tThis command is not available!y!")
- }
- }
- }
- 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, "[WGCS] %s is 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, "[WGCS] %s is 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_get_zombies_number() == 1)
- {
- ze_colored_print(Admin_ID, "!tCan't apply this action on the last zombie!y.")
- return
- }
- // Zombies have not been released yet
- if (!g_bIsZombieReleased)
- {
- ze_colored_print(Admin_ID, "!tThis command is available only after zombie appear!y.")
- 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))
- ze_cprint(0, "!yADMIN !g%s !tturn !g%s !tinto !gHuman", szAdminName, szPlayerName)
- // Log to Zombie Escape 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)] turned %s into human", szAdminName, szAuthid, szIP, szPlayerName)
- }
- }
- public Cmd_Zombie(Admin_ID, Player_ID)
- {
- // Prevent infecting last zombie
- if (ze_get_humans_number() == 1)
- {
- ze_colored_print(Admin_ID, "!tCan't apply this action on the last human!y!")
- return
- }
- // Game is already started
- if (ze_is_game_started())
- {
- // Zombie released
- if (!g_bIsZombieReleased)
- {
- ze_colored_print(Admin_ID, "!tThis command is available only after zombie appear!y.")
- 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))
- ze_cprint(0, "!yADMIN !g%s !tturn !g%s !tinto !gZombie", szAdminName, szPlayerName)
- // Log to Zombie Escape 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)] turned %s into zombie", szAdminName, szAuthid, szIP, szPlayerName)
- }
- }
- public RespawnMenu(id)
- {
- new RespawnPlayer = menu_create ("\wRespawn Menu", "RespawnMenu_Handler")
- new num, players[32], tempid, szTempID [10], tempname [32]
- get_players (players, num, "b")
- for (new i = 0; i < num; i++)
- {
- tempid = players [ i ]
- get_user_name (tempid, tempname, 31)
- num_to_str (tempid, szTempID, 9)
- menu_additem (RespawnPlayer, tempname, szTempID, 0)
- }
- menu_display (id, RespawnPlayer)
- return PLUGIN_HANDLED
- }
- public RespawnMenu_Handler(id, menu, item)
- {
- if(item == MENU_EXIT)
- {
- menu_destroy(menu)
- Open_Admin_Menu(id)
- return PLUGIN_HANDLED
- }
- new data[6], name[64]
- new access, callback
- menu_item_getinfo (menu, item, access, data, 5, name, 63, callback)
- new tempid = str_to_num (data)
- new szName[32], szAdminName[32]
- get_user_name(id, szName, charsmax(szName))
- get_user_name(tempid, szAdminName, charsmax(szAdminName))
- ze_colored_print(0, "!yADMIN !g%s !trespawned !g%s", szName, szAdminName)
- if(ze_is_game_started())
- {
- ExecuteHamB(Ham_CS_RoundRespawn, tempid)
- ze_set_user_human(id)
- }
- else if(g_bIsRoundEnded)
- {
- ze_colored_print(id, "!tYou cannot respawn the player when round ended!y!")
- }
- else
- {
- ExecuteHamB(Ham_CS_RoundRespawn, tempid)
- ze_set_user_human(id)
- rg_set_user_team(id, TEAM_CT)
- }
- RespawnMenu(id)
- /*Log to Zombie Escape log file?
- if (get_pcvar_num(g_pCvarLogAdminCmds))
- {
- new szAuthid[32], szIP[16]
- get_user_authid(id, szAuthid, charsmax(szAuthid))
- get_user_ip(id, szIP, charsmax(szIP), 1)
- ze_log("ADMIN [%s (%s - %s)] respawned %s", szAdminName, szAuthid, szIP, szName)
- }*/
- return PLUGIN_CONTINUE
- }
So, I added Respawn Menu in an Admin Menu Plugin made by @Night Fury
But the problem is when I respawn a player, it's showing Weapons Menu to other players who has already bought the weapons.
Here is my code: