Advertisement
Sugisaki

[AMXX] Pug Menu GG

Mar 28th, 2017
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.31 KB | None | 0 0
  1. #include <amxmodx>
  2.  
  3. #define PLUGIN  "PUG MENU"
  4. #define VERSION "1.0"
  5. #define AUTHOR  ""
  6.  
  7. new menu
  8. new call
  9.  
  10. native pug_get_state()
  11.  
  12. stock is_user_admin(id)
  13. {
  14.     new __flags=get_user_flags(id);
  15.     return (__flags>0 && !(__flags&ADMIN_USER));
  16. }
  17.  
  18. public plugin_init()
  19. {
  20.     register_plugin(PLUGIN, VERSION, AUTHOR)
  21.  
  22.     menu = menu_create("\yPug Menu", "mh_pug_menu")
  23.     call = menu_makecallback("check_admin")
  24.     menu_additem(menu, "Ready", "1", 0, call)
  25.     menu_additem(menu, "UnReady", "2", 0, call)
  26.     menu_additem(menu, "DMG", "3", 0, call)
  27.     menu_additem(menu, "Score", "6", 0, call)
  28.     menu_additem(menu, "Force Ready", "4", 0, call)
  29.     menu_additem(menu, "Cancel Pug", "5", 0, call)
  30.     menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  31.  
  32.     register_clcmd("nightvision", "pfn_pug_menu")
  33. }
  34. public check_admin(id, menu, item)
  35. {
  36.     new info[4], a
  37.     menu_item_getinfo(menu, item, a, info, charsmax(info), "", 0, a)
  38.  
  39.     new item_id = str_to_num(info)
  40.  
  41.     if(pug_get_state() == 0)
  42.     {
  43.         switch(item_id)
  44.         {
  45.             case 1: return ITEM_ENABLED
  46.             case 2: return ITEM_ENABLED
  47.             case 3: return ITEM_DISABLED
  48.             case 4:
  49.             {
  50.                 if(!is_user_admin(id))
  51.                 {
  52.                     return ITEM_DISABLED
  53.                 }
  54.                 return ITEM_ENABLED
  55.             }
  56.             case 5: return ITEM_DISABLED
  57.             case 6: return ITEM_DISABLED
  58.         }
  59.     }
  60.     else
  61.     {
  62.         switch(item_id)
  63.         {
  64.             case 1 : return ITEM_DISABLED
  65.             case 2 : return ITEM_DISABLED
  66.             case 3 : return ITEM_ENABLED
  67.             case 4 : return ITEM_DISABLED
  68.             case 5 :
  69.             {
  70.                 if(!is_user_admin(id))
  71.                 {
  72.                     return ITEM_DISABLED
  73.                 }
  74.                 return ITEM_ENABLED
  75.             }
  76.             case 6: return ITEM_ENABLED
  77.         }
  78.     }
  79.     return ITEM_ENABLED
  80. }
  81. public mh_pug_menu(id, menu, item)
  82. {
  83.     if(item == MENU_EXIT)
  84.     {
  85.         return
  86.     }
  87.  
  88.     new info[4], a
  89.     menu_item_getinfo(menu, item, a, info, charsmax(info), "", 0, a)
  90.  
  91.     new item_id = str_to_num(info)
  92.  
  93.     switch(item_id)
  94.     {
  95.         case 1 : client_cmd2(id, "say .ready")
  96.         case 2 : client_cmd2(id, "say .unready")
  97.         case 3 : client_cmd2(id, "say .dmg")
  98.         case 4 : client_cmd2(id, "say .forceready")
  99.         case 5 : client_cmd2(id, "say .cancel")
  100.         case 6 : client_cmd2(id, "say .score")
  101.     }
  102. }
  103. public pfn_pug_menu(id)
  104. {
  105.     menu_display(id, menu)
  106. }
  107. stock client_cmd2(id, cmd[])
  108. {
  109.     message_begin(MSG_ONE, SVC_DIRECTOR, _, id)
  110.     write_byte(strlen(cmd) + 2)
  111.     write_byte(10)
  112.     write_string(cmd)
  113.     message_end()
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement