Problema meniu arme

Modificari necesare ale pluginurilor

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

Post Reply
User avatar
kidd0x
Utilizator neserios (tepar)
Utilizator neserios (tepar)
Posts: 1054
Joined: 06 Oct 2018, 14:41
Detinator Steam: Da
SteamID: /id/kidd0x/
Reputatie: Utilizator neserios (tepar!)
Fond eXtream: 0
Location: Constangeles
Discord: kidd0x
Has thanked: 172 times
Been thanked: 81 times

25 Jan 2021, 20:01

Salut extream ,am acest plg de arme pentru ze

Code: Select all

#include <zombie_escape>
#include <ze_levels>
#include <stripweapons>

native give_golden_mp5(id);
native give_golden_m4a1(id);
native give_golden_ak47(id);
native GetAwpz(id);
native give_weapon_sfgun(id);
native give_paladin(id);
native give_unicorn(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..19: WPN_MAXIDS[id] = 15 // Golden m3
		case 20..24: WPN_MAXIDS[id] = 16 // Golden MP5
		case 25..29: WPN_MAXIDS[id] = 17 // Golden M4A1
		case 30..34: WPN_MAXIDS[id] = 18     // Golden AK47 & minigun & awpz
	}
	
	if (ze_get_user_level(id) > 30)
	{
		WPN_MAXIDS[id] = 21  // cand adaugi o arma modifici aici si adaugi +1 
	}

	// 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.
		*/

		// Golden MP5
		if (ze_get_user_level(id) >= 20 && ze_get_user_level(id) < 25)
		{
			if (iIndex == 13)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
				break;
			}
		}
		
		// Golden M4A1
		if (ze_get_user_level(id) >= 25 && 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, "Golden MP5")
			}
			
			if (iIndex == 15)
			{
				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) >= 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, "Golden MP5")
			}
			
			if (iIndex == 15)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
			}
			
			if (iIndex == 16)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK-47")
				break;
			}
		}
		
		// sf gun lvl 35
		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, "Golden MP5")
			}
			
			if (iIndex == 15)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
			}
			
			if (iIndex == 16)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK-47")
			}
			
			if (iIndex == 17)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "SF Gun")
				break;
			}
		}
		
		// etheral lvl 40
		if (ze_get_user_level(id) >= 40 && ze_get_user_level(id) < 45)
		{
			
			if (iIndex == 14)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
			}
			
			if (iIndex == 15)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
			}
			
			if (iIndex == 16)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK-47")
			}
			
			if (iIndex == 17)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "SF Gun")
			}
			if (iIndex == 18)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AK47 Paladin")
				break;
			}
		}
		// awp z 45
		if (ze_get_user_level(id) >= 45 && ze_get_user_level(id) < 50)
		{
			
			if (iIndex == 14)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
			}
			
			if (iIndex == 15)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
			}
			
			if (iIndex == 16)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK-47")
			}
			
			if (iIndex == 17)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "SF Gun")
			}
			if (iIndex == 18)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AK47 Paladin")
			}
			if (iIndex == 19)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AWP-Z")
				break;
			}
		}
		// unicorn 50 lvl
		if (ze_get_user_level(id) >= 50)
		{
			
			if (iIndex == 14)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
			}
			
			if (iIndex == 15)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
			}
			
			if (iIndex == 16)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK-47")
			}
			
			if (iIndex == 17)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "SF Gun")
			}
			if (iIndex == 18)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AK47 Paladin")
			}
			if (iIndex == 19)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AWP-Z")
			}
			if (iIndex == 20)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "UT3 Link Gun")
				break;
	
			}
		}
		
		// Must check if iIndex < 15 laser minigun
		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) < 20) // Golden MP5
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 20 Unlock\w: \yGolden MP5^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) < 30) // Golden Ak-47
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 30 Unlock\w: \yGolden AK-47^n")
	}
	else if (ze_get_user_level(id) >= 30 && ze_get_user_level(id) < 35) // SF GUN
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 35 Unlock\w: \ySF Gun^n")
	}
	else if (ze_get_user_level(id) >= 35 && ze_get_user_level(id) < 40) // Ethereal
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 40 Unlock\w: \yAk47 Paladin^n")
	}
	else if (ze_get_user_level(id) >= 40 && ze_get_user_level(id) < 45) // AWP Z
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 45 Unlock\w: \yAWP-Z^n")
	}
	else if (ze_get_user_level(id) >= 45 && ze_get_user_level(id) < 50) // UT3 Link Gun
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 45 Unlock\w: \yUT3 Link Gun^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) // Golden MP5
	{
		StripWeapons(id, Primary)
		give_item(id, "weapon_knife")
		give_golden_mp5(id)
		g_bBoughtPrimary[id] = true
		return true;
	}
	else if (selection == 15) // Golden M4A1
	{
		StripWeapons(id, Primary)
		give_item(id, "weapon_knife")
		give_golden_m4a1(id)
		g_bBoughtPrimary[id] = true
		return true;
	}
	else if (selection == 16) // Golden AK47
	{
		StripWeapons(id, Primary)
		give_item(id, "weapon_knife")
		give_golden_ak47(id)
		g_bBoughtPrimary[id] = true
		return true;
	}
	else if (selection == 17) // SF GUN
	{
		StripWeapons(id, Primary)
		give_item(id, "weapon_knife")
		give_weapon_sfgun(id)
		g_bBoughtPrimary[id] = true
		return true;
	}
	else if (selection == 18) // paladin
	{
		StripWeapons(id, Primary)
		give_item(id, "weapon_knife")
		give_paladin(id)
		g_bBoughtPrimary[id] = true
		return true;
	}
	else if (selection == 19) // AWP Z
	{
		StripWeapons(id, Primary)
		give_item(id, "weapon_knife")
		GetAwpz(id);
		g_bBoughtPrimary[id] = true
		return true;
	}
	else if (selection == 20) // Unicorn
	{
		StripWeapons(id, Primary)
		give_item(id, "weapon_knife")
		give_unicorn(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
}
Problema e urmatoarea : Poti lua arme chiar daca nu ai nivelul respectiv :
In aceasta poza : https://prnt.sc/xm83ga apar 4 arme , cea de level 40 ar fi a 5-a , dar problema e ca eu o pot lua , si arma de lvl 40 si cele de dupa 40 fara sa am nevoie de levelul necesar, dar ideea e ca liniile din meniu sunt invizibile sau ceva de genu ,adica -si revin iar la poza-, am 4 arme , dar daca apas 5,6,7 imi da armele de la nivelele urmatoare !

Daca stie cineva de unde ar fi problema sa imi zica si mie ca ma chinui de ore cu bugul asta . Stiu sigur ca dupa ce adaug o arma trb sa modific partea asta de cod

Code: Select all

	if (ze_get_user_level(id) > 30)
	{
		WPN_MAXIDS[id] = 21  // cand adaugi o arma modifici aici si adaugi +1 
	}
dar in rest nu stiu unde ar mai trebui sa mai modific

inc 1

Code: Select all

#include <amxmodx>
#include <cstrike>
#include <fun>
#include <reapi>
#include <fakemeta>
#include <hamsandwich>
#include <xs>
#include <nvault>
#include <engine>
#include <sqlx>
#include <amxmisc>
#include <amx_settings_api>
#include <cs_weap_models_api>
#include <zombie_escape_stocks>

#define ZE_VERSION "Zombie Escape 1.6"
#define AUTHORS "ZE Dev Team"

/*
*	For more information about these natives and forwards, just vist our forum:
*						Escapers-Zone.net
*/

// Team constants, use them in ze_roundend() forward 
enum
{
	ZE_TEAM_ZOMBIE = 1,
	ZE_TEAM_HUMAN
}

// Items returns used in ze_select_item_pre()
#define ZE_WRONG_ITEM -1
#define ZE_ITEM_AVAILABLE 0
#define ZE_ITEM_UNAVAILABLE 1
#define ZE_ITEM_DONT_SHOW 2

// General forwards return values
#define ZE_CONTINUE 0
#define ZE_STOP 1

// Max Extra-Items
#define MAX_EXTRA_ITEMS 60

// Forwards

/*
* Description:		Called on round end event.
*
* @param WinTeam	The win team ZE_TEAM_ZOMBIE or ZE_TEAM_HUMAN.
*
* @return			Returns here useless, it will not affect the real end round event.
*
*/
forward ze_roundend(WinTeam);

/*
* Description:	Called when user humanized, it called whenever 
*				ze_set_user_human(id) native used.
*				It's called also at every new round when all players humanized.
*
* @param id		Client index.
*
* @return		Returns here useless, it will not affect the real humanization event.
*
*/
forward ze_user_humanized(id);

/*
* Description:		Called before user get infected by player.
*
* @param iVictim	Victim index, human who will catch the infection.
* @param iInfector	Infector index, zombie who will cause the infection.
* @param iDamage	The blocked damage value.
*
* @return			To stop the infection event use:   return ZE_STOP
*					To let the infection continue use: return ZE_CONTINUE
*
* @note				This forward will not called on the zombie choose by the server,
*					only called if player try to infect player.
*					You can use pre to block the infection or to let it in specific conditions.
*					Basically return > ZE_CONTINUE  will stop the infection.
*			
*/
forward ze_user_infected_pre(iVictim, iInfector, iDamage);

/*
* Description:		Called when user infected by player or by the server.
*					Called also at the first choose of zombies (in this case server is the infector).
*
* @param iVictim	Victim index, human who catch the infection.
* @param iInfector	Infector index, zombie or server who caused the infection.
*
* @return			Returns here useless, it will not affect the real infection event.
*
* @note				If the infector is the server, The iInfector will be 0
*					else the iInfector will be the zombie id.		
*
*/
forward ze_user_infected(iVictim, iInfector);

/*
* Description:	Called when zombies chosen.
*
* @return		Returns here useless, it will not affect the real appearing event.
*
*/
forward ze_zombie_appear();

/*
* Description:	Called when the chosen zombies released.
*
* @return		Returns here useless, it will not affect the real releasing event.
*
*/
forward ze_zombie_release();

/*
* Description:	Called every new round if game started.
*
* @return		To block zombie escape round return ZE_STOP, To continue zombie escape mod return ZE_CONTINUE.
*
* @note			This called every new round only if the game started
*				which mean players is higher than required player so game already started.
*				this native somehow similar to new round event but only called when game started.
*				You can use it to block zombie escape mod round, and use your own round like Nemesis round
*				make sure to use this after first round, never return ZE_STOP in first round.
*
*/
forward ze_game_started_pre();

/*
* Description:	Called every new round if game started.
*
* @return		Returns here useless, it will not affect the real new round event.
*
* @note			This called every new round only if the game started
*				which mean players is higher than required player so game already started.
*				this native somehow similar to new round event but only called when game started.
*
*/
forward ze_game_started();

/*
* Description:	Called before zombie (or human) get fired by fire nade.
*
* @return		Return ZE_STOP to stop the fire action, zombie will not get fired.
*				Return ZE_CONTINUE to continue the fire, zombie will be fired.
*
* @note			You can use this to stop the fire action at specific conditions.
*
*/
forward ze_fire_pre(id);

/*
* Description:	Called before zombie (or human) get frozen by frost nade.
*
* @return		Return ZE_STOP to stop the freeze action, zombie will not get frozen.
*				Return ZE_CONTINUE to continue the freeze, zombie will be frozen.
*
* @note			You can use this to stop the freeze action at specific conditions.
*
*/
forward ze_frost_pre(id);

/*
* Description:	Called when zombie get unfrozen.
*
* @return		Returns here useless, it will not affect the real unfreeze event.
*
*/
forward ze_frost_unfreeze(id);

/*
* Description:			Called when player opens the extra-items menu.
*						Or when he choose the item but before he get it.
*
* @param id				Client index.
* @param iItemid		Index of item he try to buy.
* @param bIgnoreCost	true will ignore the cost, false will not ignore cost.
*
* @return				ZE_ITEM_AVAILABLE   | Shows item in the menu, player can also buy it.
*						ZE_ITEM_UNAVAILABLE | Show to player but he can't but it.
*						ZE_ITEM_DONT_SHOW   | Item not appear to that player.
*
*/
forward ze_select_item_pre(id, iItemid, bIgnoreCost);

/*
* Description:			Called after player choose the item,
*						called only if ze_select_item_pre() returned ZE_ITEM_AVAILABLE.
*
* @param id				Client index.
* @param iItemid		Index of item he try to buy.
* @param bIgnoreCost	true will ignore the cost, false will not ignore cost.
*
* @return				Returns here useless, it will not affect the real buy event.
*
*/
forward ze_select_item_post(id, iItemid, bIgnoreCost);

/*
* Description:			Called when player disconnect.
*
* @param id				Client index.
*
* @return				return ZE_CONTINUE | Will continue Mod game rules.
*						return ZE_STOP | Will block Mod game rules, you can use yours.
*
* @note					Useful in plugins like, replacing disconnected zombie/human if he was last zombie/human.
*
*/
forward ze_player_disconnect(id);

// Natives

/*
* Description:	Check if user zombie or not.
*
* @param id		Client index.
*
* @return		true  | If user Zombie.
*				false | If user Human.
*				-1    | If player not connected.
*
*/
native ze_is_user_zombie(id);

/*
* Description:	Check if game started or not.
*				Game start when minimun required players connected.
*
* @return		true  | If game started.
*				false | If game not started yet.
*
*/
native ze_is_game_started();

/*
* Description:	Check if this zombie in pre-release time or not.
*				Pre-Release time is said to be freeze time for zombies.
*
* @param id		Client index.
*
* @return		true  | If this zombie in freeze time.
*				false | If this zombie not in freeze time.
*				-1    | If player not connected or this player is Human.
*
*/
native ze_is_zombie_frozen(id);

/*
* Description:	Return current round number (Integer).
*				First round is round 1, second is 2 ... etc.
*
* @return		Round number | If game started
*				-1           | If game not started yet
*
*/
native ze_get_round_number();

/*
* Description:	Return alive humans number (Integer).
*
* @return		Alive humans number.
*
*/
native ze_get_humans_number();

/*
* Description:	Return alive zombies number (Integer).
*
* @return		Alive zombies number.
*
*/
native ze_get_zombies_number();

/*
* Description:	Set user to zombie team.
*
* @param id		Client index.
*
* @return		true  | If set successfully
*				false | If this player not connected
*
* @note			This will throw error in case of invalid player.
*
*/
native ze_set_user_zombie(id);

/*
* Description:	Set user to human team.
*
* @param id		Client index.
*
* @return		true  | If set successfully
*				false | If this player not connected
*
* @note			This will throw error in case of invalid player.
*
*/
native ze_set_user_human(id);

/*
* Description:		Increase human speed with this factor.
*					This factor added to his current speed depend on which weapon he carries.
*
* @param id			Client index.
* @param iFactor	The factor to be added to current speed.
*
* @return			true  | If set successfully
*					false | If this player not connected
*
* @note				This native will add speed to current speed.
*					For example, ze_set_human_speed_factor(id, 0) will not set player speed to zero
*					it won't increase his speed so he will have normal weapon speed.
*					Example, if player carry knife and ze_set_human_speed_factor(id, 20) his speed will be 
*					increased by 20 so his total speed will be 270 (default knife speed: 250)
*					You may use negative factors to decrease this speed.
*					Using this native will set the players speed for the whole map.
*					Speeds reset if this player disconnect, or reset using reset native.
*					This is limited by sv_maxspeed cvar.
*					This will throw error in case of invalid player.
*
*/
native ze_set_human_speed_factor(id, iFactor);

/*
* Description:	Reset human speed to default value used in ze_human_speed_factor cvar.
*
* @param id		Client index.
*
* @return		true  | If reset successfully
*				false | If this player not connected
*
* @note			This will remove the custom speed factor set by
*				ze_set_human_speed_factor(id, iFactor) native.
*				And will use the default factor in ze_human_speed_factor cvar.
*				This will throw error in case of invalid player.
*
*/
native ze_reset_human_speed(id);

/*
* Description:		Set this zombie speed to custom value.
*
* @param id			Client index.
* @param iSpeed		Speed to set this zombie to.
*
* @return			true  | If set successfully
*					false | If this player not connected
*
* @note				This native will set custom speed for this zombie
*					and will not use value defined in ze_zombie_speed cvar
*					This is limited by sv_maxspeed cvar.
*					This will throw error in case of invalid player.
*
*/
native ze_set_zombie_speed(id, iSpeed);

/*
* Description:	Reset zombie speed to default value used in ze_zombie_speed cvar.
*
* @param id		Client index.
*
* @return		true  | If reset successfully
*				false | If this player not connected
*
* @note			This will throw error in case of invalid player.
*
*/
native ze_reset_zombie_speed(id);

/*
* Description:	Get user knockback.
*
* @param id		Client index.
*
* @return		Knockback value | if client valid
*				-1				| If player not connected
*
* @note			This will throw error in case of invalid player.
*				This function return integer value.
*
*/
native ze_get_user_knockback(id);

/*
* Description:			Set user knockback.
*
* @param id				Client index.
* @param flKnockback	Knockback value as float.	
*
* @return				true	| If set successfully
*						false	| If this player not connected
*
*/
native ze_set_user_knockback(id, Float:flKnockback);

/*
* Description:	Reset user knockback to use value from CVAR.
*
* @param id		Client index.
*
* @return		true	| If reset successfully
*				false	| If this player not connected
*
*/
native ze_reset_user_knockback(id);

/*
* Description:			Set user gravity.
*
* @param id				Client index.
* @param iGravity		Gravity value.	
*
* @return				true	| If set successfully
*						false	| If this player not connected
*
*/
native ze_set_user_gravity(id, iGravity);

/*
* Description:	Reset user gravity to use value from CVAR.
*
* @param id		Client index.
*
* @return		true	| If reset successfully
*				false	| If this player not connected
*
*/
native ze_reset_user_gravity(id);

/*
* Description:	Remove zombie freeze time message.
*
* @return		true	| If removed successfully
*				false	| If message still not appeared (message not there)
*
*/
native ze_remove_zombie_freeze_msg();

/*
* Description:	Get player escape coins.
*
* @param id		Client index.
*
* @return		Player coins  | If this player in server
*				false		  | If this player not connected
*
* @note			This will throw error in case of invalid player.
*
*/
native ze_get_escape_coins(id);

/*
* Description:		Set player escape coins.
*
* @param id			Client index.
* @param iAmount	Client index.
*
* @return			true  | If set successfully
*					false | If this player not connected
*
* @note				This will throw error in case of invalid player.
*
*/
native ze_set_escape_coins(id, iAmount);

/*
* Description:		Get escape leader index.
*
* @return			Escape leader id
*
* @note				Make sure to use it when game already started.
*					If rank mode which is used the native will return rank 1 player.
*
*/
native ze_get_escape_leader_id();

/*
* Description:		Stop/Resume setting rendering from ze_effects_messages.sma plugin.
*
* @param id			Client index.
* @param bSet		True or false, True will stop the rendering that comes from ze_effects_messages.sma
*					false will continue setting rendering from ze_effects_messages.sma
*
* @return			true  | If set successfully
*					false | If this player not connected
*						
* @note				This native will not throw error if player not connected. It will just return false.
*					You before you set rendering for any player in any plugin you should first make: ze_stop_mod_rendering(id, true)
*					This will ensure that no rendering is setting from ze_effects_messages.sma plugin.
*					When you remove rendering, you should use: ze_stop_mod_rendering(id, false)
*
*/
native ze_stop_mod_rendering(id, bool:bSet);

/*
* Description:	Used to set/stop fire on zombie.
*
* @param id		Client index.
* @param bSet	Boolean value, true will set fire on zombie.
*				false will stop fire on zombie.
*
* @return		true  | If successfully set/stop fire on zombie.
*				false | If returned 1 in ze_fire_pre() forward.
*						Mean if fire action stopped by the pre forward.
*				-1	  | If this zombie not alive.
*
* @note			If zombie fired right now, you can use this to stop the fire
*				imediatly by using: ze_set_fire_grenade(id, false)
*				Same you can fire him at anytime.
*				Always check if user alive or not when using this native.
*				This will throw error in case of invalid player.
*				You can also set fire on alive humans.
*
*/
native ze_set_fire_grenade(id, bSet);

/*
* Description:	Tells you if this zombie burning now or not.
*
* @param id		Client index.
*
* @return		true  | If this zombie burning now.
*				false | If this zombie not burning.
*				-1	  | If this zombie not alive.
*
*/
native ze_zombie_in_fire(id);

/*
* Description:	Used to set/stop freeze on zombie.
*
* @param id		Client index.
* @param bSet	Boolean value, true will freeze zombie. false will unfreeze zombie.
*
* @return		true  | If successfully freeze/unfreeze zombie.
*				false | If returned 1 in ze_frost_pre() forward.
*						Mean if freeze action stopped by the pre forward.
*						Or if player already frozen
*				-1	  | If this zombie not alive.
*
* @note			If zombie frozen right now, you can use this to unfreeze him
*				imediatly by using: ze_set_frost_grenade(id, false)
*				Same you can freeze him at anytime.
*				Always check if user alive or not when using this native.
*				This will throw error in case of invalid player.
*				You can also freeze alive humans.
*
*/
native ze_set_frost_grenade(id, bSet);

/*
* Description:	Tells you if this zombie frozen now or not.
*
* @param id		Client index.
*
* @return		true  | If this zombie frozen now.
*				false | If this zombie unfrozen.
*				-1	  | If this zombie not alive.
*
*/
native ze_zombie_in_forst(id);

/*
* Description:		Register extra-item in the items-menu.
*
* @param szItemName[]	Item name.
* @param iCost			Item cost.
* @param iLimit			Item limit.
*
* @return				Item id in the menu, if successfully registered.
*						ZE_WRONG_ITEM | If item name was empty or item already registered.
*
* @note					ZE_WRONG_ITEM is defined as -1
*						Limit must be >= 0, 0 means unlimited.
*						Use this native in plugin_init() forward.
*
*/
native ze_register_item(const szItemName[], iCost, iLimit);

/*
* Description:	Open items menu for specific player.
*
* @param id		Client index.
*
* @return		true  | If successfully opened to the player.
*				false | If this player not connected.
*
*/
native ze_show_items_menu(id);

/*
* Description:			Force player to buy specific extra-item.
*
* @param id				Client index.
* @param iItemid		Item id, returned by ze_register_item() or ze_get_item_id().
* @param bIgnoreCost	true will ignore the cost, false will not ignore cost.
*
* @return				true  | If successfully bought item.
*						false | If this player not connected or itemid is invalid.
*
*/
native ze_force_buy_item(id, iItemid, bIgnoreCost);

/*
* Description:			Get item id by it's name.
*
* @param szItemName[]	Item name that used in ze_register_item().
*
* @return				Item index    | If item name is valid.
*						ZE_WRONG_ITEM | If this item name invalid.
*
* @note					ZE_WRONG_ITEM is defined as -1
*						Item name used in ze_register_item() native,
*						is called the real item name. 
*						this native deal with real name not name in ze_extraitems.ini
*
*/
native ze_get_item_id(const szItemName[]);

/*
* Description:			Get item cost (Integer) by it's id.
*
* @param iItemid		The item id from ze_register_item() or ze_get_item_id().
*
* @return				Item cost     | If item id is valid.
*						ZE_WRONG_ITEM | If item id is invalid.
*
* @note					ZE_WRONG_ITEM is defined as -1
*
*/
native ze_get_item_cost(iItemid);

/*
* Description:		Add extra-text to the item name.
*
* @param szText[]	Text to be added.
*
* @return			No return.
*
* @note				This native is used in ze_select_item_pre() forward.
*					Maximum length of the text is 32
*
*/
native ze_add_text_to_item(const szText[]);

/*
* Description:		Return item limit.
*
* @param iItemid	Item id.
*
* @return			Limit 		  | If this itemid is valid.
*					ZE_WRONG_ITEM | If this itemid is invalid.
*
* @note				ZE_WRONG_ITEM is defined as -1
*
*/
native ze_get_item_limit(iItemid);

/*
* Description:		Return item global limit.
*
* @param iItemid	Item id.
*
* @return			Global Limit  | If this itemid is valid.
*					ZE_WRONG_ITEM | If this itemid is invalid.
*
* @note				ZE_WRONG_ITEM is defined as -1
*
*/
native ze_get_item_global_limit(iItemid);

/*
* Description:		Check if this item id is valid or not.
*
* @param iItemid	Item id to check.
*
* @return			true  | If this itemid is valid.
*					false | If this itemid is invalid.
*
*/
native ze_is_valid_itemid(iItemid);

/*
* Description:		Return the item name by it's id.
*
* @param iItemid	Item id to check.
* @param szName[]	String to copy the string name to.
* @param iLen		The string szName[] max length.
*
* @return			true 		  | If item name copied successfully to szName[] string.
*					ZE_WRONG_ITEM | If this itemid is invalid.
*
*/
native ze_get_item_name(iItemid, const szName[], iLen);

/*
* 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);

/*
* Description:		Get item level.
*
* @param iItemid	Item id.
*
* @return			Item level 	  | If this itemid is valid.
*					ZE_WRONG_ITEM | If this itemid is invalid.
*					
* @note				To use this native level plugin must be installed.
*
*/
native ze_get_item_level(iItemid);

/*
* Description:		Set this item for VIPs on specific flag.
*
* @param iItemid	Item id.
* @param szFlag		Flag to set item to: a, b, c ... etc.
*
* @return			true 		  | If set successfully for VIPs.
*					ZE_WRONG_ITEM | If this itemid is invalid.
*
* @note				Use this under ze_register_item() native in plugin_init() forward.
*					To use this native VIP plugin must be installed.
*					Make sure to use only one flag.
*
*/
native ze_set_item_vip(iItemid, szFlag[]);

/*
* Description:		See if this item for VIP or not, and on which flag.
*
* @param iItemid	Item id.
*
* @return			Flag this item set to (return integer).
*					ZE_WRONG_ITEM | If this itemid is invalid.
*					
* @note				To use this native VIP plugin must be installed.
*					This native works like ze_get_vip_flags() native.
*
*/
native ze_get_item_vip(iItemid);

/*
* Description:	Check if this zombie in madness or not.
*
* @param id		Client index.
*
* @return		true  | This zombie in madness.
*				false | If this zombie not in madness.
*				-1    | If this player not connected or he is human.
*
*/
native ze_zombie_in_madness(id);

/*
* Description:	Show weapon menu for player.
*
* @param id		Client index.
*
* @return		true  | If menu opened successfully.
*				false | If this player not connected.
*
*/
native ze_show_weapon_menu(id);

/*
* Description:	Check if auto buy enabled or not.
*
* @param id		Client index.
*
* @return		true  | If auto buy enabled.
*				false | If auto buy disabled.
*				-1 	  | If this player not connected.
*
*/
native ze_is_auto_buy_enabled(id);

/*
* Description:	This will disable auto buy for player.
*
* @param id		Client index.
*
* @return		true  | If disabled successfully.
*				false | If this player not connected.
*
*/
native ze_disable_auto_buy(id);

/*
* Description:	Enable and disable Ready&PreRelease sounds for any player.
*
* @param id		Client index.
* @param bSet	true will enable sounds, false will disable sounds.
*
* @return		true  | If successfully disabled/enabled.
*				false | If this player not connected.
*
*/
native ze_set_starting_sounds(id, bool:bSet);

/*
* Description:	Enable and disable ambiance sound for any player.
*
* @param id		Client index.
* @param bSet	true will enable sound, false will disable sound.
*
* @return		true  | If successfully disabled/enabled.
*				false | If this player not connected.
*
*/
native ze_set_ambiance_sounds(id, bool:bSet);

/*
* Description:	Check for any player if Ready&PreRelease sounds enabled or disabled.
*
* @param id		Client index.
*
* @return		true  | If sounds enabled.
*				false | If sounds disabled.
*				-1 	  | If this player not connected.
*
*/
native ze_is_starting_sounds_enabled(id);

/*
* Description:	Check for any player if ambiance sounds enabled or disabled.
*
* @param id		Client index.
*
* @return		true  | If sounds enabled.
*				false | If sounds disabled.
*				-1 	  | If this player not connected.
*
*/
native ze_is_ambiance_sounds_enabled(id);
inc2

Code: Select all

#define ZE_PREFIX "!y[!gZombie Escape!y] "

// Print Color Chat message, This stock Supports ML
stock ze_colored_print(const target, const message[], any:...)
{
	static buffer[512], msg_SayText = 0
	if( !msg_SayText ) msg_SayText = get_user_msgid("SayText") 
	
	// Send to everyone
	if (!target)
	{
		static player, maxplayers, argscount
		maxplayers = get_member_game(m_nMaxPlayers)
		argscount = numargs()
		
		for (player = 1; player <= maxplayers; player++)
		{
			// Not connected
			if (!is_user_connected(player))
				continue;
			
			// Remember changed arguments
			static arg_index, changed_args[20], changedcount // [20] = max LANG_PLAYER occurencies	
			changedcount = 0
			
			// Replace LANG_PLAYER with player id
			for (arg_index = 2; arg_index < argscount; arg_index++)
			{
				if (getarg(arg_index) == LANG_PLAYER && arg_index + 1 < argscount)
				{
					// Check if next param string is a registered language translation
					static lang_key[64], arg_subindex
					arg_subindex = 0
					while ((lang_key[arg_subindex] = getarg(arg_index + 1, arg_subindex++))) { /* keep looping */ }
					if (GetLangTransKey(lang_key) != TransKey_Bad)
					{
						setarg(arg_index, 0, player)
						changed_args[changedcount++] = arg_index
						arg_index++ // skip next argument since we know it's a translation key
					}
				}
			}
			
			// Format message for player (+add ZE prefix)
			vformat(buffer, charsmax(buffer), message, 3)
			format(buffer, charsmax(buffer), "%s%s", ZE_PREFIX, buffer)
			
			replace_all(buffer, charsmax(buffer), "!g", "^x04"); // Green Color  
			replace_all(buffer, charsmax(buffer), "!y", "^x01"); // Yellow Color  
			replace_all(buffer, charsmax(buffer), "!t", "^x03"); // Team Color 
			
			// Send it
			message_begin(MSG_ONE_UNRELIABLE, msg_SayText, _, player)
			write_byte(player)
			write_string(buffer)
			message_end()
			
			// Replace back player id's with LANG_PLAYER
			for (arg_index = 0; arg_index < changedcount; arg_index++)
				setarg(changed_args[arg_index], 0, LANG_PLAYER)
		}
	}
	// Send to specific target
	else
	{
		// Format message for player (+add ZE prefix)
		vformat(buffer, charsmax(buffer), message, 3)
		format(buffer, charsmax(buffer), "%s%s", ZE_PREFIX, buffer)
		
		replace_all(buffer, charsmax(buffer), "!g", "^x04"); // Green Color  
		replace_all(buffer, charsmax(buffer), "!y", "^x01"); // Yellow Color  
		replace_all(buffer, charsmax(buffer), "!t", "^x03"); // Team Color 
			
		// Send it
		message_begin(MSG_ONE, msg_SayText, _, target)
		write_byte(target)
		write_string(buffer)
		message_end()
	}
}

// Return number of alive players from a team
stock GetAlivePlayersNum(CsTeams:iTeam)
{
	new iTAliveNum
	for(new i = 1; i <= get_member_game(m_nMaxPlayers) ; i++)
	{
		if (!is_user_connected(i))
			continue
		
		if(is_user_alive(i) && get_member(i, m_iTeam) == iTeam)
			iTAliveNum++
	}
	return iTAliveNum
}

// Return number of connected players from a team
stock GetTeamPlayersNum(CsTeams:iTeam)
{
	new iTAliveNum
	for(new i = 1; i <= get_member_game(m_nMaxPlayers) ; i++)
	{
		if (!is_user_connected(i))
			continue
		
		if(is_user_connected(i) && get_member(i, m_iTeam) == iTeam)
			iTAliveNum++
	}
	return iTAliveNum
}

// Return number of non-alive players from a team
stock GetDeadPlayersNum(CsTeams:iTeam)
{
	new iTAliveNum
	for(new i = 1; i <= get_member_game(m_nMaxPlayers) ; i++)
	{
		if (!is_user_connected(i))
			continue
		
		if(!is_user_alive(i) && get_member(i, m_iTeam) == iTeam)
			iTAliveNum++
	}
	return iTAliveNum
}

// Return number of all alive players
stock GetAllAlivePlayersNum()
{
	new iAliveAll
	for(new i = 1; i <= get_member_game(m_nMaxPlayers) ; i++)
	{
		if(is_user_alive(i))
			iAliveAll++
	}
	return iAliveAll
}

// Return number of all connected players
stock GetAllPlayersNum()
{
	new iAll
	for(new i = 1; i <= get_member_game(m_nMaxPlayers) ; i++)
	{
		if(is_user_connected(i))
			iAll++
	}
	return iAll
}

// Return Number of required zombies
stock RequiredZombies()
{
	switch(GetAllAlivePlayersNum())
	{
		case 2..5: return 1
		case 6..15: return 2
		case 16..25: return 3
		case 26..32: return 4
	}
	return 0
}

// Choose Random Target
stock GetRandomAlive(target_index)
{
	new iAlive, id
	
	for (id = 1; id <= get_member_game(m_nMaxPlayers); id++)
	{
		if (is_user_alive(id))
			iAlive++
		
		if (iAlive == target_index)
			return id
	}
	return -1
}

// Set Player Map Light Style
stock Set_MapLightStyle(iIndex, const szMapLightStyle[])
{
	message_begin(MSG_ONE, SVC_LIGHTSTYLE, {0, 0, 0}, iIndex)
	write_byte(0)
	write_string(szMapLightStyle)
	message_end()
}

// Set Player Nightvision
stock Set_NightVision(iIndex, iDuration, iHoldTime, iFlags, iRed, iGreen, iBlue, iAlpha)
{
	message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0, 0, 0}, iIndex)
	write_short(iDuration)
	write_short(iHoldTime)
	write_short(iFlags)
	write_byte(iRed)
	write_byte(iGreen)
	write_byte(iBlue)
	write_byte(iAlpha)
	message_end()
}

// Set Zombie Knockback
stock Set_Knockback(ent, Float:VicOrigin[3], Float:speed, type)
{
	static Float:fl_Velocity[3]
	static Float:EntOrigin[3]
	
	get_entvar(ent, var_origin, EntOrigin)
	static Float:distance_f
	distance_f = get_distance_f(EntOrigin, VicOrigin)
	
	new Float:fl_Time = distance_f / speed
	
	if (type == 1)
	{
		fl_Velocity[0] = ((VicOrigin[0] - EntOrigin[0]) / fl_Time) * 1.5
		fl_Velocity[1] = ((VicOrigin[1] - EntOrigin[1]) / fl_Time) * 1.5
		fl_Velocity[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time		
	}
	else if (type == 2)
	{
		fl_Velocity[0] = ((EntOrigin[0] - VicOrigin[0]) / fl_Time) * 1.5
		fl_Velocity[1] = ((EntOrigin[1] - VicOrigin[1]) / fl_Time) * 1.5
		fl_Velocity[2] = (EntOrigin[2] - VicOrigin[2]) / fl_Time
	}
	
	set_entvar(ent, var_velocity, fl_Velocity)
}

// Update Player Frags and Deaths
stock UpdateFrags(iAttacker, iVictim, iFrags, iDeaths, iScoreboard)
{
	// Set attacker frags
	set_entvar(iAttacker, var_frags, float(pev(iAttacker, pev_frags) + iFrags))
	
	// Set victim deaths
	set_member(iVictim, m_iDeaths, get_member(iVictim, m_iDeaths) + iDeaths)
	
	// Update scoreboard with attacker and victim info
	if (iScoreboard)
	{
		message_begin(MSG_BROADCAST, get_user_msgid("ScoreInfo"))
		write_byte(iAttacker) // id
		write_short(floatround(get_entvar(iAttacker, var_frags))) // frags
		write_short(get_member(iAttacker, m_iDeaths)) // deaths
		write_short(0) // class?
		write_short(get_member(iAttacker, m_iTeam)) // team
		message_end()
		
		message_begin(MSG_BROADCAST, get_user_msgid("ScoreInfo"))
		write_byte(iVictim) // id
		write_short(floatround(get_entvar(iVictim, var_frags))) // frags
		write_short(get_member(iVictim, m_iDeaths)) // deaths
		write_short(0) // class?
		write_short(get_member(iVictim, m_iTeam)) // team
		message_end()
	}
}

// Send Death Message
stock SendDeathMsg(iAttacker, iVictim)
{
	message_begin(MSG_ALL, get_user_msgid("DeathMsg"), {0, 0, 0}, 0)
	write_byte(iAttacker) // killer
	write_byte(iVictim) // victim
	write_byte(1) // headshot flag
	write_string("infection") // killer's weapon
	message_end()
}

// Show infected icon
stock InfectionIcon(id)
{
	message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("Damage"), _, id)
	write_byte(0) // damage save
	write_byte(0) // damage take
	write_long(DMG_NERVEGAS) // damage type - DMG_RADIATION
	write_coord(0) // x
	write_coord(0) // y
	write_coord(0) // z
	message_end()
}

// Fix Dead Attribute
stock FixDeadAttrib(iIndex)
{
	message_begin(MSG_ALL, get_user_msgid("ScoreAttrib"), {0, 0, 0}, 0)
	write_byte(iIndex) // id
	write_byte(0) // attrib (0 = Nothing || 1 = Dead)
	message_end()
}

// Set an entity's key value
stock Set_KeyValue(entity, const key[], const value[], const classname[])
{
	set_kvd(0, KV_ClassName, classname)
	set_kvd(0, KV_KeyName, key)
	set_kvd(0, KV_Value, value)
	set_kvd(0, KV_fHandled, 0)

	dllfunc(DLLFunc_KeyValue, entity, 0)
}

// Set Custom Sky
stock Precache_Sky(const szSkyName[])
{
	new bool:bFound
	static szTgaFile[35]
	static szSuffix[6][3] = {"up", "dn", "ft", "bk", "lf", "rt"}

	for(new i = 0; i < 6; ++i)
	{
		formatex(szTgaFile, 34, "gfx/env/%s%s.tga", szSkyName, szSuffix[i])
		
		if(file_exists(szTgaFile))
		{
			precache_generic(szTgaFile)
			bFound = true
		}
		else
		{
			log_amx("Cannot locate file '%s'", szTgaFile)
			bFound = false
			break
		}
	}
	
	if(bFound == true)
	{
		set_cvar_string("sv_skyname", szSkyName)
	}
}

// Add Commas
stock AddCommas(iNum , szOutput[] , iLen)  
{  
    new szTmp[15] , iOutputPos , iNumPos , iNumLen 
      
    if (iNum < 0)  
    {  
        szOutput[iOutputPos++] = '-' 
        iNum = abs(iNum)
    }  
      
    iNumLen = num_to_str(iNum , szTmp , charsmax(szTmp))

    if (iNumLen <= 3)  
    {  
        iOutputPos += copy(szOutput[iOutputPos] , iLen , szTmp)
    }  
    else  
    {  
        while ((iNumPos < iNumLen) && (iOutputPos < iLen))   
        {  
            szOutput[iOutputPos++] = szTmp[iNumPos++]
          
            if((iNumLen - iNumPos) && !((iNumLen - iNumPos) % 3))   
                szOutput[iOutputPos++] = ','
        }
        szOutput[iOutputPos] = EOS 
    }  
    return iOutputPos
}

// Play Sound
stock PlaySound(id, const sound[])
{
	if (equal(sound[strlen(sound)-4], ".mp3"))
	{
		client_cmd(id, "mp3 play ^"sound/%s^"", sound)
	}
	else
	{
		client_cmd(id, "spk ^"%s^"", sound)
	}
}

// Stop Sound
stock StopSound()
{
	for(new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
	{
		client_cmd(id, "mp3 stop")
		client_cmd(id, "spk stop")
		client_cmd(id, "stopsound")
	}
}

// Set Glow
stock Set_Rendering(iEntity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
{
	static Float:color[3]
	color[0] = float(r)
	color[1] = float(g)
	color[2] = float(b)
	
	set_entvar(iEntity, var_renderfx, fx)
	set_entvar(iEntity, var_rendercolor, color)
	set_entvar(iEntity, var_rendermode, render)
	set_entvar(iEntity, var_renderamt, float(amount))
}

// Multiply Vector by Scalar
stock VecMulScalar(const Float:vec[], Float:scalar, Float:out[])
{
	out[0] = vec[0] * scalar
	out[1] = vec[1] * scalar
	out[2] = vec[2] * scalar
}

// Show Given BP Ammo
stock Show_Given_BPAmmo(id, iAmmoType, iAmmount)
{
	if (iAmmount <= 0)
		return
	
	message_begin(MSG_ONE, get_user_msgid("AmmoPickup"), {0,0,0}, id)
	write_byte(iAmmoType)
	write_byte(iAmmount)
	message_end()
}

// Log MySQL Errors
stock SQL_IsFail(iFailState, iError, szError[], const szLogFile[])
{
	if (iFailState == TQUERY_CONNECT_FAILED)
	{
		log_to_file(szLogFile, "[MySQL] Could not connect to SQL database: %s", szError)
		return true
	}
	else if (iFailState == TQUERY_QUERY_FAILED)
	{
		log_to_file(szLogFile, "[MySQL] Query failed: %s", szError)
		return true
	}
	else if (iError)
	{
		log_to_file(szLogFile, "[MySQL] Error on query: %s", szError)
		return true
	}
	
	return false
}

// Check if player steamid in given array or not
stock IsPlayerInArray(Array:aSteamArray, id)
{
	new szAuthId[34], szSavedAuthId[34];
	
	get_user_authid(id, szAuthId, charsmax(szAuthId))
	
	for(new i = 0; i < ArraySize(aSteamArray); i++)
	{
		ArrayGetString(aSteamArray, i, szSavedAuthId, charsmax(szSavedAuthId))
		
		if (equal(szSavedAuthId, szAuthId))
		{
			return true
		}
	}
	
	return false
}
RoyalServer
User avatar
levin
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 3844
Joined: 24 Aug 2011, 12:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Discord: devilclass
Has thanked: 36 times
Been thanked: 594 times
Contact:

25 Jan 2021, 21:06

Code: Select all

#include <zombie_escape>
#include <ze_levels>
#include <stripweapons>

native give_golden_m3(id);
native give_golden_mp5(id);
native give_golden_m4a1(id);
native give_golden_ak47(id);

native GetAwpz(id);
native give_weapon_sfgun(id);
native give_paladin(id);
native give_unicorn(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..19: WPN_MAXIDS[id] = 15 // Golden m3
		case 20..24: WPN_MAXIDS[id] = 16 // Golden MP5
		case 25..29: WPN_MAXIDS[id] = 17 // Golden M4A1
		case 30..34: WPN_MAXIDS[id] = 18     // Golden AK47
		case 35..39: WPN_MAXIDS[id] = 19     // altă armă
		case 40..44: WPN_MAXIDS[id] = 20     // altă armă
		case 45..49: WPN_MAXIDS[id] = 21     // altă armă
		case 50: WPN_MAXIDS[id] = 22     // altă armă
	}
	
	if (ze_get_user_level(id) > 50)
	{
		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.
		*/

		// Golden M3
		if (ze_get_user_level(id) >= 15 && 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, "Golden M3")
				break;
			}
		}
		
		// Golden MP5
		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, "Golden M3")
			}
			
			if (iIndex == 15)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
				break;
			}
		}
		
		// Golden M4A1
		if (ze_get_user_level(id) >= 25 && 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, "Golden M3")
			}
			
			if (iIndex == 15)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
			}
			
			if (iIndex == 16)
			{
				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) >= 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, "Golden M3")
			}
			
			if (iIndex == 15)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
			}
			
			if (iIndex == 16)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
			}
			
			if (iIndex == 17)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK-47")
				break;
			}
		}
		
		// sf gun lvl 35
		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, "Golden M3")
			}
			
			if (iIndex == 15)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
			}
			
			if (iIndex == 16)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
			}
			
			if (iIndex == 17)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK-47")
			}
			
			if (iIndex == 18)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "SF Gun")
				break;
			}
		}
		
		// etheral lvl 40
		if (ze_get_user_level(id) >= 40 && ze_get_user_level(id) < 45)
		{
			if (iIndex == 14)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M3")
			}
			
			if (iIndex == 15)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
			}
			
			if (iIndex == 16)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
			}
			
			if (iIndex == 17)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK-47")
			}
			
			if (iIndex == 18)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "SF Gun")
			}

			if (iIndex == 19)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AK47 Paladin")
				break;
			}
		}

		// awp z 45
		if (ze_get_user_level(id) >= 45 && ze_get_user_level(id) < 50)
		{
			if (iIndex == 14)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M3")
			}
			
			if (iIndex == 15)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
			}
			
			if (iIndex == 16)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
			}
			
			if (iIndex == 17)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK-47")
			}
			
			if (iIndex == 18)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "SF Gun")
			}

			if (iIndex == 19)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AK47 Paladin")
			}

			if (iIndex == 20)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AWP-Z")
				break;
			}
		}

		// unicorn 50 lvl
		if (ze_get_user_level(id) >= 50)
		{
			if (iIndex == 14)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M3")
			}
			
			if (iIndex == 15)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
			}
			
			if (iIndex == 16)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
			}
			
			if (iIndex == 17)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK-47")
			}
			
			if (iIndex == 18)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "SF Gun")
			}

			if (iIndex == 19)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AK47 Paladin")
			}

			if (iIndex == 20)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AWP-Z")
			}

			if (iIndex == 21)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "UT3 Link Gun")
				break;
			}
		}
		
		// Must check if iIndex < 14 LAST WEAPON
		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) // Golden M3
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 15 Unlock\w: \yGolden M3^n")
	}
	else if (ze_get_user_level(id) >= 15 && ze_get_user_level(id) < 20) // Golden MP5
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 20 Unlock\w: \yGolden MP5^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) < 30) // Golden Ak-47
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 30 Unlock\w: \yGolden AK-47^n")
	}
	else if (ze_get_user_level(id) >= 30 && ze_get_user_level(id) < 35) // SF GUN
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 35 Unlock\w: \ySF Gun^n")
	}
	else if (ze_get_user_level(id) >= 35 && ze_get_user_level(id) < 40) // Ethereal
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 40 Unlock\w: \yAk47 Paladin^n")
	}
	else if (ze_get_user_level(id) >= 40 && ze_get_user_level(id) < 45) // AWP Z
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 45 Unlock\w: \yAWP-Z^n")
	}
	else if (ze_get_user_level(id) >= 45 && ze_get_user_level(id) < 50) // UT3 Link Gun
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 50 Unlock\w: \yUT3 Link Gun^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) // Golden M3
	{
		give_golden_m3(id)
		g_bBoughtPrimary[id] = true
		return true;
	}
	else if (selection == 15) // Golden MP5
	{
		give_golden_mp5(id)
		g_bBoughtPrimary[id] = true
		return true;
	}
	else if (selection == 16) // Golden M4A1
	{
		StripWeapons(id, Primary)
		give_item(id, "weapon_knife")
		give_golden_m4a1(id)
		g_bBoughtPrimary[id] = true
		return true;
	}
	else if (selection == 17) // Golden AK47
	{
		StripWeapons(id, Primary)
		give_item(id, "weapon_knife")
		give_golden_ak47(id)
		g_bBoughtPrimary[id] = true
		return true;
	}
	else if (selection == 18) // SF GUN
	{
		StripWeapons(id, Primary)
		give_item(id, "weapon_knife")
		give_weapon_sfgun(id)
		g_bBoughtPrimary[id] = true
		return true;
	}
	else if (selection == 19) // paladin
	{
		StripWeapons(id, Primary)
		give_item(id, "weapon_knife")
		give_paladin(id)
		g_bBoughtPrimary[id] = true
		return true;
	}
	else if (selection == 20) // AWP Z
	{
		StripWeapons(id, Primary)
		give_item(id, "weapon_knife")
		GetAwpz(id);
		g_bBoughtPrimary[id] = true
		return true;
	}
	else if (selection == 21) // Unicorn
	{
		StripWeapons(id, Primary)
		give_item(id, "weapon_knife")
		give_unicorn(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
}
Pentru ajutor, faceți cerere bine detaliată, completând și respectând modelul corespunzător.
Nu-mi mai dați cereri doar pentru a mă avea în lista de prieteni.
Dacă te ajut, și mă ignori/etc > te adaug în „foe”.
Aveți grijă la cei ce încearcă să mă copieze sau să dea drept mine..Puteți lua legătura cu mine prin STEAM dacă aveți o problemă/nelămurire în acest caz! Cont de forum am doar aici.
În cazul în care utilizați ceva din ce am postat(ex: aici), e bine să fiți la curent cu modificările aduse și de aici, iar dacă sunt ceva probleme nu ezitați să luați legătura cu mine. Actualizarea unor coduri nu se vor afișa public, doar dacă se găsește ceva critic/urgent de remediat, unele fiind coduri vechi iar unele refăcute chiar recent dar private.
* Nume pe cs1.6: eVoLuTiOn \ Nume vechi: eVo
* Atelierul meu - post2819572.html#p2819572 (închis, click link ca să vedeți de ce)
User avatar
kidd0x
Utilizator neserios (tepar)
Utilizator neserios (tepar)
Posts: 1054
Joined: 06 Oct 2018, 14:41
Detinator Steam: Da
SteamID: /id/kidd0x/
Reputatie: Utilizator neserios (tepar!)
Fond eXtream: 0
Location: Constangeles
Discord: kidd0x
Has thanked: 172 times
Been thanked: 81 times

25 Jan 2021, 23:19

L E V I N wrote:
25 Jan 2021, 21:06

Code: Select all

#include <zombie_escape>
#include <ze_levels>
#include <stripweapons>

native give_golden_m3(id);
native give_golden_mp5(id);
native give_golden_m4a1(id);
native give_golden_ak47(id);

native GetAwpz(id);
native give_weapon_sfgun(id);
native give_paladin(id);
native give_unicorn(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..19: WPN_MAXIDS[id] = 15 // Golden m3
		case 20..24: WPN_MAXIDS[id] = 16 // Golden MP5
		case 25..29: WPN_MAXIDS[id] = 17 // Golden M4A1
		case 30..34: WPN_MAXIDS[id] = 18     // Golden AK47
		case 35..39: WPN_MAXIDS[id] = 19     // altă armă
		case 40..44: WPN_MAXIDS[id] = 20     // altă armă
		case 45..49: WPN_MAXIDS[id] = 21     // altă armă
		case 50: WPN_MAXIDS[id] = 22     // altă armă
	}
	
	if (ze_get_user_level(id) > 50)
	{
		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.
		*/

		// Golden M3
		if (ze_get_user_level(id) >= 15 && 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, "Golden M3")
				break;
			}
		}
		
		// Golden MP5
		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, "Golden M3")
			}
			
			if (iIndex == 15)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
				break;
			}
		}
		
		// Golden M4A1
		if (ze_get_user_level(id) >= 25 && 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, "Golden M3")
			}
			
			if (iIndex == 15)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
			}
			
			if (iIndex == 16)
			{
				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) >= 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, "Golden M3")
			}
			
			if (iIndex == 15)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
			}
			
			if (iIndex == 16)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
			}
			
			if (iIndex == 17)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK-47")
				break;
			}
		}
		
		// sf gun lvl 35
		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, "Golden M3")
			}
			
			if (iIndex == 15)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
			}
			
			if (iIndex == 16)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
			}
			
			if (iIndex == 17)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK-47")
			}
			
			if (iIndex == 18)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "SF Gun")
				break;
			}
		}
		
		// etheral lvl 40
		if (ze_get_user_level(id) >= 40 && ze_get_user_level(id) < 45)
		{
			if (iIndex == 14)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M3")
			}
			
			if (iIndex == 15)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
			}
			
			if (iIndex == 16)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
			}
			
			if (iIndex == 17)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK-47")
			}
			
			if (iIndex == 18)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "SF Gun")
			}

			if (iIndex == 19)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AK47 Paladin")
				break;
			}
		}

		// awp z 45
		if (ze_get_user_level(id) >= 45 && ze_get_user_level(id) < 50)
		{
			if (iIndex == 14)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M3")
			}
			
			if (iIndex == 15)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
			}
			
			if (iIndex == 16)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
			}
			
			if (iIndex == 17)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK-47")
			}
			
			if (iIndex == 18)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "SF Gun")
			}

			if (iIndex == 19)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AK47 Paladin")
			}

			if (iIndex == 20)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AWP-Z")
				break;
			}
		}

		// unicorn 50 lvl
		if (ze_get_user_level(id) >= 50)
		{
			if (iIndex == 14)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M3")
			}
			
			if (iIndex == 15)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
			}
			
			if (iIndex == 16)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
			}
			
			if (iIndex == 17)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK-47")
			}
			
			if (iIndex == 18)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "SF Gun")
			}

			if (iIndex == 19)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AK47 Paladin")
			}

			if (iIndex == 20)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AWP-Z")
			}

			if (iIndex == 21)
			{
				iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "UT3 Link Gun")
				break;
			}
		}
		
		// Must check if iIndex < 14 LAST WEAPON
		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) // Golden M3
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 15 Unlock\w: \yGolden M3^n")
	}
	else if (ze_get_user_level(id) >= 15 && ze_get_user_level(id) < 20) // Golden MP5
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 20 Unlock\w: \yGolden MP5^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) < 30) // Golden Ak-47
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 30 Unlock\w: \yGolden AK-47^n")
	}
	else if (ze_get_user_level(id) >= 30 && ze_get_user_level(id) < 35) // SF GUN
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 35 Unlock\w: \ySF Gun^n")
	}
	else if (ze_get_user_level(id) >= 35 && ze_get_user_level(id) < 40) // Ethereal
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 40 Unlock\w: \yAk47 Paladin^n")
	}
	else if (ze_get_user_level(id) >= 40 && ze_get_user_level(id) < 45) // AWP Z
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 45 Unlock\w: \yAWP-Z^n")
	}
	else if (ze_get_user_level(id) >= 45 && ze_get_user_level(id) < 50) // UT3 Link Gun
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 50 Unlock\w: \yUT3 Link Gun^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) // Golden M3
	{
		give_golden_m3(id)
		g_bBoughtPrimary[id] = true
		return true;
	}
	else if (selection == 15) // Golden MP5
	{
		give_golden_mp5(id)
		g_bBoughtPrimary[id] = true
		return true;
	}
	else if (selection == 16) // Golden M4A1
	{
		StripWeapons(id, Primary)
		give_item(id, "weapon_knife")
		give_golden_m4a1(id)
		g_bBoughtPrimary[id] = true
		return true;
	}
	else if (selection == 17) // Golden AK47
	{
		StripWeapons(id, Primary)
		give_item(id, "weapon_knife")
		give_golden_ak47(id)
		g_bBoughtPrimary[id] = true
		return true;
	}
	else if (selection == 18) // SF GUN
	{
		StripWeapons(id, Primary)
		give_item(id, "weapon_knife")
		give_weapon_sfgun(id)
		g_bBoughtPrimary[id] = true
		return true;
	}
	else if (selection == 19) // paladin
	{
		StripWeapons(id, Primary)
		give_item(id, "weapon_knife")
		give_paladin(id)
		g_bBoughtPrimary[id] = true
		return true;
	}
	else if (selection == 20) // AWP Z
	{
		StripWeapons(id, Primary)
		give_item(id, "weapon_knife")
		GetAwpz(id);
		g_bBoughtPrimary[id] = true
		return true;
	}
	else if (selection == 21) // Unicorn
	{
		StripWeapons(id, Primary)
		give_item(id, "weapon_knife")
		give_unicorn(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
}
Multumesc LEVIN , rezolvat :flexed_biceps:
Post Reply

Return to “Modificari pluginuri”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 21 guests