Add gun to level_system

Unpaid Requests, Public Plugins
czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 598
Joined: 7 years ago
Contact:

#21

Post by czirimbolo » 5 years ago

Raheem wrote: 5 years ago
  1.        // JetPack
  2.         if (ze_get_user_level(id) >= 40 && ze_get_user_level(id) < 40)
  3.         {
  4.             if (iIndex == 14)
  5.             {
  6.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Scar Beast")
  7.             }
  8.            
  9.             if (iIndex == 15)
  10.             {
  11.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Laser MiniGun")
  12.             }
  13.            
  14.             if (iIndex == 16)
  15.             {
  16.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Guardian Aug")
  17.             }
  18.            
  19.             if (iIndex == 17)
  20.             {
  21.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
  22.             }
  23.            
  24.             if (iIndex == 18)
  25.             {
  26.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK47")
  27.             }      
  28.            
  29.             if (iIndex == 19)
  30.             {
  31.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AK47 Bloodmoon")
  32.             }
  33.  
  34.             if (iIndex == 20)
  35.             {
  36.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Dual Sword")
  37.             }
  38.             if (iIndex == 21)
  39.             {
  40.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Jetpack")
  41.                 break;
  42.         }
:arrow:
  1.        // JetPack
  2.         if (ze_get_user_level(id) >= 40 && ze_get_user_level(id) < 40)
  3.         {
  4.             if (iIndex == 14)
  5.             {
  6.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Scar Beast")
  7.             }
  8.            
  9.             if (iIndex == 15)
  10.             {
  11.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Laser MiniGun")
  12.             }
  13.            
  14.             if (iIndex == 16)
  15.             {
  16.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Guardian Aug")
  17.             }
  18.            
  19.             if (iIndex == 17)
  20.             {
  21.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
  22.             }
  23.            
  24.             if (iIndex == 18)
  25.             {
  26.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK47")
  27.             }      
  28.            
  29.             if (iIndex == 19)
  30.             {
  31.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AK47 Bloodmoon")
  32.             }
  33.  
  34.             if (iIndex == 20)
  35.             {
  36.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Dual Sword")
  37.             }
  38.            
  39.             if (iIndex == 21)
  40.             {
  41.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Jetpack")
  42.                 break;
  43.             }
  44.         }

You just forget } in if (iIndex == 21).
Raheem, after uploading this, I dont have Weapon menu and extra item menu. When I press M, I can choose TEAM now:D

L 09/28/2018 - 19:16:14: Info (map "zm_isla_escape_lg") (file "addons/amxmodx/logs/error_20180928.log")
L 09/28/2018 - 19:16:14: Called dynanative into a paused plugin.
L 09/28/2018 - 19:16:14: [AMXX] Displaying debug trace (plugin "ze_main_menu.amxx", version "1.3")
L 09/28/2018 - 19:16:14: [AMXX] Run time error 10: native error (native "ze_is_auto_buy_enabled")
L 09/28/2018 - 19:16:14: [AMXX] [0] ze_main_menu.sma::Show_Menu_Main (line 47)
L 09/28/2018 - 19:16:14: [AMXX] [1] ze_main_menu.sma::Cmd_ChooseTeam (line 29)

here is my ze_main_menu

Code: Select all

#include <zombie_escape>

// Keys
const OFFSET_CSMENUCODE = 205
const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0

public plugin_init()
{
	register_plugin("[ZE] Main Menu", ZE_VERSION, AUTHORS)
	
	// Commands
	register_clcmd("chooseteam", "Cmd_ChooseTeam")
	register_clcmd("say /ze", "Cmd_ChooseTeam")
	register_clcmd("say_team /ze", "Cmd_ChooseTeam")
	
	// Register Menus
	register_menu("Main Menu", KEYSMENU, "Main_Menu")
}

public Cmd_ChooseTeam(id)
{
	if (!is_user_connected(id))
		return PLUGIN_CONTINUE;
	
	if (get_member(id, m_iTeam) == TEAM_TERRORIST || get_member(id, m_iTeam) == TEAM_CT)
	{
		Show_Menu_Main(id)
		return PLUGIN_HANDLED // Kill the Choose Team Command
	}
	
	// Player in Spec? Allow him to open choose team menu so he can join
	return PLUGIN_CONTINUE
}

// Main Menu
public Show_Menu_Main(id)
{
	static szMenu[250]
	new iLen
    
	// Title
	iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%L^n^n", id, "MAIN_MENU_TITLE")
	
	// 1. Buy Weapons
	if (!ze_is_auto_buy_enabled(id)) // AutoBuy not enabled - normal case
	{
		if (is_user_alive(id))
		{
			iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w1.\r %L^n", id, "MENU_WEAPONBUY")
		}
		else
		{
			iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d1. %L^n", id, "MENU_WEAPONBUY")
		}
	}
	else
	{
		// Auto-Buy enabled - Re-enable case
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w1.\r %L^n", id, "MENU_WEAPONBUY_RE_ENABLE")
	}
	
	// 2. Extra Items
	if (is_user_alive(id))
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w2.\r %L^n", id, "MENU_EXTRABUY")
	}
	else
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d2. %L^n", id, "MENU_EXTRABUY")
	}
    
	// 0. Exit
	iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\r %L", id, "EXIT")
    
	// Fix for AMXX custom menus
	set_pdata_int(id, OFFSET_CSMENUCODE, 0)
	show_menu(id, KEYSMENU, szMenu, -1, "Main Menu")
}

// Main Menu
public Main_Menu(id, key)
{
	// Player disconnected?
	if (!is_user_connected(id))
		return PLUGIN_HANDLED
    
	switch (key)
	{
		case 0: // Buy Weapons
		{
			if (!ze_is_auto_buy_enabled(id))
			{
				ze_show_weapon_menu(id)
			}
			else
			{
				ze_disable_auto_buy(id)
				Show_Menu_Main(id)
			}
		}
		case 1: // Extra Items
		{
			if (is_user_alive(id))
			{
				ze_show_items_menu(id)
			}
			else
			{
				ze_colored_print(id, "%L", id, "DEAD_CANT_BUY_WEAPON")
			}
		}
	}
	return PLUGIN_HANDLED
}
Image

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

#22

Post by Raheem » 5 years ago

Seems your weapons menu plugin not runing because something.

In console write amx_plugins and u will see why weapons menu disabled.

In most cases there is native used in weapons menu that require another plugin to be runing.
He who fails to plan is planning to fail

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#23

Post by Mark » 5 years ago

Raheem wrote: 5 years ago Seems your weapons menu plugin not runing because something.

In console write amx_plugins and u will see why weapons menu disabled.

In most cases there is native used in weapons menu that require another plugin to be runing.
No

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

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#24

Post by Mark » 5 years ago

This native was wrong and some other stuff let us know if it works..

native give_weapon_buffaug(id);

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 598
Joined: 7 years ago
Contact:

#25

Post by czirimbolo » 5 years ago

Ok I fixed this. Thanks Mark, this native was wrong, but anoter native was bad too in gun code.
Image

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 598
Joined: 7 years ago
Contact:

#26

Post by czirimbolo » 5 years ago

Can you guys help me with adding new pistol?

I want this pistol from 7 level, here is native: give_sfpistol(id)

Code: Select all

#include <zombie_escape>
#include <ze_levels>
 
native give_golden_m4a1(id);
native give_golden_ak47(id);
native ze_give_jetpack(id);
native give_daul_sword(id);    
native get_bak47p(id);        
native get_item(id);
native give_tho4mpson(id);
native give_buffaug(id);
 
 
// Setting File
new const ZE_SETTING_RESOURCES[] = "zombie_escape.ini"
 
// Keys
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
const OFFSET_CSMENUCODE = 205
 
// Primary Weapons Entities [Default Values]
new const szPrimaryWeaponEnt[][] =
{
    "weapon_xm1014",  // Level 0
    "weapon_ump45",   // Level 0
    "weapon_m3",      // Level 1
    "weapon_mp5navy", // Level 2
    "weapon_p90",     // Level 3
    "weapon_galil",   // Level 4
    "weapon_famas",   // Level 5
    "weapon_sg550",   // Level 6
    "weapon_g3sg1",   // Level 7
    "weapon_m249",    // Level 8
    "weapon_sg552",   // Level 9
    "weapon_aug",     // Level 10
    "weapon_m4a1",    // Level 11
    "weapon_ak47"     // Level 12
}
 
// Secondary Weapons Entities [Default Values]
new const szSecondaryWeaponEnt[][]=
{
    "weapon_usp",         // Level 0
    "weapon_p228",        // Level 0
    "weapon_glock18",     // Level 1
    "weapon_fiveseven",   // Level 2
    "weapon_deagle",      // Level 3
    "weapon_elite"        // Level 4
}
 
// Primary and Secondary Weapons Names [Default Values]
new const szWeaponNames[][] =
{
    "",
    "P228",
    "",
    "Scout",
    "HE Grenade",
    "XM1014",
    "",
    "MAC-10",
    "AUG",
    "Smoke Grenade",
    "Dual Elite",
    "Five Seven",
    "UMP 45",
    "SG-550",
    "Galil",
    "Famas",
    "USP",
    "Glock",
    "AWP",
    "MP5",
    "M249",
    "M3",
    "M4A1",
    "TMP",
    "G3SG1",
    "Flashbang",
    "Desert Eagle",
    "SG-552",
    "AK-47",
    "",
    "P90"
}
 
// Max Back Clip Ammo (Change it From here if you need)
new const szMaxBPAmmo[] =
{
    -1,
    52,
    -1,
    90,
    1,
    32,
    1,
    100,
    90,
    1,
    120,
    100,
    100,
    90,
    90,
    90,
    100,
    120,
    30,
    120,
    200,
    32,
    90,
    120,
    90,
    2,
    35,
    90,
    90,
    -1,
    100
}
 
// Menu selections
const MENU_KEY_AUTOSELECT = 7
const MENU_KEY_BACK = 7
const MENU_KEY_NEXT = 8
const MENU_KEY_EXIT = 9
 
// Variables
new Array:g_szPrimaryWeapons, Array:g_szSecondaryWeapons
 
new g_iMenuData[33][4],
    Float:g_fBuyTimeStart[33],
    bool:g_bBoughtPrimary[33],
    bool:g_bBoughtSecondary[33],
    WPN_MAXIDS[33]
 
// Define
#define WPN_STARTID g_iMenuData[id][0]
#define WPN_SELECTION (g_iMenuData[id][0]+key)
#define WPN_AUTO_ON g_iMenuData[id][1]
#define WPN_AUTO_PRI g_iMenuData[id][2]
#define WPN_AUTO_SEC g_iMenuData[id][3]
 
// Cvars
new g_pCvarBuyTime,
    g_pCvarHeGrenade,
    g_pCvarSmokeGrenade,
    g_pCvarFlashGrenade,
    g_pCvarBlockWeapLowLevel
 
public plugin_natives()
{
    register_native("ze_show_weapon_menu", "native_ze_show_weapon_menu", 1)
    register_native("ze_is_auto_buy_enabled", "native_ze_is_auto_buy_enabled", 1)
    register_native("ze_disable_auto_buy", "native_ze_disable_auto_buy", 1)
}
 
public plugin_precache()
{
    // Initialize arrays (32 is the max length of Weapon Entity like: weapon_ak47)
    g_szPrimaryWeapons = ArrayCreate(32, 1)
    g_szSecondaryWeapons = ArrayCreate(32, 1)
   
    // Load from external file
    amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
    amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
   
    // If we couldn't load from file, use and save default ones
   
    new iIndex
   
    if (ArraySize(g_szPrimaryWeapons) == 0)
    {
        for (iIndex = 0; iIndex < sizeof szPrimaryWeaponEnt; iIndex++)
            ArrayPushString(g_szPrimaryWeapons, szPrimaryWeaponEnt[iIndex])
       
        // If not found .ini File Create it and save default values in it
        amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
    }
   
    if (ArraySize(g_szSecondaryWeapons) == 0)
    {
        for (iIndex = 0; iIndex < sizeof szSecondaryWeaponEnt; iIndex++)
            ArrayPushString(g_szSecondaryWeapons, szSecondaryWeaponEnt[iIndex])
       
        // If not found .ini File Create it and save default values in it
        amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
    }
}
 
public plugin_init()
{
    register_plugin("[ZE] Levels Weapons Menu", "1.1", "Raheem")
   
    // Commands
    register_clcmd("guns", "Cmd_Buy")
    register_clcmd("say /enable", "Cmd_Enable")
    register_clcmd("say_team /enable", "Cmd_Enable")
   
    // Cvars
    g_pCvarBuyTime = register_cvar("ze_buy_time", "60")
    g_pCvarHeGrenade = register_cvar("ze_give_HE_nade", "1") // 0 Nothing || 1 Give HE
    g_pCvarSmokeGrenade = register_cvar("ze_give_SM_nade", "1")
    g_pCvarFlashGrenade = register_cvar("ze_give_FB_nade", "1")
    g_pCvarBlockWeapLowLevel = register_cvar("ze_block_weapons_lowlvl", "1")
   
    // Menus
    register_menu("Primary Weapons", KEYSMENU, "Menu_Buy_Primary")
    register_menu("Secondary Weapons", KEYSMENU, "Menu_Buy_Secondary")
   
    // Hams
    RegisterHam(Ham_Touch, "weaponbox", "Fw_TouchWeapon_Pre", 0)
    RegisterHam(Ham_Touch, "armoury_entity", "Fw_TouchWeapon_Pre", 0)
}
 
public client_disconnected(id)
{
    WPN_AUTO_ON = 0
    WPN_STARTID = 0
}
 
public Cmd_Enable(id)
{
    if (WPN_AUTO_ON)
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "BUY_ENABLED")
        WPN_AUTO_ON = 0
    }
}
 
public Cmd_Buy(id)
{
    // Player Zombie
    if (ze_is_user_zombie(id))
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "NO_BUY_ZOMBIE")
        return
    }
   
    // Player Dead
    if (!is_user_alive(id))
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "DEAD_CANT_BUY_WEAPON")
        return
    }
   
    // Already bought
    if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "ALREADY_BOUGHT")
    }
   
    Show_Available_Buy_Menus(id)
}
 
public ze_user_humanized(id)
{
    // Static Values
    switch (ze_get_user_level(id))
    {
        case 0: WPN_MAXIDS[id] = 2
        case 1: WPN_MAXIDS[id] = 3
        case 2: WPN_MAXIDS[id] = 4
        case 3: WPN_MAXIDS[id] = 5
        case 4: WPN_MAXIDS[id] = 6
        case 5: WPN_MAXIDS[id] = 7
        case 6: WPN_MAXIDS[id] = 8
        case 7: WPN_MAXIDS[id] = 9
        case 8: WPN_MAXIDS[id] = 10
        case 9: WPN_MAXIDS[id] = 11
        case 10: WPN_MAXIDS[id] = 12
        case 11: WPN_MAXIDS[id] = 13
        case 12..14: WPN_MAXIDS[id] = 14
        case 15..16: WPN_MAXIDS[id] = 15 // Scar Beast
        case 17..19: WPN_MAXIDS[id] = 16 // Laser MiniGun
        case 20..24: WPN_MAXIDS[id] = 17 // Aug Guardian
        case 25: WPN_MAXIDS[id] = 18 // Golden M4A1
        case 26..29: WPN_MAXIDS[id] = 19 // Golden AK47
        case 30..34: WPN_MAXIDS[id] = 20 // Ak47 bloodmoon
        case 35..39: WPN_MAXIDS[id] = 21   // Dual Sword
        case 40: WPN_MAXIDS[id] = 22    // Jetpack
    }
   
    if (ze_get_user_level(id) > 40)
    {
        WPN_MAXIDS[id] = 22
    }
 
    // Buyzone time starts when player is set to human
    g_fBuyTimeStart[id] = get_gametime()
   
    g_bBoughtPrimary[id] = false
    g_bBoughtSecondary[id] = false
   
    // Player dead or zombie
    if (!is_user_alive(id) || ze_is_user_zombie(id))
        return
   
    if (WPN_AUTO_ON)
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "RE_ENABLE_MENU")
        Buy_Primary_Weapon(id, WPN_AUTO_PRI)
        Buy_Secondary_Weapon(id, WPN_AUTO_SEC)
    }
   
    // Open available buy menus
    Show_Available_Buy_Menus(id)
   
    // Give HE Grenade
    if (get_pcvar_num(g_pCvarHeGrenade) != 0)
        rg_give_item(id, "weapon_hegrenade")
   
    // Give Smoke Grenade
    if (get_pcvar_num(g_pCvarSmokeGrenade) != 0)
        rg_give_item(id, "weapon_smokegrenade")
   
    // Give Flashbang Grenade
    if (get_pcvar_num(g_pCvarFlashGrenade) != 0)
        rg_give_item(id, "weapon_flashbang")
}
 
public Show_Available_Buy_Menus(id)
{
    // Already Bought
    if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
        return
   
    // Here we use if and else if so we make sure that Primary weapon come first then secondary
    if (!g_bBoughtPrimary[id])
    {
        // Primary    
        Show_Menu_Buy_Primary(id)
    }
    else if (!g_bBoughtSecondary[id])
    {
        // Secondary
        Show_Menu_Buy_Secondary(id)
    }
}
 
public Show_Menu_Buy_Primary(id)
{
    new iMenuTime = floatround(g_fBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
   
    if (iMenuTime <= 0)
    {
        ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
        return
    }
   
    static szMenu[300], szWeaponName[32]
    new iLen, iIndex, iMaxLoops = min(WPN_STARTID+7, WPN_MAXIDS[id])
   
    // Title
    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]))
   
    // 1-7. Weapon List
    for (iIndex = WPN_STARTID; iIndex < iMaxLoops; iIndex++)
    {
        if (ze_get_user_level(id) == 0 && iIndex >= 2||
        ze_get_user_level(id) == 1 && iIndex >= 3 ||
        ze_get_user_level(id) == 2 && iIndex >= 4 ||
        ze_get_user_level(id) == 3 && iIndex >= 5 ||
        ze_get_user_level(id) == 4 && iIndex >= 6 ||
        ze_get_user_level(id) == 5 && iIndex >= 7 ||
        ze_get_user_level(id) == 6 && iIndex >= 8 ||
        ze_get_user_level(id) == 7 && iIndex >= 9 ||
        ze_get_user_level(id) == 8 && iIndex >= 10 ||
        ze_get_user_level(id) == 9 && iIndex >= 11 ||
        ze_get_user_level(id) == 10 && iIndex >= 12 ||
        ze_get_user_level(id) == 11 && iIndex >= 13 ||
        ze_get_user_level(id) == 12 && iIndex >= 14)
        {
            break
        }
       
        /*
        *  Note that WPN_MAXIDS start from 1 but iIndex start from 0.
        */
       
       // Scar Beast
        if (ze_get_user_level(id) >= 15 && ze_get_user_level(id) < 17)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Scar Beast")
                break;
            }
        }
       
        // Laser MiniGun
        if (ze_get_user_level(id) >= 17 && ze_get_user_level(id) < 20)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Scar Beast")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Laser MiniGun")
                break;
            }
        }
       
        // Guardian Aug
        if (ze_get_user_level(id) >= 20 && ze_get_user_level(id) < 25)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Scar Beast")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Laser MiniGun")
            }
           
            if (iIndex == 16)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Guardian Aug")
                break;
            }
        }
       
        // Golden M4A1
        if (ze_get_user_level(id) >= 25 && ze_get_user_level(id) < 26)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Scar Beast")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Laser MiniGun")
            }
           
            if (iIndex == 16)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Guardian Aug")
            }
           
            if (iIndex == 17)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
                break;
            }
        }
       
        // Golden AK47
        if (ze_get_user_level(id) >= 26 && ze_get_user_level(id) < 30)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Scar Beast")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Laser MiniGun")
            }
           
            if (iIndex == 16)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Guardian Aug")
            }
           
            if (iIndex == 17)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
            }
           
            if (iIndex == 18)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK47")
                break;
            }          
        }
       
        // AK 47 Bloodmoon
        if (ze_get_user_level(id) >= 30 && ze_get_user_level(id) < 35)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Scar Beast")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Laser MiniGun")
            }
           
            if (iIndex == 16)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Guardian Aug")
            }
           
            if (iIndex == 17)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
            }
           
            if (iIndex == 18)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK47")
            }      
           
            if (iIndex == 19)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AK47 Bloodmoon")
                break;
            }      
        }
       
        // Dual Sword
        if (ze_get_user_level(id) >= 35 && ze_get_user_level(id) < 40)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Scar Beast")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Laser MiniGun")
            }
           
            if (iIndex == 16)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Guardian Aug")
            }
           
            if (iIndex == 17)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
            }
           
            if (iIndex == 18)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK47")
            }      
           
            if (iIndex == 19)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AK47 Bloodmoon")
            }
 
            if (iIndex == 20)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Dual Sword")
                break;
            }      
        }
       
       // JetPack
        if (ze_get_user_level(id) >= 40)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Scar Beast")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Laser MiniGun")
            }
           
            if (iIndex == 16)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Guardian Aug")
            }
           
            if (iIndex == 17)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
            }
           
            if (iIndex == 18)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK47")
            }      
           
            if (iIndex == 19)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AK47 Bloodmoon")
            }
 
            if (iIndex == 20)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Dual Sword")
            }
            if (iIndex == 21)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Jetpack")
                break;
            }
        }
       
        // Must check if iIndex < 14 means max is AK47
        if (iIndex < 14)
        {
            ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
            iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, szWeaponNames[get_weaponid(szWeaponName)])
        }
    }
   
    if (iIndex < 7)
    {
        ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
   
    if (ze_get_user_level(id) == 5)
    {
        ArrayGetString(g_szPrimaryWeapons, 7, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 6)
    {
        ArrayGetString(g_szPrimaryWeapons, 8, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 7)
    {
        ArrayGetString(g_szPrimaryWeapons, 9, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 8)
    {
        ArrayGetString(g_szPrimaryWeapons, 10, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 9)
    {
        ArrayGetString(g_szPrimaryWeapons, 11, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 10)
    {
        ArrayGetString(g_szPrimaryWeapons, 12, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 11)
    {
        ArrayGetString(g_szPrimaryWeapons, 13, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) >= 12 && ze_get_user_level(id) < 15) // Scar Beast
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 15 Unlock\w: \yScar Beast^n")
    }
    else if (ze_get_user_level(id) >= 15 && ze_get_user_level(id) < 17) // Laser MiniGun
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 17 Unlock\w: \yLaser MiniGun^n")
    }
    else if (ze_get_user_level(id) >= 17 && ze_get_user_level(id) < 20) // Guardian Aug
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 20 Unlock\w: \yGuardian Aug^n")
    }
    else if (ze_get_user_level(id) >= 20 && ze_get_user_level(id) < 25) // Golden M4A1
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 25 Unlock\w: \yGolden M4A1^n")
    }
    else if (ze_get_user_level(id) >= 25 && ze_get_user_level(id) < 26) // Golden AK47
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 26 Unlock\w: \yGolden AK47^n")
    }
    else if (ze_get_user_level(id) >= 26 && ze_get_user_level(id) < 30) // AK47 Bloodmoon
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 30 Unlock\w: \yAK47 Bloodmoon^n")
    }
    else if (ze_get_user_level(id) >= 30 && ze_get_user_level(id) < 35) // Dual Sword
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 35 Unlock\w: \yDual Sword^n")
    }
    else if (ze_get_user_level(id) >= 35 && ze_get_user_level(id) < 40) // Jetpack
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 26 Unlock\w: \yJetpack^n")
    }
   
    // 8. Auto Select
    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")
   
    // 9. Next/Back - 0. Exit
    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")
   
    // Fix for AMXX custom menus
    set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    show_menu(id, KEYSMENU, szMenu, iMenuTime, "Primary Weapons")
}
 
public Show_Menu_Buy_Secondary(id)
{
    new iMenuTime = floatround(g_fBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
   
    if (iMenuTime <= 0)
    {
        ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
        return
    }
   
    static szMenu[250], szWeaponName[32]
    new iLen, iIndex, iMaxLoops = ArraySize(g_szSecondaryWeapons)
   
    // Title
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L^n", id, "MENU_SECONDARY_TITLE")
   
    // 1-6. Weapon List
    for (iIndex = 0; iIndex < iMaxLoops; iIndex++)
    {
        if (ze_get_user_level(id) == 0 && iIndex >= 2 ||
        ze_get_user_level(id) == 1 && iIndex >= 3 ||
        ze_get_user_level(id) == 2 && iIndex >= 4 ||
        ze_get_user_level(id) == 3 && iIndex >= 5 ||
        ze_get_user_level(id) == 4 && iIndex >= 6)
        {
            break
        }
       
        ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\w%d.\y %s", iIndex+1, szWeaponNames[get_weaponid(szWeaponName)])
    }
   
    if (iIndex < ArraySize(g_szSecondaryWeapons))
    {
        ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r Next Level Unlock\w: \y%s", szWeaponNames[get_weaponid(szWeaponName)])
    }
   
    // 8. Auto Select
    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")
   
    // 0. Exit
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\y %L", id, "EXIT")
   
    // Fix for AMXX custom menus
    set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    show_menu(id, KEYSMENU, szMenu, iMenuTime, "Secondary Weapons")
}
 
public Menu_Buy_Primary(id, key)
{
    // Player dead or zombie or already bought primary
    if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtPrimary[id])
        return PLUGIN_HANDLED
   
    // Special keys / weapon list exceeded
    if (key >= MENU_KEY_AUTOSELECT || WPN_SELECTION >= WPN_MAXIDS[id])
    {
        switch (key)
        {
            case MENU_KEY_AUTOSELECT: // toggle auto select
            {
                WPN_AUTO_ON = 1 - WPN_AUTO_ON
            }
            case MENU_KEY_NEXT: // next/back
            {
                if (WPN_STARTID+7 < WPN_MAXIDS[id])
                    WPN_STARTID += 7
                else
                    WPN_STARTID = 0
            }
            case MENU_KEY_EXIT: // exit
            {
                return PLUGIN_HANDLED
            }
        }
       
        // Show buy menu again
        Show_Menu_Buy_Primary(id)
        return PLUGIN_HANDLED
    }
   
    // Store selected weapon id
    WPN_AUTO_PRI = WPN_SELECTION
   
    // Buy primary weapon
    Buy_Primary_Weapon(id, WPN_AUTO_PRI)
   
    // Show Secondary Weapons
    Show_Available_Buy_Menus(id)
   
    return PLUGIN_HANDLED
}
 
public Buy_Primary_Weapon(id, selection)
{
    if (selection == 14) // Scar Beast
    {
        give_tho4mpson(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
    else if (selection == 15) // Laser MiniGun
    {
        get_item(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
    else if (selection == 16) // Guardian Aug
    {
        give_buffaug(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
    else if (selection == 17) // Golden M4A1
    {
        give_golden_m4a1(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
    else if (selection == 18) // Golden AK47
    {
        give_golden_ak47(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
     else if (selection == 19) // AK47 Bloodmoon
    {
        get_bak47p(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
    else if (selection == 20) // Dual Sword
    {
        give_daul_sword(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
    else if (selection == 21) // Jetpack
    {
        ze_give_jetpack(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
   
    static szWeaponName[32]
    ArrayGetString(g_szPrimaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
    new iWeaponId = get_weaponid(szWeaponName)
   
    // Strip and Give Full Weapon
    rg_give_item(id, szWeaponName, GT_REPLACE)
    rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
   
    // Primary bought
    g_bBoughtPrimary[id] = true
    return true;
}
 
public Menu_Buy_Secondary(id, key)
{
    // Player dead or zombie or already bought secondary
    if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtSecondary[id])
        return PLUGIN_HANDLED
   
    // Special keys / weapon list exceeded
    if (key >= ArraySize(g_szSecondaryWeapons))
    {
        // Toggle autoselect
        if (key == MENU_KEY_AUTOSELECT)
            WPN_AUTO_ON = 1 - WPN_AUTO_ON
       
        // Reshow menu unless user exited
        if (key != MENU_KEY_EXIT)
            Show_Menu_Buy_Secondary(id)
       
        return PLUGIN_HANDLED
    }
   
    // Store selected weapon id
    WPN_AUTO_SEC = key
   
    // Buy secondary weapon
    Buy_Secondary_Weapon(id, key)
   
    return PLUGIN_HANDLED
}
 
public Buy_Secondary_Weapon(id, selection)
{
    if ( ((selection == 2) && (ze_get_user_level(id) < 1)) ||
    ((selection == 3) && (ze_get_user_level(id) < 2)) ||
    ((selection == 4) && (ze_get_user_level(id) < 3)) ||
    ((selection == 5) && (ze_get_user_level(id) < 4)) )
    {
        Show_Menu_Buy_Secondary(id)
        return;
    }
 
    static szWeaponName[32]
    ArrayGetString(g_szSecondaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
    new iWeaponId = get_weaponid(szWeaponName)
   
    // Strip and Give Full Weapon
    rg_give_item(id, szWeaponName, GT_REPLACE)
    rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
   
    // Secondary bought
    g_bBoughtSecondary[id] = true
}
 
public Fw_TouchWeapon_Pre(iEnt, id)
{
    if (get_pcvar_num(g_pCvarBlockWeapLowLevel) == 0)
        return HAM_IGNORED;
   
    // Not alive or Not Valid Weapon?
    if(!is_user_alive(id) || !pev_valid(iEnt))
        return HAM_IGNORED;
   
    // Get Weapon Model
    new szWeapModel[32]
    pev(iEnt, pev_model, szWeapModel, charsmax(szWeapModel))
   
    // Remove "models/w_" and ".mdl"
    copyc(szWeapModel, charsmax(szWeapModel), szWeapModel[contain(szWeapModel, "_" ) + 1], '.')
   
    // Set for mp5 to be same as "weapon_mp5navy"
    if(szWeapModel[1] == 'p' && szWeapModel[2] == '5')
        szWeapModel = "mp5navy"
   
    // Add "weapon_" to all model names
    static szWeaponEnt[32]
    formatex(szWeaponEnt, charsmax(szWeaponEnt), "weapon_%s", szWeapModel)
 
    // Get it's index in Weapon Array
    new iIndex, i
   
    // I won't explain the blew code if you need to understand ask me in Escapers-Zone.XYZ
    for (i = 0; i < ArraySize(g_szPrimaryWeapons); i++)
    {
        new szPrimaryWeapon[32]
        ArrayGetString(g_szPrimaryWeapons, i, szPrimaryWeapon, charsmax(szPrimaryWeapon))
       
        if (equali(szWeaponEnt, szPrimaryWeapon))
            iIndex = i
    }
   
    if (ze_get_user_level(id) == 0 && iIndex > 1)
    {
        return HAM_SUPERCEDE;
    }
   
    for (i = 1; i <= 11; i++)
    {
        if ((ze_get_user_level(id) == i) && iIndex > i+1)
        {
            return HAM_SUPERCEDE;
        }
    }
   
    return HAM_IGNORED;
}
 
// Natives
public native_ze_show_weapon_menu(id)
{
    if (!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
        return false
    }
   
    Cmd_Buy(id)
    return true
}
 
public native_ze_is_auto_buy_enabled(id)
{
    if (!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
        return -1;
    }
   
    return WPN_AUTO_ON;
}
 
public native_ze_disable_auto_buy(id)
{
    if (!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
        return false
    }
   
    WPN_AUTO_ON = 0;
    return true
}
Image

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

#27

Post by Raheem » 5 years ago

Will try find time to add pistols pattaren.

So when you exceeded the page number 3 there is no problem, right? This i got when i read the code as this code will not need define new page as it will does i think.
He who fails to plan is planning to fail

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 598
Joined: 7 years ago
Contact:

#28

Post by czirimbolo » 5 years ago

Yes there is no problem, you can see the screens, there is 3rd page and 4th page. Now I need to add 2 pistols and thats all. Waiting for you help ;)
Attachments
2.PNG
2.PNG (135.42 KiB) Viewed 6883 times
2.PNG
2.PNG (135.42 KiB) Viewed 6883 times
1.PNG
1.PNG (192.18 KiB) Viewed 6883 times
1.PNG
1.PNG (192.18 KiB) Viewed 6883 times
Image

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 598
Joined: 7 years ago
Contact:

#29

Post by czirimbolo » 5 years ago

any progress ?
Image

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 1 guest