Solved admin-menu

Unpaid Requests, Public Plugins
Post Reply
User avatar
Luxurious
Mod Tester
Mod Tester
Egypt
Posts: 177
Joined: 6 years ago
Location: Egypt
Contact:

admin-menu

#1

Post by Luxurious » 4 years ago

hello,
i tried to add Coins Menu + Level Menu to this admin menu but i failed , can any one help me !
  1. #include <zombie_escape>
  2.  
  3.  
  4. native CoinsMenu(id)
  5. native LevelMenu(id)
  6.  
  7.  
  8. new const ZE_SETTINGS_FILE[] = "zombie_escape.ini"
  9.  
  10. new g_szAccess_Make_Zombie[2] = "d"
  11. new g_szAccess_Make_Human[2] = "d"
  12. new g_szAccess_SetLevel[2] = "k"
  13. new g_szAccess_SetCoins[2] = "k"
  14.  
  15. new g_iMaxPlayers, bool:g_bIsZombieReleased, bool:g_bIsRoundEnded
  16. new g_pCvarAMXShowActivity, g_pCvarLogAdminCmds
  17.  
  18. public plugin_natives()
  19. {
  20.     register_native("ze_open_admin_menu", "_ze_open_admin_menu", 1)
  21. }
  22.  
  23. public plugin_precache()
  24. {
  25.     if (!amx_load_setting_string(ZE_SETTINGS_FILE, "Access Flags", "Make Zombie", g_szAccess_Make_Zombie, charsmax(g_szAccess_Make_Zombie)))
  26.         amx_save_setting_string(ZE_SETTINGS_FILE, "Access Flags", "Make Zombie", g_szAccess_Make_Zombie)
  27.  
  28.     if (!amx_load_setting_string(ZE_SETTINGS_FILE, "Access Flags", "Make Human", g_szAccess_Make_Human, charsmax(g_szAccess_Make_Human)))
  29.         amx_save_setting_string(ZE_SETTINGS_FILE, "Access Flags", "Make Human", g_szAccess_Make_Human)
  30.  
  31.    
  32.     if (!amx_load_setting_string(ZE_SETTINGS_FILE, "Access Flags", "Level Menu", g_szAccess_SetLevel, charsmax(g_szAccess_SetLevel)))
  33.         amx_save_setting_string(ZE_SETTINGS_FILE, "Access Flags", "Level Menu", g_szAccess_SetLevel)
  34.    
  35.     if (!amx_load_setting_string(ZE_SETTINGS_FILE, "Access Flags", "Coins Menu", g_szAccess_SetCoins, charsmax(g_szAccess_SetCoins)))
  36.         amx_save_setting_string(ZE_SETTINGS_FILE, "Access Flags", "Coins Menu", g_szAccess_SetCoins)
  37.  
  38.  
  39. }
  40.  
  41. public plugin_init()
  42. {
  43.     register_plugin("[ZE] Addons: Admin szMenu", "1.0", "Jack GamePlay")
  44.  
  45.     register_clcmd("say /am", "Open_Admin_Menu")
  46.  
  47.     register_concmd("ze_zombie", "Zombie_Cmd", _, "<target> - Turn someone into a zombie", 0)
  48.     register_concmd("ze_human", "Human_Cmd", _, "<target> - Turn someone back to human", 0)
  49.    
  50.  
  51.     g_pCvarLogAdminCmds = register_cvar("ze_log_admin_commands", "1")
  52.  
  53.     g_iMaxPlayers = get_member_game(m_nMaxPlayers)
  54. }
  55.  
  56. public ze_zombie_appear()
  57. {
  58.     g_bIsZombieReleased = false
  59.     g_bIsRoundEnded = false
  60. }
  61.  
  62. public ze_game_started()
  63. {
  64.     g_bIsZombieReleased = false
  65.     g_bIsRoundEnded = false
  66. }
  67.  
  68. public ze_zombie_release()
  69. {
  70.     g_bIsZombieReleased = true
  71.     g_bIsRoundEnded = false
  72. }
  73.  
  74. public ze_roundend()
  75. {
  76.     g_bIsRoundEnded = true
  77.     g_bIsZombieReleased = false
  78. }
  79.  
  80. public plugin_cfg()
  81. {
  82.     g_pCvarAMXShowActivity = get_cvar_pointer("amx_show_activity")
  83. }
  84.  
  85. public Open_Admin_Menu(id)
  86. {
  87.     static szMenu[250]
  88.     new iMenuID
  89.    
  90.     formatex(szMenu, charsmax(szMenu), "\y%L:^n^n", LANG_PLAYER, "MENU_ADMIN_TITLE")
  91.     iMenuID = menu_create(szMenu, "Admin_Menu_Handler")
  92.    
  93.     if (get_user_flags(id) & (read_flags(g_szAccess_Make_Zombie) | read_flags(g_szAccess_Make_Human)))
  94.         formatex(szMenu, charsmax(szMenu), "\w%L^n", LANG_PLAYER, "MAKE_HM_ZM")
  95.     else
  96.         formatex(szMenu, charsmax(szMenu), "\d%L^n", LANG_PLAYER, "MAKE_HM_ZM")
  97.     menu_additem(iMenuID, szMenu)
  98.    
  99.     if (get_user_flags(id) & (read_flags(g_szAccess_SetLevel))
  100.         formatex(szMenu, charsmax(szMenu), "\w%L^n", LANG_PLAYER, "LEVEL_MENU")
  101.     else
  102.         formatex(szMenu, charsmax(szMenu), "\d%L^n", LANG_PLAYER, "LEVEL_MENU")
  103.     menu_additem(iMenuID, szMenu)
  104.  
  105.  if (get_user_flags(id) & (read_flags(g_szAccess_SetCoins))
  106.         formatex(szMenu, charsmax(szMenu), "\w%L^n", LANG_PLAYER, "COINS_MENU")
  107.     else
  108.         formatex(szMenu, charsmax(szMenu), "\d%L^n", LANG_PLAYER, "COINS_MENU")
  109.     menu_additem(iMenuID, szMenu)
  110.  
  111.  
  112.  
  113.     menu_display(id, iMenuID, 0, 30)
  114. }
  115.  
  116. public Admin_Menu_Handler(id, iMenuID, iKey)
  117. {
  118.     // Player disconnected?
  119.     if (!is_user_connected(id))
  120.         return PLUGIN_HANDLED
  121.    
  122.     switch (iKey)
  123.     {
  124.         case 0:
  125.         {
  126.             if (get_user_flags(id) & (read_flags(g_szAccess_Make_Zombie) | read_flags(g_szAccess_Make_Human)))
  127.             {
  128.                 Show_Player_Menu(id)
  129.             }
  130.             else
  131.             {
  132.                 ze_colored_print(id, "%L", LANG_PLAYER, "CMD_NOT_ACCESS")
  133.                 Open_Admin_Menu(id)
  134.             }
  135.        
  136.        {
  137.        
  138.         case 1:
  139.         {
  140.             if (get_user_flags(id) & (read_flags(g_szAccess_SetLevel))
  141.             {
  142.                 LevelMenu(id)
  143.             }
  144.             else
  145.             {
  146.                 ze_colored_print(id, "%L", LANG_PLAYER, "CMD_NOT_ACCESS")
  147.                 Open_Admin_Menu(id)
  148.             }
  149.        
  150.         {
  151.           case 2:
  152.         {
  153.             if (get_user_flags(id) & (read_flags(g_szAccess_SetCoins))
  154.             {
  155.                 CoinsMenu(id)
  156.             }
  157.             else
  158.             {
  159.                 ze_colored_print(id, "%L", LANG_PLAYER, "CMD_NOT_ACCESS")
  160.                 Open_Admin_Menu(id)
  161.             }
  162.         }
  163.     }
  164.  
  165.     menu_destroy(iMenuID)
  166.     return PLUGIN_HANDLED
  167. }
  168.  
  169. public Show_Player_Menu(id)
  170. {
  171.     static szMenu[128], szAdminName[32], szPlayerName[32]
  172.     new iIndex, iMenuID, iItemData[2]
  173.  
  174.     get_user_name(id, szAdminName, charsmax(szAdminName))
  175.  
  176.     formatex(szMenu, charsmax(szMenu), "%L:^n^n", LANG_PLAYER, "MAKE_HM_ZM")
  177.     iMenuID = menu_create(szMenu, "Player_Menu_Handler")
  178.  
  179.     for (iIndex = 0; iIndex <= g_iMaxPlayers; iIndex++)
  180.     {
  181.         if (!is_user_connected(iIndex))
  182.             continue
  183.  
  184.         get_user_name(iIndex, szPlayerName, charsmax(szPlayerName))
  185.  
  186.         if (ze_is_user_zombie(iIndex))
  187.         {
  188.             if ((get_user_flags(id) & read_flags(g_szAccess_Make_Human)) && is_user_alive(iIndex) && g_bIsZombieReleased && !g_bIsRoundEnded)
  189.             {
  190.                 if (equali(szPlayerName, szAdminName))
  191.                     formatex(szMenu, charsmax(szMenu), "\y%s \d[\r%L\d]", szPlayerName, LANG_PLAYER, "CLASS_ZOMBIE")
  192.                 else
  193.                     formatex(szMenu, charsmax(szMenu), "\w%s \d[\r%L\d]", szPlayerName, LANG_PLAYER, "CLASS_ZOMBIE")
  194.             }
  195.             else
  196.                 formatex(szMenu, charsmax(szMenu), "\d%s [%L]", szPlayerName, LANG_PLAYER, "CLASS_ZOMBIE")
  197.         }
  198.         else
  199.         {
  200.             if ((get_user_flags(id) & read_flags(g_szAccess_Make_Zombie)) && is_user_alive(iIndex) && g_bIsZombieReleased && !g_bIsRoundEnded)
  201.             {
  202.                 if (equali(szPlayerName, szAdminName))
  203.                     formatex(szMenu, charsmax(szMenu), "\y%s \d[\r%L\d]", szPlayerName, LANG_PLAYER, "CLASS_HUMAN")
  204.                 else
  205.                     formatex(szMenu, charsmax(szMenu), "\w%s \d[\r%L\d]", szPlayerName, LANG_PLAYER, "CLASS_HUMAN")
  206.             }
  207.             else
  208.                 formatex(szMenu, charsmax(szMenu), "\d%s [%L]", szPlayerName, LANG_PLAYER, "CLASS_HUMAN")
  209.         }
  210.  
  211.         iItemData[0] = iIndex
  212.         iItemData[1] = 0
  213.         menu_additem(iMenuID, szMenu, iItemData)
  214.     }
  215.  
  216.     // Back - Next - Exit
  217.     formatex(szMenu, charsmax(szMenu), "%L", LANG_PLAYER, "BACK")
  218.     menu_setprop(iMenuID, MPROP_BACKNAME, szMenu)
  219.     formatex(szMenu, charsmax(szMenu), "%L", LANG_PLAYER, "NEXT")
  220.     menu_setprop(iMenuID, MPROP_NEXTNAME, szMenu)
  221.     formatex(szMenu, charsmax(szMenu), "%L", LANG_PLAYER, "EXIT")
  222.     menu_setprop(iMenuID, MPROP_EXITNAME, szMenu)
  223.  
  224.     menu_display(id, iMenuID, 0, 30)
  225. }
  226.  
  227. public Player_Menu_Handler(id, iMenuID, iKey)
  228. {
  229.     if (iKey == MENU_EXIT)
  230.     {
  231.         menu_destroy(iMenuID)
  232.         Open_Admin_Menu(id)
  233.         return PLUGIN_HANDLED
  234.     }
  235.    
  236.     new iItemData[2], iDummy, iPlayer
  237.     menu_item_getinfo(iMenuID, iKey, iDummy, iItemData, charsmax(iItemData), _, _, iDummy)
  238.     iPlayer = iItemData[0]
  239.  
  240.     if (is_user_connected(iPlayer))
  241.     {
  242.         if (ze_is_user_zombie(iPlayer))
  243.         {
  244.             if ((get_user_flags(id) & read_flags(g_szAccess_Make_Human)) && is_user_alive(iPlayer) && g_bIsZombieReleased && !g_bIsRoundEnded)
  245.                 {
  246.                     ze_admin_command_human(id, iPlayer)
  247.                     Show_Player_Menu(id)
  248.                 }
  249.             else
  250.                 ze_colored_print(id, "%L", LANG_PLAYER, "CMD_NOT")
  251.         }
  252.         else
  253.         {
  254.             if ((get_user_flags(id) & read_flags(g_szAccess_Make_Zombie)) && is_user_alive(iPlayer) && g_bIsZombieReleased && !g_bIsRoundEnded)
  255.                 {
  256.                     ze_admin_command_zombie(id, iPlayer)
  257.                     Show_Player_Menu(id)
  258.                 }
  259.             else
  260.                 ze_colored_print(id, "%L", LANG_PLAYER, "CMD_NOT")
  261.         }
  262.     }
  263.  
  264.     menu_destroy(iMenuID)
  265.     return PLUGIN_HANDLED
  266. }
  267.  
  268. public ze_admin_command_human(Admin_ID, Player_ID)
  269. {
  270.     if (!is_user_connected(Admin_ID))
  271.     {
  272.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", Admin_ID)
  273.         return false
  274.     }
  275.    
  276.     if (!is_user_alive(Player_ID))
  277.     {
  278.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", Player_ID)
  279.         return false
  280.     }
  281.    
  282.     Cmd_Human(Admin_ID, Player_ID)
  283.     return true
  284. }
  285.  
  286. public ze_admin_command_zombie(Admin_ID, Player_ID)
  287. {
  288.     if (!is_user_connected(Admin_ID))
  289.     {
  290.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", Admin_ID)
  291.         return false
  292.     }
  293.    
  294.     if (!is_user_alive(Player_ID))
  295.     {
  296.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", Player_ID)
  297.         return false
  298.     }
  299.    
  300.     Cmd_Zombie(Admin_ID, Player_ID)
  301.     return true
  302. }
  303.  
  304. public Human_Cmd(Admin_ID, level, cid)
  305. {
  306.     // Check for access flag - Make Human
  307.     if (!cmd_access(Admin_ID, read_flags(g_szAccess_Make_Human), cid, 2))
  308.         return PLUGIN_HANDLED
  309.    
  310.     // Retrieve arguments
  311.     new szArg[32], Player_ID
  312.     read_argv(1, szArg, charsmax(szArg))
  313.     Player_ID = cmd_target(Admin_ID, szArg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF))
  314.    
  315.     // Invalid target
  316.     if (!Player_ID || !g_bIsZombieReleased || g_bIsRoundEnded)
  317.         return PLUGIN_HANDLED
  318.    
  319.     // Target not allowed to be human
  320.     if (!ze_is_user_zombie(Player_ID))
  321.     {
  322.         new szPlayerName[32]
  323.         get_user_name(Player_ID, szPlayerName, charsmax(szPlayerName))
  324.         client_print(Admin_ID, print_console, "[ZE] %L (%s).", LANG_PLAYER, "ALREADY_HUMAN", szPlayerName)
  325.         return PLUGIN_HANDLED
  326.     }
  327.    
  328.     Cmd_Human(Admin_ID, Player_ID)
  329.     return PLUGIN_HANDLED
  330. }
  331.  
  332. public Zombie_Cmd(Admin_ID, level, cid)
  333. {
  334.     // Check for access flag - Make Human
  335.     if (!cmd_access(Admin_ID, read_flags(g_szAccess_Make_Zombie), cid, 2))
  336.         return PLUGIN_HANDLED
  337.    
  338.     // Retrieve arguments
  339.     new szArg[32], Player_ID
  340.     read_argv(1, szArg, charsmax(szArg))
  341.     Player_ID = cmd_target(Admin_ID, szArg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF))
  342.    
  343.     // Invalid target
  344.     if (!Player_ID || !g_bIsZombieReleased  || g_bIsRoundEnded)
  345.         return PLUGIN_HANDLED
  346.    
  347.     // Target not allowed to be human
  348.     if (ze_is_user_zombie(Player_ID))
  349.     {
  350.         new szPlayerName[32]
  351.         get_user_name(Player_ID, szPlayerName, charsmax(szPlayerName))
  352.         client_print(Admin_ID, print_console, "[ZE] %L (%s).", LANG_PLAYER, "ALREADY_ZOMBIE", szPlayerName)
  353.         return PLUGIN_HANDLED
  354.     }
  355.    
  356.     Cmd_Zombie(Admin_ID, Player_ID)
  357.     return PLUGIN_HANDLED
  358. }
  359.  
  360. public Cmd_Human(Admin_ID, Player_ID)
  361. {
  362.     // Prevent infecting last zombie
  363.     //if (ze_is_last_zombie(Player_ID))
  364.     if (ze_get_zombies_number() == 1)
  365.     {
  366.         ze_colored_print(Admin_ID, "%L", LANG_PLAYER, "CMD_CANT_LAST_ZOMBIE")
  367.         return
  368.     }
  369.    
  370.     // Zombies have not been released yet
  371.     if (!g_bIsZombieReleased)
  372.     {
  373.         ze_colored_print(Admin_ID, "%L", LANG_PLAYER, "CMD_ONLY_AFTER_GAME_MODE")
  374.         return
  375.     }
  376.    
  377.     ze_set_user_human(Player_ID)
  378.    
  379.     // Get user names
  380.     new szAdminName[32], szPlayerName[32]
  381.     get_user_name(Admin_ID, szAdminName, charsmax(szAdminName))
  382.     get_user_name(Player_ID, szPlayerName, charsmax(szPlayerName))
  383.    
  384.     // Show activity?
  385.     if (g_pCvarAMXShowActivity)
  386.     {
  387.         switch (get_pcvar_num(g_pCvarAMXShowActivity))
  388.         {
  389.             case 1: ze_colored_print(0, "!tAdmin !y- !g%s !t%L", szPlayerName, LANG_PLAYER, "CMD_CURED")
  390.             case 2: ze_colored_print(0, "!tAdmin !g%s !y- !g%s !t%L", szAdminName, szPlayerName, LANG_PLAYER, "CMD_CURED")
  391.         }
  392.     }
  393.    
  394.     // Log to Zombie Plague log file?
  395.     if (get_pcvar_num(g_pCvarLogAdminCmds))
  396.     {
  397.         new szAuthid[32], szIP[16]
  398.         get_user_authid(Admin_ID, szAuthid, charsmax(szAuthid))
  399.         get_user_ip(Admin_ID, szIP, charsmax(szIP), 1)
  400.         ze_log("Admin [%s (%s - %s)] - [%s] [%L]", szAdminName, szAuthid, szIP, szPlayerName, LANG_PLAYER, "CMD_CURED")
  401.     }
  402. }
  403.  
  404. public Cmd_Zombie(Admin_ID, Player_ID)
  405. {
  406.     // Prevent infecting last zombie
  407.     //if (ze_is_last_human(Player_ID))
  408.     if (ze_get_humans_number() == 1)
  409.     {
  410.         ze_colored_print(Admin_ID, "%L", LANG_PLAYER, "CMD_CANT_LAST_HUMAN")
  411.         return
  412.     }
  413.    
  414.     // Game is already started
  415.     if (ze_is_game_started())
  416.     {
  417.         // Zombie released
  418.         if (!g_bIsZombieReleased)
  419.         {
  420.             ze_colored_print(Admin_ID, "%L", LANG_PLAYER, "CMD_ONLY_AFTER_GAME_MODE")
  421.             return
  422.         }
  423.     }
  424.    
  425.     ze_set_user_zombie(Player_ID)
  426.    
  427.     // Get user names
  428.     new szAdminName[32], szPlayerName[32]
  429.     get_user_name(Admin_ID, szAdminName, charsmax(szAdminName))
  430.     get_user_name(Player_ID, szPlayerName, charsmax(szPlayerName))
  431.    
  432.     // Show activity?
  433.     if (g_pCvarAMXShowActivity)
  434.     {
  435.         switch (get_pcvar_num(g_pCvarAMXShowActivity))
  436.         {
  437.             case 1: ze_colored_print(0, "!tAdmin !y- !g%s !t%L", szPlayerName, LANG_PLAYER, "CMD_INFECTED")
  438.             case 2: ze_colored_print(0, "!tAdmin !g%s !y- !g%s !t%L", szAdminName, szPlayerName, LANG_PLAYER, "CMD_INFECTED")
  439.         }
  440.     }
  441.    
  442.     // Log to Zombie Plague log file?
  443.     if (get_pcvar_num(g_pCvarLogAdminCmds))
  444.     {
  445.         new szAuthid[32], szIP[16]
  446.         get_user_authid(Admin_ID, szAuthid, charsmax(szAuthid))
  447.         get_user_ip(Admin_ID, szIP, charsmax(szIP), 1)
  448.         ze_log("Admin [%s(%s - %s)]-[%s] [%L]", szAdminName, szAuthid, szIP, szPlayerName, LANG_PLAYER, "CMD_INFECTED")
  449.     }
  450. }
  451.  
  452. stock ze_log(const szMessageFmt[], any:...)
  453. {
  454.     static szMessage[256], szFileName[32], szDate[16]
  455.     vformat(szMessage, charsmax(szMessage), szMessageFmt, 2)
  456.     format_time(szDate, charsmax(szDate), "%Y%m%d")
  457.     formatex(szFileName, charsmax(szFileName), "ZombieEscape_%s.log", szDate)
  458.     log_to_file(szFileName, "%s", szMessage)
  459. }
  460.  
  461. public _ze_open_admin_menu(id)
  462. {
  463.     if (!is_user_connected(id))
  464.     {
  465.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
  466.         return false
  467.     }
  468.    
  469.     Open_Admin_Menu(id)
  470.     return true
  471. }
Natives :
  1.   register_native("CoinsMenu","native_CoinsMenu",1)
and :
  1.   register_native("LevelMenu","native_LevelMenu",1)
DRK Zombie-Escape V1.6
IP : 81.169.153.129:27015

User avatar
Luxurious
Mod Tester
Mod Tester
Egypt
Posts: 177
Joined: 6 years ago
Location: Egypt
Contact:

#2

Post by Luxurious » 4 years ago

solved !
DRK Zombie-Escape V1.6
IP : 81.169.153.129:27015

snitch
Member
Member
Turkey
Posts: 24
Joined: 4 years ago
Contact:

#3

Post by snitch » 4 years ago

can you upload the fixed?

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 5 guests