Solved please help with the VIP weapons menu

Coding Help/Re-API Supported
Post Reply
User avatar
Urban
Member
Member
Ukraine
Posts: 12
Joined: 3 years ago
Contact:

please help with the VIP weapons menu

#1

Post by Urban » 3 years ago

Hello everyone, I ran into a problem, I want to make a custom weapon menu for vip, does not display custom weapon menu items. Here is the code, I edited two functions public Buy_Primary_Weapon (id, selection) and public Show_Menu_Buy_Primary (id), where get_user_flags (id) and ADMIN_LEVEL_H
help me figure out what my mistake is.

  1. #include <zombie_escape>
  2. #include <ze_levels>
  3.  
  4. native ze_weapon_m3(id);
  5. native give_golden_mp5(id);
  6. native ze_weapon_m4a1(id);
  7. native give_golden_ak47(id);
  8.  
  9. // Setting File
  10. new const ZE_SETTING_RESOURCES[] = "zombie_escape.ini"
  11.  
  12. // Keys
  13. 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
  14. const OFFSET_CSMENUCODE = 205
  15.  
  16. // Primary Weapons Entities [Default Values]
  17. new const szPrimaryWeaponEnt[][] =
  18. {
  19.     "weapon_xm1014",  // Level 0
  20.     "weapon_ump45",   // Level 0
  21.     "weapon_m3",      // Level 1
  22.     "weapon_mp5navy", // Level 2
  23.     "weapon_p90",     // Level 3
  24.     "weapon_galil",   // Level 4
  25.     "weapon_famas",   // Level 5
  26.     "weapon_sg550",   // Level 6
  27.     "weapon_g3sg1",   // Level 7
  28.     "weapon_m249",    // Level 8
  29.     "weapon_sg552",   // Level 9
  30.     "weapon_aug",     // Level 10
  31.     "weapon_m4a1",    // Level 11
  32.     "weapon_ak47"     // Level 12
  33. }
  34.  
  35. // Secondary Weapons Entities [Default Values]
  36. new const szSecondaryWeaponEnt[][]=
  37. {
  38.     "weapon_usp",         // Level 0
  39.     "weapon_p228",        // Level 0
  40.     "weapon_glock18",     // Level 1
  41.     "weapon_fiveseven",   // Level 2
  42.     "weapon_deagle",      // Level 3
  43.     "weapon_elite"        // Level 4
  44. }
  45.  
  46. // Primary and Secondary Weapons Names [Default Values]
  47. new const szWeaponNames[][] =
  48. {
  49.     "",
  50.     "P228",
  51.     "",
  52.     "Scout",
  53.     "HE Grenade",
  54.     "XM1014",
  55.     "",
  56.     "MAC-10",
  57.     "AUG",
  58.     "Smoke Grenade",
  59.     "Dual Elite",
  60.     "Five Seven",
  61.     "UMP 45",
  62.     "SG-550",
  63.     "Galil",
  64.     "Famas",
  65.     "USP",
  66.     "Glock",
  67.     "AWP",
  68.     "MP5",
  69.     "M249",
  70.     "M3",
  71.     "M4A1",
  72.     "TMP",
  73.     "G3SG1",
  74.     "Flashbang",
  75.     "Desert Eagle",
  76.     "SG-552",
  77.     "AK-47",
  78.     "",
  79.     "P90"
  80. }
  81.  
  82. // Max Back Clip Ammo (Change it From here if you need)
  83. new const szMaxBPAmmo[] =
  84. {
  85.     -1,
  86.     220,
  87.     -1,
  88.     220,
  89.     1,
  90.     220,
  91.     1,
  92.     220,
  93.     220,
  94.     1,
  95.     220,
  96.     220,
  97.     220,
  98.     220,
  99.     220,
  100.     220,
  101.     220,
  102.     220,
  103.     220,
  104.     220,
  105.     220,
  106.     220,
  107.     220,
  108.     220,
  109.     220,
  110.     2,
  111.     220,
  112.     220,
  113.     220,
  114.     -1,
  115.     220
  116. }
  117.  
  118. // Menu selections
  119. const MENU_KEY_AUTOSELECT = 7
  120. const MENU_KEY_BACK = 7
  121. const MENU_KEY_NEXT = 8
  122. const MENU_KEY_EXIT = 9
  123.  
  124. // Variables
  125. new Array:g_szPrimaryWeapons, Array:g_szSecondaryWeapons
  126.  
  127. new g_iMenuData[33][4],
  128.     Float:g_fBuyTimeStart[33],
  129.     bool:g_bBoughtPrimary[33],
  130.     bool:g_bBoughtSecondary[33],
  131.     WPN_MAXIDS[33]
  132.  
  133. // Define
  134. #define WPN_STARTID g_iMenuData[id][0]
  135. #define WPN_SELECTION (g_iMenuData[id][0]+key)
  136. #define WPN_AUTO_ON g_iMenuData[id][1]
  137. #define WPN_AUTO_PRI g_iMenuData[id][2]
  138. #define WPN_AUTO_SEC g_iMenuData[id][3]
  139.  
  140. // Cvars
  141. new g_pCvarBuyTime,
  142.     g_pCvarHeGrenade,
  143.     g_pCvarSmokeGrenade,
  144.     g_pCvarFlashGrenade,
  145.     g_pCvarBlockWeapLowLevel
  146.  
  147. public plugin_natives()
  148. {
  149.     register_native("ze_show_weapon_menu", "native_ze_show_weapon_menu", 1)
  150.     register_native("ze_is_auto_buy_enabled", "native_ze_is_auto_buy_enabled", 1)
  151.     register_native("ze_disable_auto_buy", "native_ze_disable_auto_buy", 1)
  152. }
  153.  
  154. public plugin_precache()
  155. {
  156.     // Initialize arrays (32 is the max length of Weapon Entity like: weapon_ak47)
  157.     g_szPrimaryWeapons = ArrayCreate(32, 1)
  158.     g_szSecondaryWeapons = ArrayCreate(32, 1)
  159.    
  160.     // Load from external file
  161.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
  162.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
  163.    
  164.     // If we couldn't load from file, use and save default ones
  165.    
  166.     new iIndex
  167.    
  168.     if (ArraySize(g_szPrimaryWeapons) == 0)
  169.     {
  170.         for (iIndex = 0; iIndex < sizeof szPrimaryWeaponEnt; iIndex++)
  171.             ArrayPushString(g_szPrimaryWeapons, szPrimaryWeaponEnt[iIndex])
  172.        
  173.         // If not found .ini File Create it and save default values in it
  174.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
  175.     }
  176.    
  177.     if (ArraySize(g_szSecondaryWeapons) == 0)
  178.     {
  179.         for (iIndex = 0; iIndex < sizeof szSecondaryWeaponEnt; iIndex++)
  180.             ArrayPushString(g_szSecondaryWeapons, szSecondaryWeaponEnt[iIndex])
  181.        
  182.         // If not found .ini File Create it and save default values in it
  183.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
  184.     }
  185. }
  186.  
  187. public plugin_init()
  188. {
  189.     register_plugin("[ZE] Levels Weapons Menu", "1.1", "Raheem")
  190.    
  191.     // Commands
  192.     register_clcmd("guns", "Cmd_Buy")
  193.     register_clcmd("say /enable", "Cmd_Enable")
  194.     register_clcmd("say_team /enable", "Cmd_Enable")
  195.    
  196.     // Cvars
  197.     g_pCvarBuyTime = register_cvar("ze_buy_time", "60")
  198.     g_pCvarHeGrenade = register_cvar("ze_give_HE_nade", "1") // 0 Nothing || 1 Give HE
  199.     g_pCvarSmokeGrenade = register_cvar("ze_give_SM_nade", "1")
  200.     g_pCvarFlashGrenade = register_cvar("ze_give_FB_nade", "1")
  201.     g_pCvarBlockWeapLowLevel = register_cvar("ze_block_weapons_lowlvl", "1")
  202.    
  203.     // Menus
  204.     register_menu("Primary Weapons", KEYSMENU, "Menu_Buy_Primary")
  205.     register_menu("Secondary Weapons", KEYSMENU, "Menu_Buy_Secondary")
  206.    
  207.     // Hams
  208.     RegisterHam(Ham_Touch, "weaponbox", "Fw_TouchWeapon_Pre", 0)
  209.     RegisterHam(Ham_Touch, "armoury_entity", "Fw_TouchWeapon_Pre", 0)
  210. }
  211.  
  212. public client_disconnected(id)
  213. {
  214.     WPN_AUTO_ON = 0
  215.     WPN_STARTID = 0
  216. }
  217.  
  218. public Cmd_Enable(id)
  219. {
  220.     if (WPN_AUTO_ON)
  221.     {
  222.         ze_colored_print(id, "%L", LANG_PLAYER, "BUY_ENABLED")
  223.         WPN_AUTO_ON = 0
  224.     }
  225. }
  226.  
  227. public Cmd_Buy(id)
  228. {
  229.     // Player Zombie
  230.     if (ze_is_user_zombie(id))
  231.     {
  232.         ze_colored_print(id, "%L", LANG_PLAYER, "NO_BUY_ZOMBIE")
  233.         return
  234.     }
  235.    
  236.     // Player Dead
  237.     if (!is_user_alive(id))
  238.     {
  239.         ze_colored_print(id, "%L", LANG_PLAYER, "DEAD_CANT_BUY_WEAPON")
  240.         return
  241.     }
  242.    
  243.     // Already bought
  244.     if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
  245.     {
  246.         ze_colored_print(id, "%L", LANG_PLAYER, "ALREADY_BOUGHT")
  247.     }
  248.    
  249.     Show_Available_Buy_Menus(id)
  250. }
  251.  
  252. public ze_user_humanized(id)
  253. {
  254.     // Static Values
  255.     switch (ze_get_user_level(id))
  256.     {
  257.         case 0: WPN_MAXIDS[id] = 2
  258.         case 1: WPN_MAXIDS[id] = 3
  259.         case 2: WPN_MAXIDS[id] = 4
  260.         case 3: WPN_MAXIDS[id] = 5
  261.         case 4: WPN_MAXIDS[id] = 6
  262.         case 5: WPN_MAXIDS[id] = 7
  263.         case 6: WPN_MAXIDS[id] = 8
  264.         case 7: WPN_MAXIDS[id] = 9
  265.         case 8: WPN_MAXIDS[id] = 10
  266.         case 9: WPN_MAXIDS[id] = 11
  267.         case 10: WPN_MAXIDS[id] = 12
  268.         case 11: WPN_MAXIDS[id] = 13
  269.         case 12..14: WPN_MAXIDS[id] = 14
  270.         case 15..19: WPN_MAXIDS[id] = 15 // Golden m3
  271.         case 20..24: WPN_MAXIDS[id] = 16 // Golden MP5
  272.         case 25..29: WPN_MAXIDS[id] = 17 // Golden M4A1
  273.         case 30: WPN_MAXIDS[id] = 18     // Golden AK47
  274.     }
  275.    
  276.     if (ze_get_user_level(id) > 30)
  277.     {
  278.         WPN_MAXIDS[id] = 18
  279.     }
  280.  
  281.     // Buyzone time starts when player is set to human
  282.     g_fBuyTimeStart[id] = get_gametime()
  283.    
  284.     g_bBoughtPrimary[id] = false
  285.     g_bBoughtSecondary[id] = false
  286.    
  287.     // Player dead or zombie
  288.     if (!is_user_alive(id) || ze_is_user_zombie(id))
  289.         return
  290.    
  291.     if (WPN_AUTO_ON)
  292.     {
  293.         ze_colored_print(id, "%L", LANG_PLAYER, "RE_ENABLE_MENU")
  294.         Buy_Primary_Weapon(id, WPN_AUTO_PRI)
  295.         Buy_Secondary_Weapon(id, WPN_AUTO_SEC)
  296.     }
  297.    
  298.     // Open available buy menus
  299.     Show_Available_Buy_Menus(id)
  300.    
  301.     // Give HE Grenade
  302.     if (get_pcvar_num(g_pCvarHeGrenade) != 0)
  303.         rg_give_item(id, "weapon_hegrenade")
  304.    
  305.     // Give Smoke Grenade
  306.     if (get_pcvar_num(g_pCvarSmokeGrenade) != 0)
  307.         rg_give_item(id, "weapon_smokegrenade")
  308.    
  309.     // Give Flashbang Grenade
  310.     if (get_pcvar_num(g_pCvarFlashGrenade) != 0)
  311.         rg_give_item(id, "weapon_flashbang")
  312. }
  313.  
  314. public Show_Available_Buy_Menus(id)
  315. {
  316.     // Already Bought
  317.     if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
  318.         return
  319.    
  320.     // Here we use if and else if so we make sure that Primary weapon come first then secondary
  321.     if (!g_bBoughtPrimary[id])
  322.     {
  323.         // Primary     
  324.         Show_Menu_Buy_Primary(id)
  325.     }
  326.     else if (!g_bBoughtSecondary[id])
  327.     {
  328.         // Secondary
  329.         Show_Menu_Buy_Secondary(id)
  330.     }
  331. }
  332.  
  333. public Show_Menu_Buy_Primary(id)
  334. {
  335.     if(get_user_flags(id) & ADMIN_LEVEL_H)
  336.     {
  337.         new iMenuTime = floatround(g_fBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
  338.        
  339.         if (iMenuTime <= 0)
  340.         {
  341.             ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
  342.             return
  343.         }
  344.        
  345.         static szMenu[300]
  346.         new iLen, iIndex, iMaxLoops = min(WPN_STARTID+7, WPN_MAXIDS[id])
  347.        
  348.         // Title
  349.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L \w[\r%d\w-\r%d\w]^n^n", id, "MENU_PRIMARY_TITLE_VIP", ze_get_user_level(id), WPN_STARTID+1, min(WPN_STARTID+7, WPN_MAXIDS[id]))
  350.        
  351.         // 1-7. Weapon List
  352.         for (iIndex = WPN_STARTID; iIndex < iMaxLoops; iIndex++)
  353.         {
  354.             // if (ze_get_user_level(id) == 0 && iIndex >= 2||
  355.             // ze_get_user_level(id) == 1 && iIndex >= 3 ||
  356.             // ze_get_user_level(id) == 2 && iIndex >= 4 ||
  357.             // ze_get_user_level(id) == 3 && iIndex >= 5 ||
  358.             // ze_get_user_level(id) == 4 && iIndex >= 6 ||
  359.             // ze_get_user_level(id) == 5 && iIndex >= 7 ||
  360.             // ze_get_user_level(id) == 6 && iIndex >= 8 ||
  361.             // ze_get_user_level(id) == 7 && iIndex >= 9 ||
  362.             // ze_get_user_level(id) == 8 && iIndex >= 10 ||
  363.             // ze_get_user_level(id) == 9 && iIndex >= 11 ||
  364.             // ze_get_user_level(id) == 10 && iIndex >= 12 ||
  365.             // ze_get_user_level(id) == 11 && iIndex >= 13 ||
  366.             // ze_get_user_level(id) == 12 && iIndex >= 14)
  367.             // {
  368.             //  break
  369.             // }
  370.            
  371.             /*
  372.             *  Note that WPN_MAXIDS start from 1 but iIndex start from 0.
  373.             */
  374.            
  375.             // M4A1 & AK47
  376.             if (ze_get_user_level(id) == 0 && ze_get_user_level(id) < 5)
  377.             {
  378.                 if (iIndex == 2)
  379.                 {
  380.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "M4A1")
  381.                 }
  382.  
  383.                 if (iIndex == 3)
  384.                 {
  385.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AK47")
  386.                     break;
  387.                 }
  388.             }
  389.            
  390.             // MP5
  391.             if (ze_get_user_level(id) >= 5 && ze_get_user_level(id) < 10)
  392.             {
  393.                 if (iIndex == 2)
  394.                 {
  395.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "M4A1")
  396.                 }
  397.  
  398.                 if (iIndex == 3)
  399.                 {
  400.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AK47")
  401.                 }
  402.                
  403.                 if (iIndex == 4)
  404.                 {
  405.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "MP5")
  406.                     break;
  407.                 }
  408.             }
  409.            
  410.             // M3
  411.             if (ze_get_user_level(id) >= 10 && ze_get_user_level(id) < 15)
  412.             {
  413.                 if (iIndex == 2)
  414.                 {
  415.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "M4A1")
  416.                 }
  417.  
  418.                 if (iIndex == 3)
  419.                 {
  420.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AK47")
  421.                 }
  422.                
  423.                 if (iIndex == 4)
  424.                 {
  425.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "MP5")
  426.                 }
  427.                
  428.                 if (iIndex == 5)
  429.                 {
  430.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "M3")
  431.                     break;
  432.                 }
  433.             }
  434.            
  435.             // WEAPON 1
  436.             if (ze_get_user_level(id) >= 15)
  437.             {
  438.                 if (iIndex == 2)
  439.                 {
  440.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "M4A1")
  441.                 }
  442.  
  443.                 if (iIndex == 3)
  444.                 {
  445.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AK47")
  446.                 }
  447.                
  448.                 if (iIndex == 4)
  449.                 {
  450.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "MP5")
  451.                 }
  452.                
  453.                 if (iIndex == 5)
  454.                 {
  455.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "M3")
  456.                 }
  457.                
  458.                 if (iIndex == 6)
  459.                 {
  460.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "WEAPON #1")
  461.                     break;
  462.                 }
  463.             }
  464.  
  465.         }
  466.        
  467.         if (ze_get_user_level(id) == 0 && ze_get_user_level(id) < 5)
  468.         {
  469.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 5 Unlock\w: \yMP5 \rWEAPON^n")
  470.         }
  471.         else if (ze_get_user_level(id) >= 5 && ze_get_user_level(id) < 10)
  472.         {
  473.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 10 Unlock\w: \yM3 \rWEAPON^n")
  474.         }
  475.         else if (ze_get_user_level(id) >= 10 && ze_get_user_level(id) < 15)
  476.         {
  477.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 15 Unlock\w: \yWEAPON #1^n")
  478.         }
  479.  
  480.         // 8. Auto Select
  481.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\w8.\y %L \w[\r%L\w]", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "SAVE_YES" : "SAVE_NO")
  482.        
  483.         // 9. Next/Back - 0. Exit
  484.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\y9.\r %L \w/ \r%L^n^n\w0.\y %L", id, "NEXT", id, "BACK", id, "EXIT")
  485.        
  486.         // Fix for AMXX custom menus
  487.         set_pdata_int(id, OFFSET_CSMENUCODE, 0)
  488.         show_menu(id, KEYSMENU, szMenu, iMenuTime, "Primary Weapons")
  489.         }
  490.  
  491.  
  492.  
  493.     else /*********************** ОБЫЧНЫЙ ПОЛЬЗОВАТЕЛЬ ************************/
  494.  
  495.  
  496.  
  497.  
  498.     {
  499.         new iMenuTime = floatround(g_fBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
  500.        
  501.         if (iMenuTime <= 0)
  502.         {
  503.             ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
  504.             return
  505.         }
  506.        
  507.         static szMenu[300], szWeaponName[32]
  508.         new iLen, iIndex, iMaxLoops = min(WPN_STARTID+7, WPN_MAXIDS[id])
  509.        
  510.         // Title
  511.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L \w[\r%d\w-\r%d\w]^n^n", id, "MENU_PRIMARY_TITLE", WPN_STARTID+1, min(WPN_STARTID+7, WPN_MAXIDS[id]))
  512.        
  513.         // 1-7. Weapon List
  514.         for (iIndex = WPN_STARTID; iIndex < iMaxLoops; iIndex++)
  515.         {
  516.             if (ze_get_user_level(id) == 0 && iIndex >= 2||
  517.             ze_get_user_level(id) == 1 && iIndex >= 3 ||
  518.             ze_get_user_level(id) == 2 && iIndex >= 4 ||
  519.             ze_get_user_level(id) == 3 && iIndex >= 5 ||
  520.             ze_get_user_level(id) == 4 && iIndex >= 6 ||
  521.             ze_get_user_level(id) == 5 && iIndex >= 7 ||
  522.             ze_get_user_level(id) == 6 && iIndex >= 8 ||
  523.             ze_get_user_level(id) == 7 && iIndex >= 9 ||
  524.             ze_get_user_level(id) == 8 && iIndex >= 10 ||
  525.             ze_get_user_level(id) == 9 && iIndex >= 11 ||
  526.             ze_get_user_level(id) == 10 && iIndex >= 12 ||
  527.             ze_get_user_level(id) == 11 && iIndex >= 13 ||
  528.             ze_get_user_level(id) == 12 && iIndex >= 14)
  529.             {
  530.                 break
  531.             }
  532.            
  533.             /*
  534.             *  Note that WPN_MAXIDS start from 1 but iIndex start from 0.
  535.             */
  536.            
  537.             // Golden M3
  538.             if (ze_get_user_level(id) >= 15 && ze_get_user_level(id) < 20)
  539.             {
  540.                 if (iIndex == 14)
  541.                 {
  542.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M3")
  543.                     break;
  544.                 }
  545.             }
  546.            
  547.             // Golden MP5
  548.             if (ze_get_user_level(id) >= 20 && ze_get_user_level(id) < 25)
  549.             {
  550.                 if (iIndex == 14)
  551.                 {
  552.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M3")
  553.                 }
  554.                
  555.                 if (iIndex == 15)
  556.                 {
  557.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
  558.                     break;
  559.                 }
  560.             }
  561.            
  562.             // Golden M4A1
  563.             if (ze_get_user_level(id) >= 25 && ze_get_user_level(id) < 30)
  564.             {
  565.                 if (iIndex == 14)
  566.                 {
  567.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M3")
  568.                 }
  569.                
  570.                 if (iIndex == 15)
  571.                 {
  572.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
  573.                 }
  574.                
  575.                 if (iIndex == 16)
  576.                 {
  577.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
  578.                     break;
  579.                 }
  580.             }
  581.            
  582.             // Golden AK47
  583.             if (ze_get_user_level(id) >= 30)
  584.             {
  585.                 if (iIndex == 14)
  586.                 {
  587.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M3")
  588.                 }
  589.                
  590.                 if (iIndex == 15)
  591.                 {
  592.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
  593.                 }
  594.                
  595.                 if (iIndex == 16)
  596.                 {
  597.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
  598.                 }
  599.                
  600.                 if (iIndex == 17)
  601.                 {
  602.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK-47")
  603.                     break;
  604.                 }
  605.             }
  606.            
  607.             // Must check if iIndex < 14 means max is AK47
  608.             if (iIndex < 14)
  609.             {
  610.                 ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
  611.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, szWeaponNames[get_weaponid(szWeaponName)])
  612.             }
  613.         }
  614.        
  615.         if (iIndex < 7)
  616.         {
  617.             ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
  618.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
  619.         }
  620.        
  621.         if (ze_get_user_level(id) == 5)
  622.         {
  623.             ArrayGetString(g_szPrimaryWeapons, 7, szWeaponName, charsmax(szWeaponName))
  624.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
  625.         }
  626.         else if (ze_get_user_level(id) == 6)
  627.         {
  628.             ArrayGetString(g_szPrimaryWeapons, 8, szWeaponName, charsmax(szWeaponName))
  629.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
  630.         }
  631.         else if (ze_get_user_level(id) == 7)
  632.         {
  633.             ArrayGetString(g_szPrimaryWeapons, 9, szWeaponName, charsmax(szWeaponName))
  634.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
  635.         }
  636.         else if (ze_get_user_level(id) == 8)
  637.         {
  638.             ArrayGetString(g_szPrimaryWeapons, 10, szWeaponName, charsmax(szWeaponName))
  639.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
  640.         }
  641.         else if (ze_get_user_level(id) == 9)
  642.         {
  643.             ArrayGetString(g_szPrimaryWeapons, 11, szWeaponName, charsmax(szWeaponName))
  644.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
  645.         }
  646.         else if (ze_get_user_level(id) == 10)
  647.         {
  648.             ArrayGetString(g_szPrimaryWeapons, 12, szWeaponName, charsmax(szWeaponName))
  649.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
  650.         }
  651.         else if (ze_get_user_level(id) == 11)
  652.         {
  653.             ArrayGetString(g_szPrimaryWeapons, 13, szWeaponName, charsmax(szWeaponName))
  654.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
  655.         }
  656.         else if (ze_get_user_level(id) >= 12 && ze_get_user_level(id) < 15) // Golden M3
  657.         {
  658.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 15 Unlock\w: \yGolden M3^n")
  659.         }
  660.         else if (ze_get_user_level(id) >= 15 && ze_get_user_level(id) < 20) // Golden MP5
  661.         {
  662.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 20 Unlock\w: \yGolden MP5^n")
  663.         }
  664.         else if (ze_get_user_level(id) >= 20 && ze_get_user_level(id) < 25) // Golden M4A1
  665.         {
  666.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 25 Unlock\w: \yGolden M4A1^n")
  667.         }
  668.         else if (ze_get_user_level(id) >= 25 && ze_get_user_level(id) < 30) // Golden Ak-47
  669.         {
  670.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 30 Unlock\w: \yGolden AK-47^n")
  671.         }
  672.  
  673.         // 8. Auto Select
  674.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\w8.\y %L \w[\r%L\w]", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "SAVE_YES" : "SAVE_NO")
  675.        
  676.         // 9. Next/Back - 0. Exit
  677.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\y9.\r %L \w/ \r%L^n^n\w0.\y %L", id, "NEXT", id, "BACK", id, "EXIT")
  678.        
  679.         // Fix for AMXX custom menus
  680.         set_pdata_int(id, OFFSET_CSMENUCODE, 0)
  681.         show_menu(id, KEYSMENU, szMenu, iMenuTime, "Primary Weapons")
  682.         }
  683. }
  684.  
  685. public Show_Menu_Buy_Secondary(id)
  686. {
  687.     new iMenuTime = floatround(g_fBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
  688.    
  689.     if (iMenuTime <= 0)
  690.     {
  691.         ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
  692.         return
  693.     }
  694.    
  695.     static szMenu[250], szWeaponName[32]
  696.     new iLen, iIndex, iMaxLoops = ArraySize(g_szSecondaryWeapons)
  697.    
  698.     // Title
  699.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L^n", id, "MENU_SECONDARY_TITLE")
  700.    
  701.     // 1-6. Weapon List
  702.     for (iIndex = 0; iIndex < iMaxLoops; iIndex++)
  703.     {
  704.         if (ze_get_user_level(id) == 0 && iIndex >= 2 ||
  705.         ze_get_user_level(id) == 1 && iIndex >= 3 ||
  706.         ze_get_user_level(id) == 2 && iIndex >= 4 ||
  707.         ze_get_user_level(id) == 3 && iIndex >= 5 ||
  708.         ze_get_user_level(id) == 4 && iIndex >= 6)
  709.         {
  710.             break
  711.         }
  712.        
  713.         ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
  714.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\w%d.\y %s", iIndex+1, szWeaponNames[get_weaponid(szWeaponName)])
  715.     }
  716.    
  717.     if (iIndex < ArraySize(g_szSecondaryWeapons))
  718.     {
  719.         ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
  720.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r Next Level Unlock\w: \y%s", szWeaponNames[get_weaponid(szWeaponName)])
  721.     }
  722.    
  723.     // 8. Auto Select
  724.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w8.\y %L \w[\r%L\w]", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "SAVE_YES" : "SAVE_NO")
  725.    
  726.     // 0. Exit
  727.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\y %L", id, "EXIT")
  728.    
  729.     // Fix for AMXX custom menus
  730.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
  731.     show_menu(id, KEYSMENU, szMenu, iMenuTime, "Secondary Weapons")
  732. }
  733.  
  734. public Menu_Buy_Primary(id, key)
  735. {
  736.     // Player dead or zombie or already bought primary
  737.     if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtPrimary[id])
  738.         return PLUGIN_HANDLED
  739.    
  740.     // Special keys / weapon list exceeded
  741.     if (key >= MENU_KEY_AUTOSELECT || WPN_SELECTION >= WPN_MAXIDS[id])
  742.     {
  743.         switch (key)
  744.         {
  745.             case MENU_KEY_AUTOSELECT: // toggle auto select
  746.             {
  747.                 WPN_AUTO_ON = 1 - WPN_AUTO_ON
  748.             }
  749.             case MENU_KEY_NEXT: // next/back
  750.             {
  751.                 if (WPN_STARTID+7 < WPN_MAXIDS[id])
  752.                     WPN_STARTID += 7
  753.                 else
  754.                     WPN_STARTID = 0
  755.             }
  756.             case MENU_KEY_EXIT: // exit
  757.             {
  758.                 return PLUGIN_HANDLED
  759.             }
  760.         }
  761.        
  762.         // Show buy menu again
  763.         Show_Menu_Buy_Primary(id)
  764.         return PLUGIN_HANDLED
  765.     }
  766.    
  767.     // Store selected weapon id
  768.     WPN_AUTO_PRI = WPN_SELECTION
  769.    
  770.     // Buy primary weapon
  771.     Buy_Primary_Weapon(id, WPN_AUTO_PRI)
  772.    
  773.     // Show Secondary Weapons
  774.     Show_Available_Buy_Menus(id)
  775.    
  776.     return PLUGIN_HANDLED
  777. }
  778.  
  779. public Buy_Primary_Weapon(id, selection)
  780. {
  781.     if(get_user_flags(id) & ADMIN_LEVEL_H)
  782.     {
  783.         if (selection == 2)
  784.         {
  785.             ze_weapon_m4a1(id)
  786.             g_bBoughtPrimary[id] = true
  787.             return true;
  788.         }
  789.         else if (selection == 3) // Golden MP5
  790.         {
  791.             ze_colored_print(id, "!tAK недоступен")
  792.             g_bBoughtPrimary[id] = true
  793.             return true;
  794.         }
  795.         else if (selection == 4) // Golden M4A1
  796.         {
  797.             ze_colored_print(id, "!tMP5 недоступен")
  798.             g_bBoughtPrimary[id] = true
  799.             return true;
  800.         }
  801.         else if (selection == 5) // Golden AK47
  802.         {
  803.             ze_weapon_m3(id)
  804.             g_bBoughtPrimary[id] = true
  805.             return true;
  806.         }
  807.         else if (selection == 6) // Golden AK47
  808.         {
  809.             ze_colored_print(id, "!tWEAPON 1 недоступен")
  810.             g_bBoughtPrimary[id] = true
  811.             return true;
  812.         }
  813.        
  814.         // Primary bought
  815.         g_bBoughtPrimary[id] = true
  816.         return true;
  817.     }
  818.     else
  819.     {
  820.         if (selection == 14) // Golden M3
  821.         {
  822.             ze_weapon_m3(id)
  823.             g_bBoughtPrimary[id] = true
  824.             return true;
  825.         }
  826.         else if (selection == 15) // Golden MP5
  827.         {
  828.             give_golden_mp5(id)
  829.             g_bBoughtPrimary[id] = true
  830.             return true;
  831.         }
  832.         else if (selection == 16) // Golden M4A1
  833.         {
  834.             ze_weapon_m4a1(id)
  835.             g_bBoughtPrimary[id] = true
  836.             return true;
  837.         }
  838.         else if (selection == 17) // Golden AK47
  839.         {
  840.             give_golden_ak47(id)
  841.             g_bBoughtPrimary[id] = true
  842.             return true;
  843.         }
  844.        
  845.         static szWeaponName[32]
  846.         ArrayGetString(g_szPrimaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
  847.         new iWeaponId = get_weaponid(szWeaponName)
  848.        
  849.         // Strip and Give Full Weapon
  850.         rg_give_item(id, szWeaponName, GT_REPLACE)
  851.         rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
  852.        
  853.         // Primary bought
  854.         g_bBoughtPrimary[id] = true
  855.         return true;
  856.     }  
  857. }
  858.  
  859. public Menu_Buy_Secondary(id, key)
  860. {
  861.     // Player dead or zombie or already bought secondary
  862.     if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtSecondary[id])
  863.         return PLUGIN_HANDLED
  864.    
  865.     // Special keys / weapon list exceeded
  866.     if (key >= ArraySize(g_szSecondaryWeapons))
  867.     {
  868.         // Toggle autoselect
  869.         if (key == MENU_KEY_AUTOSELECT)
  870.             WPN_AUTO_ON = 1 - WPN_AUTO_ON
  871.        
  872.         // Reshow menu unless user exited
  873.         if (key != MENU_KEY_EXIT)
  874.             Show_Menu_Buy_Secondary(id)
  875.        
  876.         return PLUGIN_HANDLED
  877.     }
  878.    
  879.     // Store selected weapon id
  880.     WPN_AUTO_SEC = key
  881.    
  882.     // Buy secondary weapon
  883.     Buy_Secondary_Weapon(id, key)
  884.    
  885.     return PLUGIN_HANDLED
  886. }
  887.  
  888. public Buy_Secondary_Weapon(id, selection)
  889. {
  890.     if ( ((selection == 2) && (ze_get_user_level(id) < 1)) ||
  891.     ((selection == 3) && (ze_get_user_level(id) < 2)) ||
  892.     ((selection == 4) && (ze_get_user_level(id) < 3)) ||
  893.     ((selection == 5) && (ze_get_user_level(id) < 4)) )
  894.     {
  895.         Show_Menu_Buy_Secondary(id)
  896.         return;
  897.     }
  898.  
  899.     static szWeaponName[32]
  900.     ArrayGetString(g_szSecondaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
  901.     new iWeaponId = get_weaponid(szWeaponName)
  902.    
  903.     // Strip and Give Full Weapon
  904.     rg_give_item(id, szWeaponName, GT_REPLACE)
  905.     rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
  906.    
  907.     // Secondary bought
  908.     g_bBoughtSecondary[id] = true
  909. }
  910.  
  911. public Fw_TouchWeapon_Pre(iEnt, id)
  912. {
  913.     if (get_pcvar_num(g_pCvarBlockWeapLowLevel) == 0)
  914.         return HAM_IGNORED;
  915.    
  916.     // Not alive or Not Valid Weapon?
  917.     if(!is_user_alive(id) || !pev_valid(iEnt))
  918.         return HAM_IGNORED;
  919.    
  920.     // Get Weapon Model
  921.     new szWeapModel[32]
  922.     pev(iEnt, pev_model, szWeapModel, charsmax(szWeapModel))
  923.    
  924.     // Remove "models/w_" and ".mdl"
  925.     copyc(szWeapModel, charsmax(szWeapModel), szWeapModel[contain(szWeapModel, "_" ) + 1], '.')
  926.    
  927.     // Set for mp5 to be same as "weapon_mp5navy"
  928.     if(szWeapModel[1] == 'p' && szWeapModel[2] == '5')
  929.         szWeapModel = "mp5navy"
  930.    
  931.     // Add "weapon_" to all model names
  932.     static szWeaponEnt[32]
  933.     formatex(szWeaponEnt, charsmax(szWeaponEnt), "weapon_%s", szWeapModel)
  934.  
  935.     // Get it's index in Weapon Array
  936.     new iIndex, i
  937.    
  938.     // I won't explain the blew code if you need to understand ask me in Escapers-Zone.XYZ
  939.     for (i = 0; i < ArraySize(g_szPrimaryWeapons); i++)
  940.     {
  941.         new szPrimaryWeapon[32]
  942.         ArrayGetString(g_szPrimaryWeapons, i, szPrimaryWeapon, charsmax(szPrimaryWeapon))
  943.        
  944.         if (equali(szWeaponEnt, szPrimaryWeapon))
  945.             iIndex = i
  946.     }
  947.    
  948.     if (ze_get_user_level(id) == 0 && iIndex > 1)
  949.     {
  950.         return HAM_SUPERCEDE;
  951.     }
  952.    
  953.     for (i = 1; i <= 11; i++)
  954.     {
  955.         if ((ze_get_user_level(id) == i) && iIndex > i+1)
  956.         {
  957.             return HAM_SUPERCEDE;
  958.         }
  959.     }
  960.    
  961.     return HAM_IGNORED;
  962. }
  963.  
  964. // Natives
  965. public native_ze_show_weapon_menu(id)
  966. {
  967.     if (!is_user_connected(id))
  968.     {
  969.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
  970.         return false
  971.     }
  972.    
  973.     Cmd_Buy(id)
  974.     return true
  975. }
  976.  
  977. public native_ze_is_auto_buy_enabled(id)
  978. {
  979.     if (!is_user_connected(id))
  980.     {
  981.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
  982.         return -1;
  983.     }
  984.    
  985.     return WPN_AUTO_ON;
  986. }
  987.  
  988. public native_ze_disable_auto_buy(id)
  989. {
  990.     if (!is_user_connected(id))
  991.     {
  992.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
  993.         return false
  994.     }
  995.    
  996.     WPN_AUTO_ON = 0;
  997.     return true
  998. }

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#2

Post by Raheem » 3 years ago

Welcome and hello :sweat_smile:,

Please explain what is the problem you ran into, also provide the main code before editing.
He who fails to plan is planning to fail

User avatar
Urban
Member
Member
Ukraine
Posts: 12
Joined: 3 years ago
Contact:

#3

Post by Urban » 3 years ago

All is decided. indexes were incorrectly spelled out))

didn't work because I wrote an index with 2
  1. if (iIndex == 2)
  2.                 {
  3.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "M4A1")
  4.                 }
  5.  
  6.                 if (iIndex == 3)
  7.                 {
  8.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AK47")
  9.                     break;
  10.                 }
this is how it works
  1. if (iIndex == 0)
  2.                 {
  3.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "M4A1")
  4.                 }
  5.  
  6.                 if (iIndex == 1)
  7.                 {
  8.                     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AK47")
  9.                     break;
  10.                 }
must also match "selection"

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#4

Post by Raheem » 3 years ago

So your issue resolved, right?
He who fails to plan is planning to fail

User avatar
Urban
Member
Member
Ukraine
Posts: 12
Joined: 3 years ago
Contact:

#5

Post by Urban » 3 years ago

Yes. thanks Raheem. great mod))
-
we can assume that the topic is closed..

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 6 guests