Approved Levels Weapons Menu

Gameplay Addons
User avatar
Jack GamePlay
Mod Developer
Mod Developer
Egypt
Posts: 501
Joined: 1 Year Ago
Location: Egypt
Has thanked: 31 times
Been thanked: 39 times
Age: 18
Contact:

Re: Levels Weapons Menu

#11

Post by Jack GamePlay » 3 Months Ago

Rain1153 wrote:
3 Months Ago
raheeeem when are u gonna level extra items menu :P

Code: Select all

/*
* Description:		Set this item for specific level.
*
* @param iItemid	Item id.
* @param iLevel		Level must player have to buy this item.
*
* @return			true 		  | If level set successfully.
*					false 		  | If level < 0 (Failed).
*					ZE_WRONG_ITEM | If this itemid is invalid.
*
* @note				Use this under ze_register_item() native in plugin_init() forward.
* 					To use this native level plugin must be installed.
*
*/
native ze_set_item_level(iItemid, iLevel);
Source: ze_set_item_level
Image

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1703
Joined: 1 Year Ago
Location: Egypt
Has thanked: 28 times
Been thanked: 75 times
Age: 20
Contact:

#12

Post by Raheem » 3 Months Ago

You don't know? Learn and you will know.

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 257
Joined: 2 Months Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 19 times
Age: 33
Contact:

#13

Post by Mark » 2 Months Ago

Raheem wrote:
3 Months Ago
Here it's: viewtopic.php?p=7113#p7113
If i wanted to set the next weapons to open on lvl 5 how can i?

Right now they open on every new level earned.
  1. #include <zombie_escape>
  2. #include <ze_levels>
  3.  
  4. // Setting File
  5. new const ZE_SETTING_RESOURCES[] = "zombie_escape.ini"
  6.  
  7. // Keys
  8. 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
  9. const OFFSET_CSMENUCODE = 205
  10.  
  11. // Primary Weapons Entities [Default Values]
  12. new const szPrimaryWeaponEnt[][] =
  13. {
  14.     "weapon_xm1014",  // Level 0
  15.     "weapon_ump45",   // Level 0
  16.     "weapon_m3",      // Level 1
  17.     "weapon_mp5navy", // Level 2
  18.     "weapon_p90",     // Level 3
  19.     "weapon_galil",   // Level 4
  20.     "weapon_famas",   // Level 5
  21.     "weapon_sg550",   // Level 6
  22.     "weapon_g3sg1",   // Level 7
  23.     "weapon_m249",    // Level 8
  24.     "weapon_sg552",   // Level 9
  25.     "weapon_aug",     // Level 10
  26.     "weapon_m4a1",    // Level 11
  27.     "weapon_ak47"     // Level 12
  28. }
  29.  
  30. // Secondary Weapons Entities [Default Values]
  31. new const szSecondaryWeaponEnt[][]=
  32. {
  33.     "weapon_usp",         // Level 0
  34.     "weapon_p228",        // Level 0
  35.     "weapon_glock18",     // Level 1
  36.     "weapon_fiveseven",   // Level 2
  37.     "weapon_deagle",      // Level 3
  38.     "weapon_elite"        // Level 4
  39. }
  40.  
  41. // Primary and Secondary Weapons Names [Default Values]
  42. new const szWeaponNames[][] =
  43. {
  44.     "",
  45.     "P228",
  46.     "",
  47.     "Scout",
  48.     "HE Grenade",
  49.     "XM1014",
  50.     "",
  51.     "MAC-10",
  52.     "AUG",
  53.     "Smoke Grenade",
  54.     "Dual Elite",
  55.     "Five Seven",
  56.     "UMP 45",
  57.     "SG-550",
  58.     "Galil",
  59.     "Famas",
  60.     "USP",
  61.     "Glock",
  62.     "AWP",
  63.     "MP5",
  64.     "M249",
  65.     "M3",
  66.     "M4A1",
  67.     "TMP",
  68.     "G3SG1",
  69.     "Flashbang",
  70.     "Desert Eagle",
  71.     "SG-552",
  72.     "AK-47",
  73.     "",
  74.     "P90"
  75. }
  76.  
  77. // Max Back Clip Ammo (Change it From here if you need)
  78. new const szMaxBPAmmo[] =
  79. {
  80.     -1,
  81.     52,
  82.     -1,
  83.     90,
  84.     1,
  85.     32,
  86.     1,
  87.     100,
  88.     90,
  89.     1,
  90.     120,
  91.     100,
  92.     100,
  93.     90,
  94.     90,
  95.     90,
  96.     100,
  97.     120,
  98.     30,
  99.     120,
  100.     200,
  101.     32,
  102.     90,
  103.     120,
  104.     90,
  105.     2,
  106.     35,
  107.     90,
  108.     90,
  109.     -1,
  110.     100
  111. }
  112.  
  113. // Menu selections
  114. const MENU_KEY_AUTOSELECT = 7
  115. const MENU_KEY_BACK = 7
  116. const MENU_KEY_NEXT = 8
  117. const MENU_KEY_EXIT = 9
  118.  
  119. // Variables
  120. new Array:g_szPrimaryWeapons,
  121.     Array:g_szSecondaryWeapons
  122.  
  123. new g_iMenuData[33][4],
  124.     Float:g_flBuyTimeStart[33],
  125.     bool:g_bBoughtPrimary[33],
  126.     bool:g_bBoughtSecondary[33]
  127.     new WPN_MAXIDS[33]
  128.  
  129. // Define
  130. #define WPN_STARTID g_iMenuData[id][0]
  131. #define WPN_SELECTION (g_iMenuData[id][0]+key)
  132. #define WPN_AUTO_ON g_iMenuData[id][1]
  133. #define WPN_AUTO_PRI g_iMenuData[id][2]
  134. #define WPN_AUTO_SEC g_iMenuData[id][3]
  135.  
  136. // Cvars
  137. new g_pCvarBuyTime,
  138.     g_pCvarHEGrenade,
  139.     g_pCvarSmokeGrenade,
  140.     g_pCvarFlashGrenade,
  141.     g_pCvarBlockWeapLowLvl
  142.  
  143. public plugin_natives()
  144. {
  145.     register_native("ze_show_weapon_menu", "native_ze_show_weapon_menu", 1)
  146.     register_native("ze_is_auto_buy_enabled", "native_ze_is_auto_buy_enabled", 1)
  147.     register_native("ze_disable_auto_buy", "native_ze_disable_auto_buy", 1)
  148. }
  149.  
  150. public plugin_precache()
  151. {
  152.     // Initialize arrays (32 is the max length of Weapon Entity like: weapon_ak47)
  153.     g_szPrimaryWeapons = ArrayCreate(32, 1)
  154.     g_szSecondaryWeapons = ArrayCreate(32, 1)
  155.    
  156.     // Load from external file
  157.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
  158.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
  159.    
  160.     // If we couldn't load from file, use and save default ones
  161.    
  162.     new iIndex
  163.    
  164.     if (ArraySize(g_szPrimaryWeapons) == 0)
  165.     {
  166.         for (iIndex = 0; iIndex < sizeof szPrimaryWeaponEnt; iIndex++)
  167.             ArrayPushString(g_szPrimaryWeapons, szPrimaryWeaponEnt[iIndex])
  168.        
  169.         // If not found .ini File Create it and save default values in it
  170.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
  171.     }
  172.    
  173.     if (ArraySize(g_szSecondaryWeapons) == 0)
  174.     {
  175.         for (iIndex = 0; iIndex < sizeof szSecondaryWeaponEnt; iIndex++)
  176.             ArrayPushString(g_szSecondaryWeapons, szSecondaryWeaponEnt[iIndex])
  177.        
  178.         // If not found .ini File Create it and save default values in it
  179.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
  180.     }
  181. }
  182.  
  183. public plugin_init()
  184. {
  185.     register_plugin("[ZE] Levels Weapons Menu", "1.1", "Raheem")
  186.    
  187.     // Commands
  188.     register_clcmd("guns", "Cmd_Buy")
  189.     register_clcmd("say /enable", "Cmd_Enable")
  190.     register_clcmd("say_team /enable", "Cmd_Enable")
  191.    
  192.     // Cvars
  193.     g_pCvarBuyTime = register_cvar("ze_buy_time", "60")
  194.     g_pCvarHEGrenade = register_cvar("ze_give_HE_nade", "1") // 0 Nothing || 1 Give HE
  195.     g_pCvarSmokeGrenade = register_cvar("ze_give_SM_nade", "1")
  196.     g_pCvarFlashGrenade = register_cvar("ze_give_FB_nade", "1")
  197.     g_pCvarBlockWeapLowLvl = register_cvar("ze_block_weapons_lowlvl", "1")
  198.    
  199.     // Menus
  200.     register_menu("Primary Weapons", KEYSMENU, "Menu_Buy_Primary")
  201.     register_menu("Secondary Weapons", KEYSMENU, "Menu_Buy_Secondary")
  202.    
  203.     // Hams
  204.     RegisterHam(Ham_Touch, "weaponbox", "Fw_TouchWeapon_Pre", 0)
  205.     RegisterHam(Ham_Touch, "armoury_entity", "Fw_TouchWeapon_Pre", 0)
  206. }
  207.  
  208. public client_disconnected(id)
  209. {
  210.     WPN_AUTO_ON = 0
  211.     WPN_STARTID = 0
  212. }
  213.  
  214. public Cmd_Enable(id)
  215. {
  216.     if (WPN_AUTO_ON)
  217.     {
  218.         ze_colored_print(id, "%L", LANG_PLAYER, "BUY_ENABLED")
  219.         WPN_AUTO_ON = 0
  220.     }
  221. }
  222.  
  223. public Cmd_Buy(id)
  224. {
  225.     // Player Zombie
  226.     if (ze_is_user_zombie(id))
  227.     {
  228.         ze_colored_print(id, "%L", LANG_PLAYER, "NO_BUY_ZOMBIE")
  229.         return
  230.     }
  231.    
  232.     // Player Dead
  233.     if (!is_user_alive(id))
  234.     {
  235.         ze_colored_print(id, "%L", LANG_PLAYER, "DEAD_CANT_BUY_WEAPON")
  236.         return
  237.     }
  238.    
  239.     // Already bought
  240.     if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
  241.     {
  242.         ze_colored_print(id, "%L", LANG_PLAYER, "ALREADY_BOUGHT")
  243.     }
  244.    
  245.     Show_Available_Buy_Menus(id)
  246. }
  247.  
  248. public ze_user_humanized(id)
  249. {
  250.     // Static Values
  251.     switch (ze_get_user_level(id))
  252.     {
  253.         case 0: WPN_MAXIDS[id] = 2
  254.         case 1: WPN_MAXIDS[id] = 3
  255.         case 2: WPN_MAXIDS[id] = 4
  256.         case 3: WPN_MAXIDS[id] = 5
  257.         case 4: WPN_MAXIDS[id] = 6
  258.         case 5: WPN_MAXIDS[id] = 7
  259.         case 6: WPN_MAXIDS[id] = 8
  260.         case 7: WPN_MAXIDS[id] = 9
  261.         case 8: WPN_MAXIDS[id] = 10
  262.         case 9: WPN_MAXIDS[id] = 11
  263.         case 10: WPN_MAXIDS[id] = 12
  264.         case 11: WPN_MAXIDS[id] = 13
  265.         case 12: WPN_MAXIDS[id] = 14
  266.     }
  267.    
  268.     if (ze_get_user_level(id) > 12)
  269.     {
  270.         WPN_MAXIDS[id] = 14
  271.     }
  272.  
  273.     // Buyzone time starts when player is set to human
  274.     g_flBuyTimeStart[id] = get_gametime()
  275.    
  276.     g_bBoughtPrimary[id] = false
  277.     g_bBoughtSecondary[id] = false
  278.    
  279.     // Player dead or zombie
  280.     if (!is_user_alive(id) || ze_is_user_zombie(id))
  281.         return
  282.    
  283.     if (WPN_AUTO_ON)
  284.     {
  285.         ze_colored_print(id, "%L", LANG_PLAYER, "RE_ENABLE_MENU")
  286.         Buy_Primary_Weapon(id, WPN_AUTO_PRI)
  287.         Buy_Secondary_Weapon(id, WPN_AUTO_SEC)
  288.     }
  289.    
  290.     // Open available buy menus
  291.     Show_Available_Buy_Menus(id)
  292.    
  293.     // Give HE Grenade
  294.     if (get_pcvar_num(g_pCvarHEGrenade) != 0)
  295.         rg_give_item(id, "weapon_hegrenade")
  296.    
  297.     // Give Smoke Grenade
  298.     if (get_pcvar_num(g_pCvarSmokeGrenade) != 0)
  299.         rg_give_item(id, "weapon_smokegrenade")
  300.    
  301.     // Give Flashbang Grenade
  302.     if (get_pcvar_num(g_pCvarFlashGrenade) != 0)
  303.         rg_give_item(id, "weapon_flashbang")
  304. }
  305.  
  306. public Show_Available_Buy_Menus(id)
  307. {
  308.     // Already Bought
  309.     if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
  310.         return
  311.    
  312.     // Here we use if and else if so we make sure that Primary weapon come first then secondary
  313.     if (!g_bBoughtPrimary[id])
  314.     {
  315.         // Primary     
  316.         Show_Menu_Buy_Primary(id)
  317.     }
  318.     else if (!g_bBoughtSecondary[id])
  319.     {
  320.         // Secondary
  321.         Show_Menu_Buy_Secondary(id)
  322.     }
  323. }
  324.  
  325. public Show_Menu_Buy_Primary(id)
  326. {
  327.     new iMenuTime = floatround(g_flBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
  328.    
  329.     if (iMenuTime <= 0)
  330.     {
  331.         ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
  332.         return
  333.     }
  334.    
  335.     static szMenu[300], szWeaponName[32]
  336.     new iLen, iIndex, iMaxLoops = min(WPN_STARTID+7, WPN_MAXIDS[id])
  337.    
  338.     // Title
  339.     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]))
  340.    
  341.     // 1-7. Weapon List
  342.     for (iIndex = WPN_STARTID; iIndex < iMaxLoops; iIndex++)
  343.     {
  344.         if (ze_get_user_level(id) == 0 && iIndex >= 2||
  345.         ze_get_user_level(id) == 1 && iIndex >= 3 ||
  346.         ze_get_user_level(id) == 2 && iIndex >= 4 ||
  347.         ze_get_user_level(id) == 3 && iIndex >= 5 ||
  348.         ze_get_user_level(id) == 4 && iIndex >= 6 ||
  349.         ze_get_user_level(id) == 5 && iIndex >= 7 ||
  350.         ze_get_user_level(id) == 6 && iIndex >= 8 ||
  351.         ze_get_user_level(id) == 7 && iIndex >= 9 ||
  352.         ze_get_user_level(id) == 8 && iIndex >= 10 ||
  353.         ze_get_user_level(id) == 9 && iIndex >= 11 ||
  354.         ze_get_user_level(id) == 10 && iIndex >= 12 ||
  355.         ze_get_user_level(id) == 11 && iIndex >= 13 ||
  356.         ze_get_user_level(id) == 12 && iIndex >= 14)
  357.         {
  358.             break
  359.         }
  360.  
  361.         ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
  362.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, szWeaponNames[get_weaponid(szWeaponName)])
  363.     }
  364.    
  365.     if (iIndex < 7)
  366.     {
  367.         ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
  368.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
  369.     }
  370.    
  371.     if (ze_get_user_level(id) == 5)
  372.     {
  373.         ArrayGetString(g_szPrimaryWeapons, 7, szWeaponName, charsmax(szWeaponName))
  374.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
  375.     }
  376.     else if (ze_get_user_level(id) == 6)
  377.     {
  378.         ArrayGetString(g_szPrimaryWeapons, 8, szWeaponName, charsmax(szWeaponName))
  379.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
  380.     }
  381.     else if (ze_get_user_level(id) == 7)
  382.     {
  383.         ArrayGetString(g_szPrimaryWeapons, 9, szWeaponName, charsmax(szWeaponName))
  384.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
  385.     }
  386.     else if (ze_get_user_level(id) == 8)
  387.     {
  388.         ArrayGetString(g_szPrimaryWeapons, 10, szWeaponName, charsmax(szWeaponName))
  389.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
  390.     }
  391.     else if (ze_get_user_level(id) == 9)
  392.     {
  393.         ArrayGetString(g_szPrimaryWeapons, 11, szWeaponName, charsmax(szWeaponName))
  394.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
  395.     }
  396.     else if (ze_get_user_level(id) == 10)
  397.     {
  398.         ArrayGetString(g_szPrimaryWeapons, 12, szWeaponName, charsmax(szWeaponName))
  399.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
  400.     }
  401.     else if (ze_get_user_level(id) == 11)
  402.     {
  403.         ArrayGetString(g_szPrimaryWeapons, 13, szWeaponName, charsmax(szWeaponName))
  404.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
  405.     }
  406.  
  407.     // 8. Auto Select
  408.     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")
  409.    
  410.     // 9. Next/Back - 0. Exit
  411.     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")
  412.    
  413.     // Fix for AMXX custom menus
  414.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
  415.     show_menu(id, KEYSMENU, szMenu, iMenuTime, "Primary Weapons")
  416. }
  417.  
  418. public Show_Menu_Buy_Secondary(id)
  419. {
  420.     new iMenuTime = floatround(g_flBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
  421.    
  422.     if (iMenuTime <= 0)
  423.     {
  424.         ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
  425.         return
  426.     }
  427.    
  428.     static szMenu[250], szWeaponName[32]
  429.     new iLen, iIndex, iMaxLoops = ArraySize(g_szSecondaryWeapons)
  430.    
  431.     // Title
  432.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L^n", id, "MENU_SECONDARY_TITLE")
  433.    
  434.     // 1-6. Weapon List
  435.     for (iIndex = 0; iIndex < iMaxLoops; iIndex++)
  436.     {
  437.         if (ze_get_user_level(id) == 0 && iIndex >= 2 ||
  438.         ze_get_user_level(id) == 1 && iIndex >= 3 ||
  439.         ze_get_user_level(id) == 2 && iIndex >= 4 ||
  440.         ze_get_user_level(id) == 3 && iIndex >= 5 ||
  441.         ze_get_user_level(id) == 4 && iIndex >= 6)
  442.         {
  443.             break
  444.         }
  445.        
  446.         ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
  447.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\w%d.\y %s", iIndex+1, szWeaponNames[get_weaponid(szWeaponName)])
  448.     }
  449.    
  450.     if (iIndex < ArraySize(g_szSecondaryWeapons))
  451.     {
  452.         ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
  453.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r Next Level Unlock\w: \y%s", szWeaponNames[get_weaponid(szWeaponName)])
  454.     }
  455.    
  456.     // 8. Auto Select
  457.     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")
  458.    
  459.     // 0. Exit
  460.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\y %L", id, "EXIT")
  461.    
  462.     // Fix for AMXX custom menus
  463.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
  464.     show_menu(id, KEYSMENU, szMenu, iMenuTime, "Secondary Weapons")
  465. }
  466.  
  467. public Menu_Buy_Primary(id, key)
  468. {
  469.     // Player dead or zombie or already bought primary
  470.     if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtPrimary[id])
  471.         return PLUGIN_HANDLED
  472.    
  473.     // Special keys / weapon list exceeded
  474.     if (key >= MENU_KEY_AUTOSELECT || WPN_SELECTION >= WPN_MAXIDS[id])
  475.     {
  476.         switch (key)
  477.         {
  478.             case MENU_KEY_AUTOSELECT: // toggle auto select
  479.             {
  480.                 WPN_AUTO_ON = 1 - WPN_AUTO_ON
  481.             }
  482.             case MENU_KEY_NEXT: // next/back
  483.             {
  484.                 if (WPN_STARTID+7 < WPN_MAXIDS[id])
  485.                     WPN_STARTID += 7
  486.                 else
  487.                     WPN_STARTID = 0
  488.             }
  489.             case MENU_KEY_EXIT: // exit
  490.             {
  491.                 return PLUGIN_HANDLED
  492.             }
  493.         }
  494.        
  495.         // Show buy menu again
  496.         Show_Menu_Buy_Primary(id)
  497.         return PLUGIN_HANDLED
  498.     }
  499.    
  500.     // Store selected weapon id
  501.     WPN_AUTO_PRI = WPN_SELECTION
  502.    
  503.     // Buy primary weapon
  504.     Buy_Primary_Weapon(id, WPN_AUTO_PRI)
  505.    
  506.     // Show Secondary Weapons
  507.     Show_Available_Buy_Menus(id)
  508.    
  509.     return PLUGIN_HANDLED
  510. }
  511.  
  512. public Buy_Primary_Weapon(id, selection)
  513. {
  514.     static szWeaponName[32]
  515.     ArrayGetString(g_szPrimaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
  516.     new iWeaponId = get_weaponid(szWeaponName)
  517.    
  518.     // Strip and Give Full Weapon
  519.     rg_give_item(id, szWeaponName, GT_REPLACE)
  520.     rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
  521.    
  522.     // Primary bought
  523.     g_bBoughtPrimary[id] = true
  524. }
  525.  
  526. public Menu_Buy_Secondary(id, key)
  527. {
  528.     // Player dead or zombie or already bought secondary
  529.     if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtSecondary[id])
  530.         return PLUGIN_HANDLED
  531.    
  532.     // Special keys / weapon list exceeded
  533.     if (key >= ArraySize(g_szSecondaryWeapons))
  534.     {
  535.         // Toggle autoselect
  536.         if (key == MENU_KEY_AUTOSELECT)
  537.             WPN_AUTO_ON = 1 - WPN_AUTO_ON
  538.        
  539.         // Reshow menu unless user exited
  540.         if (key != MENU_KEY_EXIT)
  541.             Show_Menu_Buy_Secondary(id)
  542.        
  543.         return PLUGIN_HANDLED
  544.     }
  545.    
  546.     // Store selected weapon id
  547.     WPN_AUTO_SEC = key
  548.    
  549.     // Buy secondary weapon
  550.     Buy_Secondary_Weapon(id, key)
  551.    
  552.     return PLUGIN_HANDLED
  553. }
  554.  
  555. public Buy_Secondary_Weapon(id, selection)
  556. {
  557.     if ( ((selection == 2) && (ze_get_user_level(id) < 1)) ||
  558.     ((selection == 3) && (ze_get_user_level(id) < 2)) ||
  559.     ((selection == 4) && (ze_get_user_level(id) < 3)) ||
  560.     ((selection == 5) && (ze_get_user_level(id) < 4)) )
  561.     {
  562.         Show_Menu_Buy_Secondary(id)
  563.         return;
  564.     }
  565.  
  566.     static szWeaponName[32]
  567.     ArrayGetString(g_szSecondaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
  568.     new iWeaponId = get_weaponid(szWeaponName)
  569.    
  570.     // Strip and Give Full Weapon
  571.     rg_give_item(id, szWeaponName, GT_REPLACE)
  572.     rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
  573.    
  574.     // Secondary bought
  575.     g_bBoughtSecondary[id] = true
  576. }
  577.  
  578. public Fw_TouchWeapon_Pre(iEnt, id)
  579. {
  580.     if (get_pcvar_num(g_pCvarBlockWeapLowLvl) == 0)
  581.         return HAM_IGNORED;
  582.    
  583.     // Not alive or Not Valid Weapon?
  584.     if(!is_user_alive(id) || !pev_valid(iEnt))
  585.         return HAM_IGNORED;
  586.    
  587.     // Get Weapon Model
  588.     new szWeapModel[32]
  589.     pev(iEnt, pev_model, szWeapModel, charsmax(szWeapModel))
  590.    
  591.     // Remove "models/w_" and ".mdl"
  592.     copyc(szWeapModel, charsmax(szWeapModel), szWeapModel[contain(szWeapModel, "_" ) + 1], '.')
  593.    
  594.     // Set for mp5 to be same as "weapon_mp5navy"
  595.     if(szWeapModel[1] == 'p' && szWeapModel[2] == '5')
  596.         szWeapModel = "mp5navy"
  597.    
  598.     // Add "weapon_" to all model names
  599.     static szWeaponEnt[32]
  600.     formatex(szWeaponEnt, charsmax(szWeaponEnt), "weapon_%s", szWeapModel)
  601.  
  602.     // Get it's index in Weapon Array
  603.     new iIndex, i
  604.    
  605.     // I won't explain the blew code if you need to understand ask me in Escapers-Zone.XYZ
  606.     for (i = 0; i < ArraySize(g_szPrimaryWeapons); i++)
  607.     {
  608.         new szPrimaryWeapon[32]
  609.         ArrayGetString(g_szPrimaryWeapons, i, szPrimaryWeapon, charsmax(szPrimaryWeapon))
  610.        
  611.         if (equali(szWeaponEnt, szPrimaryWeapon))
  612.             iIndex = i
  613.     }
  614.    
  615.     if (ze_get_user_level(id) == 0 && iIndex > 1)
  616.     {
  617.         return HAM_SUPERCEDE;
  618.     }
  619.    
  620.     for (i = 1; i <= 11; i++)
  621.     {
  622.         if ((ze_get_user_level(id) == i) && iIndex > i+1)
  623.         {
  624.             return HAM_SUPERCEDE;
  625.         }
  626.     }
  627.    
  628.     return HAM_IGNORED;
  629. }
  630.  
  631. // Natives
  632. public native_ze_show_weapon_menu(id)
  633. {
  634.     if (!is_user_connected(id))
  635.     {
  636.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
  637.         return false
  638.     }
  639.    
  640.     Cmd_Buy(id)
  641.     return true
  642. }
  643.  
  644. public native_ze_is_auto_buy_enabled(id)
  645. {
  646.     if (!is_user_connected(id))
  647.     {
  648.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
  649.         return -1;
  650.     }
  651.    
  652.     return WPN_AUTO_ON;
  653. }
  654.  
  655. public native_ze_disable_auto_buy(id)
  656. {
  657.     if (!is_user_connected(id))
  658.     {
  659.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
  660.         return false
  661.     }
  662.    
  663.     WPN_AUTO_ON = 0;
  664.     return true
  665. }

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1703
Joined: 1 Year Ago
Location: Egypt
Has thanked: 28 times
Been thanked: 75 times
Age: 20
Contact:

#14

Post by Raheem » 2 Months Ago

What you mean by open in level 5?

Give full example and i'll edit it.
You don't know? Learn and you will know.

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 257
Joined: 2 Months Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 19 times
Age: 33
Contact:

#15

Post by Mark » 2 Months Ago

Raheem wrote:
2 Months Ago
What you mean by open in level 5?

Give full example and i'll edit it.
These guns
  1.     "weapon_xm1014",  // Level 0
  2.     "weapon_ump45",   // Level 0
  3.     "weapon_m3",      // Level 5
  4.     "weapon_mp5navy", // Level 5
  5.     "weapon_p90",     // Level 10
  6.     "weapon_galil",   // Level 10
  7.     "weapon_famas",   // Level 15
  8.     "weapon_sg550",   // Level 15
  9.     "weapon_g3sg1",   // Level 20
  10.     "weapon_m249",    // Level 20
  11.     "weapon_sg552",   // Level 25
  12.     "weapon_aug",     // Level 25
  13.     "weapon_m4a1",    // Level 30
  14.     "weapon_ak47"     // Level 30
Just seems they get weapons way to fast

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1703
Joined: 1 Year Ago
Location: Egypt
Has thanked: 28 times
Been thanked: 75 times
Age: 20
Contact:

#16

Post by Raheem » 1 Month Ago

Here:

  1. #include <zombie_escape>
  2. #include <ze_levels>
  3.  
  4. // Setting File
  5. new const ZE_SETTING_RESOURCES[] = "zombie_escape.ini"
  6.  
  7. // Keys
  8. 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
  9. const OFFSET_CSMENUCODE = 205
  10.  
  11. // Primary Weapons Entities [Default Values]
  12. new const szPrimaryWeaponEnt[][] =
  13. {
  14.     "weapon_xm1014",  // Level 0
  15.     "weapon_ump45",   // Level 0
  16.     "weapon_m3",      // Level 5
  17.     "weapon_mp5navy", // Level 5
  18.     "weapon_p90",     // Level 10
  19.     "weapon_galil",   // Level 10
  20.     "weapon_famas",   // Level 15
  21.     "weapon_sg550",   // Level 15
  22.     "weapon_g3sg1",   // Level 20
  23.     "weapon_m249",    // Level 20
  24.     "weapon_sg552",   // Level 25
  25.     "weapon_aug",     // Level 25
  26.     "weapon_m4a1",    // Level 30
  27.     "weapon_ak47"     // Level 30
  28. }
  29.  
  30. // Secondary Weapons Entities [Default Values]
  31. new const szSecondaryWeaponEnt[][]=
  32. {
  33.     "weapon_usp",         // Level 0
  34.     "weapon_p228",        // Level 0
  35.     "weapon_glock18",     // Level 1
  36.     "weapon_fiveseven",   // Level 2
  37.     "weapon_deagle",      // Level 3
  38.     "weapon_elite"        // Level 4
  39. }
  40.  
  41. // Primary and Secondary Weapons Names [Default Values]
  42. new const szWeaponNames[][] =
  43. {
  44.     "",
  45.     "P228",
  46.     "",
  47.     "Scout",
  48.     "HE Grenade",
  49.     "XM1014",
  50.     "",
  51.     "MAC-10",
  52.     "AUG",
  53.     "Smoke Grenade",
  54.     "Dual Elite",
  55.     "Five Seven",
  56.     "UMP 45",
  57.     "SG-550",
  58.     "Galil",
  59.     "Famas",
  60.     "USP",
  61.     "Glock",
  62.     "AWP",
  63.     "MP5",
  64.     "M249",
  65.     "M3",
  66.     "M4A1",
  67.     "TMP",
  68.     "G3SG1",
  69.     "Flashbang",
  70.     "Desert Eagle",
  71.     "SG-552",
  72.     "AK-47",
  73.     "",
  74.     "P90"
  75. }
  76.  
  77. // Max Back Clip Ammo (Change it From here if you need)
  78. new const szMaxBPAmmo[] =
  79. {
  80.     -1,
  81.     52,
  82.     -1,
  83.     90,
  84.     1,
  85.     32,
  86.     1,
  87.     100,
  88.     90,
  89.     1,
  90.     120,
  91.     100,
  92.     100,
  93.     90,
  94.     90,
  95.     90,
  96.     100,
  97.     120,
  98.     30,
  99.     120,
  100.     200,
  101.     32,
  102.     90,
  103.     120,
  104.     90,
  105.     2,
  106.     35,
  107.     90,
  108.     90,
  109.     -1,
  110.     100
  111. }
  112.  
  113. // Menu selections
  114. const MENU_KEY_AUTOSELECT = 7
  115. const MENU_KEY_BACK = 7
  116. const MENU_KEY_NEXT = 8
  117. const MENU_KEY_EXIT = 9
  118.  
  119. // Variables
  120. new Array:g_szPrimaryWeapons,
  121.     Array:g_szSecondaryWeapons
  122.  
  123. new g_iMenuData[33][4],
  124.     Float:g_flBuyTimeStart[33],
  125.     bool:g_bBoughtPrimary[33],
  126.     bool:g_bBoughtSecondary[33]
  127.     new WPN_MAXIDS[33]
  128.  
  129. // Define
  130. #define WPN_STARTID g_iMenuData[id][0]
  131. #define WPN_SELECTION (g_iMenuData[id][0]+key)
  132. #define WPN_AUTO_ON g_iMenuData[id][1]
  133. #define WPN_AUTO_PRI g_iMenuData[id][2]
  134. #define WPN_AUTO_SEC g_iMenuData[id][3]
  135.  
  136. // Cvars
  137. new g_pCvarBuyTime,
  138.     g_pCvarHEGrenade,
  139.     g_pCvarSmokeGrenade,
  140.     g_pCvarFlashGrenade,
  141.     g_pCvarBlockWeapLowLvl
  142.  
  143. public plugin_natives()
  144. {
  145.     register_native("ze_show_weapon_menu", "native_ze_show_weapon_menu", 1)
  146.     register_native("ze_is_auto_buy_enabled", "native_ze_is_auto_buy_enabled", 1)
  147.     register_native("ze_disable_auto_buy", "native_ze_disable_auto_buy", 1)
  148. }
  149.  
  150. public plugin_precache()
  151. {
  152.     // Initialize arrays (32 is the max length of Weapon Entity like: weapon_ak47)
  153.     g_szPrimaryWeapons = ArrayCreate(32, 1)
  154.     g_szSecondaryWeapons = ArrayCreate(32, 1)
  155.    
  156.     // Load from external file
  157.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
  158.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
  159.    
  160.     // If we couldn't load from file, use and save default ones
  161.    
  162.     new iIndex
  163.    
  164.     if (ArraySize(g_szPrimaryWeapons) == 0)
  165.     {
  166.         for (iIndex = 0; iIndex < sizeof szPrimaryWeaponEnt; iIndex++)
  167.             ArrayPushString(g_szPrimaryWeapons, szPrimaryWeaponEnt[iIndex])
  168.        
  169.         // If not found .ini File Create it and save default values in it
  170.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
  171.     }
  172.    
  173.     if (ArraySize(g_szSecondaryWeapons) == 0)
  174.     {
  175.         for (iIndex = 0; iIndex < sizeof szSecondaryWeaponEnt; iIndex++)
  176.             ArrayPushString(g_szSecondaryWeapons, szSecondaryWeaponEnt[iIndex])
  177.        
  178.         // If not found .ini File Create it and save default values in it
  179.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
  180.     }
  181. }
  182.  
  183. public plugin_init()
  184. {
  185.     register_plugin("[ZE] Levels Weapons Menu", "1.1", "Raheem")
  186.    
  187.     // Commands
  188.     register_clcmd("guns", "Cmd_Buy")
  189.     register_clcmd("say /enable", "Cmd_Enable")
  190.     register_clcmd("say_team /enable", "Cmd_Enable")
  191.    
  192.     // Cvars
  193.     g_pCvarBuyTime = register_cvar("ze_buy_time", "60")
  194.     g_pCvarHEGrenade = register_cvar("ze_give_HE_nade", "1") // 0 Nothing || 1 Give HE
  195.     g_pCvarSmokeGrenade = register_cvar("ze_give_SM_nade", "1")
  196.     g_pCvarFlashGrenade = register_cvar("ze_give_FB_nade", "1")
  197.     g_pCvarBlockWeapLowLvl = register_cvar("ze_block_weapons_lowlvl", "1")
  198.    
  199.     // Menus
  200.     register_menu("Primary Weapons", KEYSMENU, "Menu_Buy_Primary")
  201.     register_menu("Secondary Weapons", KEYSMENU, "Menu_Buy_Secondary")
  202.    
  203.     // Hams
  204.     RegisterHam(Ham_Touch, "weaponbox", "Fw_TouchWeapon_Pre", 0)
  205.     RegisterHam(Ham_Touch, "armoury_entity", "Fw_TouchWeapon_Pre", 0)
  206. }
  207.  
  208. public client_disconnected(id)
  209. {
  210.     WPN_AUTO_ON = 0
  211.     WPN_STARTID = 0
  212. }
  213.  
  214. public Cmd_Enable(id)
  215. {
  216.     if (WPN_AUTO_ON)
  217.     {
  218.         ze_colored_print(id, "%L", LANG_PLAYER, "BUY_ENABLED")
  219.         WPN_AUTO_ON = 0
  220.     }
  221. }
  222.  
  223. public Cmd_Buy(id)
  224. {
  225.     // Player Zombie
  226.     if (ze_is_user_zombie(id))
  227.     {
  228.         ze_colored_print(id, "%L", LANG_PLAYER, "NO_BUY_ZOMBIE")
  229.         return
  230.     }
  231.    
  232.     // Player Dead
  233.     if (!is_user_alive(id))
  234.     {
  235.         ze_colored_print(id, "%L", LANG_PLAYER, "DEAD_CANT_BUY_WEAPON")
  236.         return
  237.     }
  238.    
  239.     // Already bought
  240.     if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
  241.     {
  242.         ze_colored_print(id, "%L", LANG_PLAYER, "ALREADY_BOUGHT")
  243.     }
  244.    
  245.     Show_Available_Buy_Menus(id)
  246. }
  247.  
  248. public ze_user_humanized(id)
  249. {
  250.     // Static Values
  251.     switch (ze_get_user_level(id))
  252.     {
  253.         case 0..4: WPN_MAXIDS[id] = 2
  254.         case 5..9: WPN_MAXIDS[id] = 4
  255.         case 10..14: WPN_MAXIDS[id] = 6
  256.         case 15..19: WPN_MAXIDS[id] = 8
  257.         case 20..24: WPN_MAXIDS[id] = 10
  258.         case 25..29: WPN_MAXIDS[id] = 12
  259.         case 30: WPN_MAXIDS[id] = 14
  260.     }
  261.    
  262.     if (ze_get_user_level(id) > 30)
  263.     {
  264.         WPN_MAXIDS[id] = 14
  265.     }
  266.  
  267.     // Buyzone time starts when player is set to human
  268.     g_flBuyTimeStart[id] = get_gametime()
  269.    
  270.     g_bBoughtPrimary[id] = false
  271.     g_bBoughtSecondary[id] = false
  272.    
  273.     // Player dead or zombie
  274.     if (!is_user_alive(id) || ze_is_user_zombie(id))
  275.         return
  276.    
  277.     if (WPN_AUTO_ON)
  278.     {
  279.         ze_colored_print(id, "%L", LANG_PLAYER, "RE_ENABLE_MENU")
  280.         Buy_Primary_Weapon(id, WPN_AUTO_PRI)
  281.         Buy_Secondary_Weapon(id, WPN_AUTO_SEC)
  282.     }
  283.    
  284.     // Open available buy menus
  285.     Show_Available_Buy_Menus(id)
  286.    
  287.     // Give HE Grenade
  288.     if (get_pcvar_num(g_pCvarHEGrenade) != 0)
  289.         rg_give_item(id, "weapon_hegrenade")
  290.    
  291.     // Give Smoke Grenade
  292.     if (get_pcvar_num(g_pCvarSmokeGrenade) != 0)
  293.         rg_give_item(id, "weapon_smokegrenade")
  294.    
  295.     // Give Flashbang Grenade
  296.     if (get_pcvar_num(g_pCvarFlashGrenade) != 0)
  297.         rg_give_item(id, "weapon_flashbang")
  298. }
  299.  
  300. public Show_Available_Buy_Menus(id)
  301. {
  302.     // Already Bought
  303.     if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
  304.         return
  305.    
  306.     // Here we use if and else if so we make sure that Primary weapon come first then secondary
  307.     if (!g_bBoughtPrimary[id])
  308.     {
  309.         // Primary    
  310.         Show_Menu_Buy_Primary(id)
  311.     }
  312.     else if (!g_bBoughtSecondary[id])
  313.     {
  314.         // Secondary
  315.         Show_Menu_Buy_Secondary(id)
  316.     }
  317. }
  318.  
  319. public Show_Menu_Buy_Primary(id)
  320. {
  321.     new iMenuTime = floatround(g_flBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
  322.    
  323.     if (iMenuTime <= 0)
  324.     {
  325.         ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
  326.         return
  327.     }
  328.    
  329.     static szMenu[300], szWeaponName[32]
  330.     new iLen, iIndex, iMaxLoops = min(WPN_STARTID+7, WPN_MAXIDS[id])
  331.    
  332.     // Title
  333.     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]))
  334.    
  335.     // 1-7. Weapon List
  336.     for (iIndex = WPN_STARTID; iIndex < iMaxLoops; iIndex++)
  337.     {
  338.         if (ze_get_user_level(id) == 0 && iIndex >= 2||
  339.         ze_get_user_level(id) == 5 && iIndex >= 4 ||
  340.         ze_get_user_level(id) == 10 && iIndex >= 6 ||
  341.         ze_get_user_level(id) == 15 && iIndex >= 8 ||
  342.         ze_get_user_level(id) == 20 && iIndex >= 10 ||
  343.         ze_get_user_level(id) == 25 && iIndex >= 12 ||
  344.         ze_get_user_level(id) == 30 && iIndex >= 14)
  345.         {
  346.             break
  347.         }
  348.  
  349.         ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
  350.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, szWeaponNames[get_weaponid(szWeaponName)])
  351.     }
  352.    
  353.     if (ze_get_user_level(id) < 5)
  354.     {
  355.         ArrayGetString(g_szPrimaryWeapons, 2, szWeaponName, charsmax(szWeaponName))
  356.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 5 Unlock\w: \y%s, ", szWeaponNames[get_weaponid(szWeaponName)])
  357.        
  358.         ArrayGetString(g_szPrimaryWeapons, 3, szWeaponName, charsmax(szWeaponName))
  359.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "%s^n", szWeaponNames[get_weaponid(szWeaponName)])
  360.     }
  361.    
  362.     if (ze_get_user_level(id) >= 5 && ze_get_user_level(id) < 10)
  363.     {
  364.         ArrayGetString(g_szPrimaryWeapons, 4, szWeaponName, charsmax(szWeaponName))
  365.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 10 Unlock\w: \y%s, ", szWeaponNames[get_weaponid(szWeaponName)])
  366.        
  367.         ArrayGetString(g_szPrimaryWeapons, 5, szWeaponName, charsmax(szWeaponName))
  368.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "%s^n", szWeaponNames[get_weaponid(szWeaponName)])
  369.     }
  370.    
  371.     if (ze_get_user_level(id) >= 10 && ze_get_user_level(id) < 15)
  372.     {
  373.         ArrayGetString(g_szPrimaryWeapons, 6, szWeaponName, charsmax(szWeaponName))
  374.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 15 Unlock\w: \y%s, ", szWeaponNames[get_weaponid(szWeaponName)])
  375.        
  376.         ArrayGetString(g_szPrimaryWeapons, 7, szWeaponName, charsmax(szWeaponName))
  377.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "%s^n", szWeaponNames[get_weaponid(szWeaponName)])
  378.     }
  379.    
  380.     if (ze_get_user_level(id) >= 15 && ze_get_user_level(id) < 20)
  381.     {
  382.         ArrayGetString(g_szPrimaryWeapons, 8, szWeaponName, charsmax(szWeaponName))
  383.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 20 Unlock\w: \y%s, ", szWeaponNames[get_weaponid(szWeaponName)])
  384.        
  385.         ArrayGetString(g_szPrimaryWeapons, 9, szWeaponName, charsmax(szWeaponName))
  386.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "%s^n", szWeaponNames[get_weaponid(szWeaponName)])
  387.     }
  388.    
  389.     if (ze_get_user_level(id) >= 20 && ze_get_user_level(id) < 25)
  390.     {
  391.         ArrayGetString(g_szPrimaryWeapons, 10, szWeaponName, charsmax(szWeaponName))
  392.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 25 Unlock\w: \y%s, ", szWeaponNames[get_weaponid(szWeaponName)])
  393.        
  394.         ArrayGetString(g_szPrimaryWeapons, 11, szWeaponName, charsmax(szWeaponName))
  395.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "%s^n", szWeaponNames[get_weaponid(szWeaponName)])
  396.     }
  397.    
  398.     if (ze_get_user_level(id) >= 25 && ze_get_user_level(id) < 30)
  399.     {
  400.         ArrayGetString(g_szPrimaryWeapons, 12, szWeaponName, charsmax(szWeaponName))
  401.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 30 Unlock\w: \y%s, ", szWeaponNames[get_weaponid(szWeaponName)])
  402.        
  403.         ArrayGetString(g_szPrimaryWeapons, 13, szWeaponName, charsmax(szWeaponName))
  404.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "%s^n", szWeaponNames[get_weaponid(szWeaponName)])
  405.     }
  406.  
  407.     // 8. Auto Select
  408.     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")
  409.    
  410.     // 9. Next/Back - 0. Exit
  411.     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")
  412.    
  413.     // Fix for AMXX custom menus
  414.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
  415.     show_menu(id, KEYSMENU, szMenu, iMenuTime, "Primary Weapons")
  416. }
  417.  
  418. public Show_Menu_Buy_Secondary(id)
  419. {
  420.     new iMenuTime = floatround(g_flBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
  421.    
  422.     if (iMenuTime <= 0)
  423.     {
  424.         ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
  425.         return
  426.     }
  427.    
  428.     static szMenu[250], szWeaponName[32]
  429.     new iLen, iIndex, iMaxLoops = ArraySize(g_szSecondaryWeapons)
  430.    
  431.     // Title
  432.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L^n", id, "MENU_SECONDARY_TITLE")
  433.    
  434.     // 1-6. Weapon List
  435.     for (iIndex = 0; iIndex < iMaxLoops; iIndex++)
  436.     {
  437.         if (ze_get_user_level(id) == 0 && iIndex >= 2 ||
  438.         ze_get_user_level(id) == 1 && iIndex >= 3 ||
  439.         ze_get_user_level(id) == 2 && iIndex >= 4 ||
  440.         ze_get_user_level(id) == 3 && iIndex >= 5 ||
  441.         ze_get_user_level(id) == 4 && iIndex >= 6)
  442.         {
  443.             break
  444.         }
  445.        
  446.         ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
  447.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\w%d.\y %s", iIndex+1, szWeaponNames[get_weaponid(szWeaponName)])
  448.     }
  449.    
  450.     if (iIndex < ArraySize(g_szSecondaryWeapons))
  451.     {
  452.         ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
  453.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r Next Level Unlock\w: \y%s", szWeaponNames[get_weaponid(szWeaponName)])
  454.     }
  455.    
  456.     // 8. Auto Select
  457.     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")
  458.    
  459.     // 0. Exit
  460.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\y %L", id, "EXIT")
  461.    
  462.     // Fix for AMXX custom menus
  463.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
  464.     show_menu(id, KEYSMENU, szMenu, iMenuTime, "Secondary Weapons")
  465. }
  466.  
  467. public Menu_Buy_Primary(id, key)
  468. {
  469.     // Player dead or zombie or already bought primary
  470.     if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtPrimary[id])
  471.         return PLUGIN_HANDLED
  472.    
  473.     // Special keys / weapon list exceeded
  474.     if (key >= MENU_KEY_AUTOSELECT || WPN_SELECTION >= WPN_MAXIDS[id])
  475.     {
  476.         switch (key)
  477.         {
  478.             case MENU_KEY_AUTOSELECT: // toggle auto select
  479.             {
  480.                 WPN_AUTO_ON = 1 - WPN_AUTO_ON
  481.             }
  482.             case MENU_KEY_NEXT: // next/back
  483.             {
  484.                 if (WPN_STARTID+7 < WPN_MAXIDS[id])
  485.                     WPN_STARTID += 7
  486.                 else
  487.                     WPN_STARTID = 0
  488.             }
  489.             case MENU_KEY_EXIT: // exit
  490.             {
  491.                 return PLUGIN_HANDLED
  492.             }
  493.         }
  494.        
  495.         // Show buy menu again
  496.         Show_Menu_Buy_Primary(id)
  497.         return PLUGIN_HANDLED
  498.     }
  499.    
  500.     // Store selected weapon id
  501.     WPN_AUTO_PRI = WPN_SELECTION
  502.    
  503.     // Buy primary weapon
  504.     Buy_Primary_Weapon(id, WPN_AUTO_PRI)
  505.    
  506.     // Show Secondary Weapons
  507.     Show_Available_Buy_Menus(id)
  508.    
  509.     return PLUGIN_HANDLED
  510. }
  511.  
  512. public Buy_Primary_Weapon(id, selection)
  513. {
  514.     static szWeaponName[32]
  515.     ArrayGetString(g_szPrimaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
  516.     new iWeaponId = get_weaponid(szWeaponName)
  517.    
  518.     // Strip and Give Full Weapon
  519.     rg_give_item(id, szWeaponName, GT_REPLACE)
  520.     rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
  521.    
  522.     // Primary bought
  523.     g_bBoughtPrimary[id] = true
  524. }
  525.  
  526. public Menu_Buy_Secondary(id, key)
  527. {
  528.     // Player dead or zombie or already bought secondary
  529.     if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtSecondary[id])
  530.         return PLUGIN_HANDLED
  531.    
  532.     // Special keys / weapon list exceeded
  533.     if (key >= ArraySize(g_szSecondaryWeapons))
  534.     {
  535.         // Toggle autoselect
  536.         if (key == MENU_KEY_AUTOSELECT)
  537.             WPN_AUTO_ON = 1 - WPN_AUTO_ON
  538.        
  539.         // Reshow menu unless user exited
  540.         if (key != MENU_KEY_EXIT)
  541.             Show_Menu_Buy_Secondary(id)
  542.        
  543.         return PLUGIN_HANDLED
  544.     }
  545.    
  546.     // Store selected weapon id
  547.     WPN_AUTO_SEC = key
  548.    
  549.     // Buy secondary weapon
  550.     Buy_Secondary_Weapon(id, key)
  551.    
  552.     return PLUGIN_HANDLED
  553. }
  554.  
  555. public Buy_Secondary_Weapon(id, selection)
  556. {
  557.     if ( ((selection == 2) && (ze_get_user_level(id) < 1)) ||
  558.     ((selection == 3) && (ze_get_user_level(id) < 2)) ||
  559.     ((selection == 4) && (ze_get_user_level(id) < 3)) ||
  560.     ((selection == 5) && (ze_get_user_level(id) < 4)) )
  561.     {
  562.         Show_Menu_Buy_Secondary(id)
  563.         return;
  564.     }
  565.  
  566.     static szWeaponName[32]
  567.     ArrayGetString(g_szSecondaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
  568.     new iWeaponId = get_weaponid(szWeaponName)
  569.    
  570.     // Strip and Give Full Weapon
  571.     rg_give_item(id, szWeaponName, GT_REPLACE)
  572.     rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
  573.    
  574.     // Secondary bought
  575.     g_bBoughtSecondary[id] = true
  576. }
  577.  
  578. public Fw_TouchWeapon_Pre(iEnt, id)
  579. {
  580.     if (get_pcvar_num(g_pCvarBlockWeapLowLvl) == 0)
  581.         return HAM_IGNORED;
  582.    
  583.     // Not alive or Not Valid Weapon?
  584.     if(!is_user_alive(id) || !pev_valid(iEnt))
  585.         return HAM_IGNORED;
  586.    
  587.     // Get Weapon Model
  588.     new szWeapModel[32]
  589.     pev(iEnt, pev_model, szWeapModel, charsmax(szWeapModel))
  590.    
  591.     // Remove "models/w_" and ".mdl"
  592.     copyc(szWeapModel, charsmax(szWeapModel), szWeapModel[contain(szWeapModel, "_" ) + 1], '.')
  593.    
  594.     // Set for mp5 to be same as "weapon_mp5navy"
  595.     if(szWeapModel[1] == 'p' && szWeapModel[2] == '5')
  596.         szWeapModel = "mp5navy"
  597.    
  598.     // Add "weapon_" to all model names
  599.     static szWeaponEnt[32]
  600.     formatex(szWeaponEnt, charsmax(szWeaponEnt), "weapon_%s", szWeapModel)
  601.  
  602.     // Get it's index in Weapon Array
  603.     new iIndex, i
  604.    
  605.     // I won't explain the blew code if you need to understand ask me in Escapers-Zone.XYZ
  606.     for (i = 0; i < ArraySize(g_szPrimaryWeapons); i++)
  607.     {
  608.         new szPrimaryWeapon[32]
  609.         ArrayGetString(g_szPrimaryWeapons, i, szPrimaryWeapon, charsmax(szPrimaryWeapon))
  610.        
  611.         if (equali(szWeaponEnt, szPrimaryWeapon))
  612.             iIndex = i
  613.     }
  614.    
  615.     if (ze_get_user_level(id) == 0 && iIndex > 1)
  616.     {
  617.         return HAM_SUPERCEDE;
  618.     }
  619.    
  620.     for (i = 1; i <= 11; i++)
  621.     {
  622.         if ((ze_get_user_level(id) == i) && iIndex > i+1)
  623.         {
  624.             return HAM_SUPERCEDE;
  625.         }
  626.     }
  627.    
  628.     return HAM_IGNORED;
  629. }
  630.  
  631. // Natives
  632. public native_ze_show_weapon_menu(id)
  633. {
  634.     if (!is_user_connected(id))
  635.     {
  636.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
  637.         return false
  638.     }
  639.    
  640.     Cmd_Buy(id)
  641.     return true
  642. }
  643.  
  644. public native_ze_is_auto_buy_enabled(id)
  645. {
  646.     if (!is_user_connected(id))
  647.     {
  648.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
  649.         return -1;
  650.     }
  651.    
  652.     return WPN_AUTO_ON;
  653. }
  654.  
  655. public native_ze_disable_auto_buy(id)
  656. {
  657.     if (!is_user_connected(id))
  658.     {
  659.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
  660.         return false
  661.     }
  662.    
  663.     WPN_AUTO_ON = 0;
  664.     return true
  665. }

Screenshots:
  • level15.png
    level30.png
You don't know? Learn and you will know.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests