Solved Add Frost M4a1 To Level Weapons System

Unpaid Requests, Public Plugins
Post Reply
User avatar
Luxurious
Mod Tester
Mod Tester
Egypt
Posts: 177
Joined: 6 years ago
Location: Egypt
Contact:

Add Frost M4a1 To Level Weapons System

#1

Post by Luxurious » 5 years ago

Frost Code

Code: Select all

set_hudmessage(255, 0, 0, -1.0, 0.01)
show_hudmessage(id, "<Hudmessage>")
#include <zombie_escape>
#include <engine>

new const V_M4A1_MODEL[] = "models/zombie_escape/v_frost_m4a1.mdl"
new const P_M4A1_MODEL[] = "models/zombie_escape/p_frost_m4a1.mdl"
new const W_M4A1_MODEL[] = "models/zombie_escape/w_frost_m4a1.mdl"
new const W_OLD_M4A1_MODEL[] = "models/w_m4a1.mdl"

new g_iItemID, g_iHudSync, g_iSpriteLaser, g_iFreezeDmg, g_iDmgMultiplier
new bool:g_bHasFrostM4A1[33]
new g_iDmg[33]

public plugin_init()
{
	register_plugin("[ZE] Extra Item: Frost M4A1", "1.0", "Raheem")
	
	// Cvars
	g_iFreezeDmg = register_cvar("ze_freezing_m4a1_damage", "2000") // Damage Requried So Zombie got Frozen
	g_iDmgMultiplier = register_cvar("ze_multiplier_m4a1_damage", "2") // Multiplie Weapon Damage

	// Message IDS
	g_iHudSync = CreateHudSyncObj()
	
	// ITEM NAME & COST
	g_iItemID = ze_register_item("Frost M4A1", 30, 0) // It's cost 30 Ammo Pack
	ze_set_item_vip(g_iItemID, "f")
	
	// Events
	register_event("WeapPickup", "CheckModel", "b", "1=19")
	register_event("CurWeapon", "CurrentWeapon", "be", "1=1")
	
	// Forwards
	register_forward(FM_SetModel, "Fw_SetModel")
	
	// HookChains
	RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
	
	// Hams
	RegisterHam(Ham_TraceAttack, "player", "Fw_TraceAttack_Post", 1)
	RegisterHam(Ham_TraceAttack, "worldspawn", "Fw_TraceAttack_Post", 1)
	RegisterHam(Ham_Item_AddToPlayer, "weapon_m4a1", "Fw_AddFrostM4A1ToPlayer")
}

public plugin_precache() 
{
	// Models
	precache_model(V_M4A1_MODEL)
	precache_model(P_M4A1_MODEL)
	precache_model(W_M4A1_MODEL)
	
	// Sprites
	g_iSpriteLaser = precache_model( "sprites/Newlightning.spr")
}

public client_disconnected(id)
{
	g_bHasFrostM4A1[id] = false
}

public ze_select_item_pre(id, itemid)
{
    // Return Available and we will block it in Post, So it dosen't affect other plugins
    if (itemid != g_iItemID)
        return ZE_ITEM_AVAILABLE
   
    // Available for Humans only, So don't show it for zombies
    if (ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW
   
    return ZE_ITEM_AVAILABLE
}

public ze_select_item_post(player, itemid)
{
    if (itemid != g_iItemID)
        return

    g_bHasFrostM4A1[player] = true

    rg_remove_item(player, "weapon_m4a1")
    rg_give_item(player, "weapon_m4a1", GT_APPEND)
    rg_set_user_bpammo(player, WeaponIdType:get_weaponid("weapon_m4a1"), 90)
	
    new szName[32]
    get_user_name(player, szName, charsmax(szName))
    
    set_hudmessage(random(255), random(255), random(255), -1.0, 0.17, 1, 0.0, 5.0, 1.0, 1.0, -1)
    show_hudmessage(0, "%s Has bought Frost M4A1!", szName)
    
    ze_colored_print(player, "!tYou Have bought Frost M4A1!y!")
}

public Fw_TraceAttack_Post(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
{
	if(!is_user_alive(iAttacker))
		return 
	
	if(get_user_weapon(iAttacker) != CSW_M4A1 || !g_bHasFrostM4A1[iAttacker])
		return
	
	set_hudmessage(34, 138, 255, -1.0, 0.17, 1, 0.0, 2.0, 1.0, 1.0, -1)
	ShowSyncHudMsg(iAttacker, g_iHudSync, "Freeze Damage^n%d/%d", g_iDmg[iAttacker], get_pcvar_num(g_iFreezeDmg))
	
	new vec1[3], vec2[3]
	get_user_origin(iAttacker, vec1, 1) 
	get_user_origin(iAttacker, vec2, 4)

	make_beam(vec1, vec2, g_iSpriteLaser, 0, 50, 200, 200)
}

public ze_user_infected(infected)
{
	if (g_bHasFrostM4A1[infected])
	{
		g_bHasFrostM4A1[infected] = false
	}
}

public ze_user_humanized(id)
{
	g_bHasFrostM4A1[id] = false
	g_iDmg[id] = 0
}

public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
{
	// Not Vaild Victim or Attacker
	if (!is_user_connected(iVictim) || !is_user_connected(iAttacker))
		return HC_CONTINUE
	
	if (g_bHasFrostM4A1[iAttacker] && (get_user_weapon(iAttacker) == CSW_M4A1))
	{
		SetHookChainArg(4 , ATYPE_FLOAT, fDamage * get_pcvar_num(g_iDmgMultiplier))
	}
	
	if((get_user_weapon(iAttacker) == CSW_M4A1) && g_bHasFrostM4A1[iAttacker])
	{
		g_iDmg[iAttacker] += (floatround(fDamage) * get_pcvar_num(g_iDmgMultiplier))
	}
	
	if((g_iDmg[iAttacker] >= get_pcvar_num(g_iFreezeDmg)) && (get_user_weapon(iAttacker) == CSW_M4A1) && g_bHasFrostM4A1[iAttacker])
	{
		new szName[32]
		get_user_name(iVictim, szName, charsmax(szName))
		
		ze_set_frost_grenade(iVictim, true)
		
		g_iDmg[iAttacker] = 0
		
		set_dhudmessage(34, 138, 255, -1.0, 0.25, 2, 6.0, 3.0, 0.1, 1.5)
		show_dhudmessage(iAttacker, "%s Has been Freezed!", szName)
	}
	return HC_CONTINUE
}

public CheckModel(id)
{
	if (is_user_alive(id))
	{
		set_pev(id, pev_viewmodel2, V_M4A1_MODEL)
		set_pev(id, pev_weaponmodel2, P_M4A1_MODEL)
	}
	return PLUGIN_CONTINUE
}

public CurrentWeapon(id)
{
	if ((get_user_weapon(id) == CSW_M4A1) && g_bHasFrostM4A1[id] == true)
	{
		CheckModel(id)
	}
	else
	{
		ClearSyncHud(id, g_iHudSync)
	}
	return PLUGIN_CONTINUE
}

make_beam(const origin2[3], const origin[3], sprite, red, green, blue, alpha)
{
	//BEAMENTPOINTS
	message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
	write_byte (0) //TE_BEAMENTPOINTS 0
	write_coord(origin2[0])
	write_coord(origin2[1])
	write_coord(origin2[2])
	write_coord(origin[0])
	write_coord(origin[1])
	write_coord(origin[2])
	write_short(sprite) // sprite
	write_byte(1) // framestart
	write_byte(5) // framerate
	write_byte(2) // life
	write_byte(20) // width
	write_byte(0) // noise 
	write_byte(red) // r, g, b
	write_byte(green) // r, g, b 
	write_byte(blue) // r, g, b 
	write_byte(alpha) // brightness
	write_byte(150) // speed
	message_end()
}

public Fw_SetModel(entity, model[])
{
	
	if(!is_valid_ent(entity)) 
		return FMRES_IGNORED

	if(!equali(model, W_OLD_M4A1_MODEL)) 
		return FMRES_IGNORED

	new className[33]
	entity_get_string(entity, EV_SZ_classname, className, 32)

	static iOwner, iStoredM4A1ID

	// Frost M4A1 Owner
	iOwner = entity_get_edict(entity, EV_ENT_owner)

	// Get drop weapon index (Frost M4A1) to use in fw_FrostM4A1AddToPlayer forward
	iStoredM4A1ID = find_ent_by_owner(-1, "weapon_m4a1", entity)

	// If Player Has Frost M4A1 and It's weapon_m4a1
	if(g_bHasFrostM4A1[iOwner] && is_valid_ent(iStoredM4A1ID))
	{
		// Setting weapon options
		entity_set_int(iStoredM4A1ID, EV_INT_impulse, 1997)

		// Rest Var
		g_bHasFrostM4A1[iOwner] = false
		
		// Set weaponbox new model
		entity_set_model(entity, W_M4A1_MODEL)
		return FMRES_SUPERCEDE
	}
	return FMRES_IGNORED
}

public Fw_AddFrostM4A1ToPlayer(FrostM4A1, id)
{
	// Make sure that this is M4A1
	if(is_valid_ent(FrostM4A1) && is_user_connected(id) && entity_get_int(FrostM4A1, EV_INT_impulse) == 1997)
	{
		// Update Var
		g_bHasFrostM4A1[id] = true

		// Reset weapon options
		entity_set_int(FrostM4A1, EV_INT_impulse, 0)
		return HAM_HANDLED
	}
	return HAM_IGNORED
}
Level Menu Code

Code: Select all

#include <zombie_escape>
#include <ze_levels>

native give_golden_m3(id);
native give_golden_mp5(id);
native give_golden_m4a1(id);
native give_golden_ak47(id);
native ze_giveminigun(id)
native give_thantos5(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,
	200,
	-1,
	200,
	1,
	200,
	1,
	200,
	200,
	1,
	200,
	200,
	200,
	200,
	200,
	200,
	200,
	200,
	200,
	200,
	200,
	32,
	200,
	200,
	200,
	2,
	200,
	200,
	200,
	-1,
	200
}

// 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", "0")
	g_pCvarFlashGrenade = register_cvar("ze_give_FB_nade", "0")
	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: WPN_MAXIDS[id] = 18     // Golden AK47
	}
	
	if (ze_get_user_level(id) > 30)
	{
		WPN_MAXIDS[id] = 18
	}

	// 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)
		{
			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, "Thantos-5")
				break;
			}
		}
		
		// Must check if iIndex < 14 means max is AK47
		if (iIndex < 14)
		{
			ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
			iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, szWeaponNames[get_weaponid(szWeaponName)])
		}
	}
	
	if (iIndex < 7)
	{
		ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
	}
	
	if (ze_get_user_level(id) == 5)
	{
		ArrayGetString(g_szPrimaryWeapons, 7, szWeaponName, charsmax(szWeaponName))
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
	}
	else if (ze_get_user_level(id) == 6)
	{
		ArrayGetString(g_szPrimaryWeapons, 8, szWeaponName, charsmax(szWeaponName))
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
	}
	else if (ze_get_user_level(id) == 7)
	{
		ArrayGetString(g_szPrimaryWeapons, 9, szWeaponName, charsmax(szWeaponName))
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
	}
	else if (ze_get_user_level(id) == 8)
	{
		ArrayGetString(g_szPrimaryWeapons, 10, szWeaponName, charsmax(szWeaponName))
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
	}
	else if (ze_get_user_level(id) == 9)
	{
		ArrayGetString(g_szPrimaryWeapons, 11, szWeaponName, charsmax(szWeaponName))
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
	}
	else if (ze_get_user_level(id) == 10)
	{
		ArrayGetString(g_szPrimaryWeapons, 12, szWeaponName, charsmax(szWeaponName))
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
	}
	else if (ze_get_user_level(id) == 11)
	{
		ArrayGetString(g_szPrimaryWeapons, 13, szWeaponName, charsmax(szWeaponName))
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
	}
	else if (ze_get_user_level(id) >= 12 && ze_get_user_level(id) < 15) // 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) // Thantos-5
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 30 Unlock\w: \yThantos-5^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
	{
		give_golden_m4a1(id)
		g_bBoughtPrimary[id] = true
		return true;
	}
	else if (selection == 17) // Thantos-5
	{
		give_thantos5(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])
	ze_giveminigun(id)

	
	// 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
}
DRK Zombie-Escape V1.6
IP : 81.169.153.129:27015

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

#2

Post by Raheem » 5 years ago

Frost M4A1:
    1. #include <zombie_escape>
    2. #include <engine>
    3.  
    4. new const V_M4A1_MODEL[] = "models/zombie_escape/v_frost_m4a1.mdl"
    5. new const P_M4A1_MODEL[] = "models/zombie_escape/p_frost_m4a1.mdl"
    6. new const W_M4A1_MODEL[] = "models/zombie_escape/w_frost_m4a1.mdl"
    7. new const W_OLD_M4A1_MODEL[] = "models/w_m4a1.mdl"
    8.  
    9. new g_iHudSync, g_iSpriteLaser, g_iFreezeDmg, g_iDmgMultiplier
    10. new bool:g_bHasFrostM4A1[33]
    11. new g_iDmg[33]
    12.  
    13. public plugin_init()
    14. {
    15.     register_plugin("[ZE] Extra Item: Frost M4A1", "1.0", "Raheem")
    16.    
    17.     // Cvars
    18.     g_iFreezeDmg = register_cvar("ze_freezing_m4a1_damage", "2000") // Damage Requried So Zombie got Frozen
    19.     g_iDmgMultiplier = register_cvar("ze_multiplier_m4a1_damage", "2") // Multiplie Weapon Damage
    20.  
    21.     // Message IDS
    22.     g_iHudSync = CreateHudSyncObj()
    23.    
    24.     // Events
    25.     register_event("WeapPickup", "CheckModel", "b", "1=19")
    26.     register_event("CurWeapon", "CurrentWeapon", "be", "1=1")
    27.    
    28.     // Forwards
    29.     register_forward(FM_SetModel, "Fw_SetModel")
    30.    
    31.     // HookChains
    32.     RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
    33.    
    34.     // Hams
    35.     RegisterHam(Ham_TraceAttack, "player", "Fw_TraceAttack_Post", 1)
    36.     RegisterHam(Ham_TraceAttack, "worldspawn", "Fw_TraceAttack_Post", 1)
    37.     RegisterHam(Ham_Item_AddToPlayer, "weapon_m4a1", "Fw_AddFrostM4A1ToPlayer")
    38. }
    39.  
    40. public plugin_precache()
    41. {
    42.     // Models
    43.     precache_model(V_M4A1_MODEL)
    44.     precache_model(P_M4A1_MODEL)
    45.     precache_model(W_M4A1_MODEL)
    46.    
    47.     // Sprites
    48.     g_iSpriteLaser = precache_model( "sprites/Newlightning.spr")
    49. }
    50.  
    51. public plugin_natives()
    52. {
    53.     register_native("give_frost_m4a1", "native_give_frost_m4a1", 1)
    54. }
    55.  
    56. public native_give_frost_m4a1(id)
    57. {
    58.     g_bHasFrostM4A1[player] = true
    59.  
    60.     rg_remove_item(player, "weapon_m4a1")
    61.     rg_give_item(player, "weapon_m4a1", GT_APPEND)
    62.     rg_set_user_bpammo(player, WeaponIdType:get_weaponid("weapon_m4a1"), 90)
    63.    
    64.     new szName[32]
    65.     get_user_name(player, szName, charsmax(szName))
    66.    
    67.     //set_hudmessage(random(255), random(255), random(255), -1.0, 0.17, 1, 0.0, 5.0, 1.0, 1.0, -1)
    68.     //show_hudmessage(0, "%s Has bought Frost M4A1!", szName)
    69.    
    70.     ze_colored_print(player, "!tYou choosed Frost M4A1!y!")
    71. }
    72.  
    73. public client_disconnected(id)
    74. {
    75.     g_bHasFrostM4A1[id] = false
    76. }
    77.  
    78. public Fw_TraceAttack_Post(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
    79. {
    80.     if(!is_user_alive(iAttacker))
    81.         return
    82.    
    83.     if(get_user_weapon(iAttacker) != CSW_M4A1 || !g_bHasFrostM4A1[iAttacker])
    84.         return
    85.    
    86.     set_hudmessage(34, 138, 255, -1.0, 0.17, 1, 0.0, 2.0, 1.0, 1.0, -1)
    87.     ShowSyncHudMsg(iAttacker, g_iHudSync, "Freeze Damage^n%d/%d", g_iDmg[iAttacker], get_pcvar_num(g_iFreezeDmg))
    88.    
    89.     new vec1[3], vec2[3]
    90.     get_user_origin(iAttacker, vec1, 1)
    91.     get_user_origin(iAttacker, vec2, 4)
    92.  
    93.     make_beam(vec1, vec2, g_iSpriteLaser, 0, 50, 200, 200)
    94. }
    95.  
    96. public ze_user_infected(infected)
    97. {
    98.     if (g_bHasFrostM4A1[infected])
    99.     {
    100.         g_bHasFrostM4A1[infected] = false
    101.     }
    102. }
    103.  
    104. public ze_user_humanized(id)
    105. {
    106.     g_bHasFrostM4A1[id] = false
    107.     g_iDmg[id] = 0
    108. }
    109.  
    110. public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
    111. {
    112.     // Not Vaild Victim or Attacker
    113.     if (!is_user_connected(iVictim) || !is_user_connected(iAttacker))
    114.         return HC_CONTINUE
    115.    
    116.     if (g_bHasFrostM4A1[iAttacker] && (get_user_weapon(iAttacker) == CSW_M4A1))
    117.     {
    118.         SetHookChainArg(4 , ATYPE_FLOAT, fDamage * get_pcvar_num(g_iDmgMultiplier))
    119.     }
    120.    
    121.     if((get_user_weapon(iAttacker) == CSW_M4A1) && g_bHasFrostM4A1[iAttacker])
    122.     {
    123.         g_iDmg[iAttacker] += (floatround(fDamage) * get_pcvar_num(g_iDmgMultiplier))
    124.     }
    125.    
    126.     if((g_iDmg[iAttacker] >= get_pcvar_num(g_iFreezeDmg)) && (get_user_weapon(iAttacker) == CSW_M4A1) && g_bHasFrostM4A1[iAttacker])
    127.     {
    128.         new szName[32]
    129.         get_user_name(iVictim, szName, charsmax(szName))
    130.        
    131.         ze_set_frost_grenade(iVictim, true)
    132.        
    133.         g_iDmg[iAttacker] = 0
    134.        
    135.         set_dhudmessage(34, 138, 255, -1.0, 0.25, 2, 6.0, 3.0, 0.1, 1.5)
    136.         show_dhudmessage(iAttacker, "%s Has been Freezed!", szName)
    137.     }
    138.     return HC_CONTINUE
    139. }
    140.  
    141. public CheckModel(id)
    142. {
    143.     if (is_user_alive(id))
    144.     {
    145.         set_pev(id, pev_viewmodel2, V_M4A1_MODEL)
    146.         set_pev(id, pev_weaponmodel2, P_M4A1_MODEL)
    147.     }
    148.     return PLUGIN_CONTINUE
    149. }
    150.  
    151. public CurrentWeapon(id)
    152. {
    153.     if ((get_user_weapon(id) == CSW_M4A1) && g_bHasFrostM4A1[id] == true)
    154.     {
    155.         CheckModel(id)
    156.     }
    157.     else
    158.     {
    159.         ClearSyncHud(id, g_iHudSync)
    160.     }
    161.     return PLUGIN_CONTINUE
    162. }
    163.  
    164. make_beam(const origin2[3], const origin[3], sprite, red, green, blue, alpha)
    165. {
    166.     //BEAMENTPOINTS
    167.     message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
    168.     write_byte (0) //TE_BEAMENTPOINTS 0
    169.     write_coord(origin2[0])
    170.     write_coord(origin2[1])
    171.     write_coord(origin2[2])
    172.     write_coord(origin[0])
    173.     write_coord(origin[1])
    174.     write_coord(origin[2])
    175.     write_short(sprite) // sprite
    176.     write_byte(1) // framestart
    177.     write_byte(5) // framerate
    178.     write_byte(2) // life
    179.     write_byte(20) // width
    180.     write_byte(0) // noise
    181.     write_byte(red) // r, g, b
    182.     write_byte(green) // r, g, b
    183.     write_byte(blue) // r, g, b
    184.     write_byte(alpha) // brightness
    185.     write_byte(150) // speed
    186.     message_end()
    187. }
    188.  
    189. public Fw_SetModel(entity, model[])
    190. {
    191.    
    192.     if(!is_valid_ent(entity))
    193.         return FMRES_IGNORED
    194.  
    195.     if(!equali(model, W_OLD_M4A1_MODEL))
    196.         return FMRES_IGNORED
    197.  
    198.     new className[33]
    199.     entity_get_string(entity, EV_SZ_classname, className, 32)
    200.  
    201.     static iOwner, iStoredM4A1ID
    202.  
    203.     // Frost M4A1 Owner
    204.     iOwner = entity_get_edict(entity, EV_ENT_owner)
    205.  
    206.     // Get drop weapon index (Frost M4A1) to use in fw_FrostM4A1AddToPlayer forward
    207.     iStoredM4A1ID = find_ent_by_owner(-1, "weapon_m4a1", entity)
    208.  
    209.     // If Player Has Frost M4A1 and It's weapon_m4a1
    210.     if(g_bHasFrostM4A1[iOwner] && is_valid_ent(iStoredM4A1ID))
    211.     {
    212.         // Setting weapon options
    213.         entity_set_int(iStoredM4A1ID, EV_INT_impulse, 1997)
    214.  
    215.         // Rest Var
    216.         g_bHasFrostM4A1[iOwner] = false
    217.        
    218.         // Set weaponbox new model
    219.         entity_set_model(entity, W_M4A1_MODEL)
    220.         return FMRES_SUPERCEDE
    221.     }
    222.     return FMRES_IGNORED
    223. }
    224.  
    225. public Fw_AddFrostM4A1ToPlayer(FrostM4A1, id)
    226. {
    227.     // Make sure that this is M4A1
    228.     if(is_valid_ent(FrostM4A1) && is_user_connected(id) && entity_get_int(FrostM4A1, EV_INT_impulse) == 1997)
    229.     {
    230.         // Update Var
    231.         g_bHasFrostM4A1[id] = true
    232.  
    233.         // Reset weapon options
    234.         entity_set_int(FrostM4A1, EV_INT_impulse, 0)
    235.         return HAM_HANDLED
    236.     }
    237.     return HAM_IGNORED
    238. }
Weapons Menu:
    1. #include <zombie_escape>
    2. #include <ze_levels>
    3.  
    4. native give_golden_m3(id);
    5. native give_golden_mp5(id);
    6. native give_golden_m4a1(id);
    7. native ze_giveminigun(id);
    8. native give_thantos5(id);
    9. native give_frost_m4a1(id);
    10.  
    11. // Setting File
    12. new const ZE_SETTING_RESOURCES[] = "zombie_escape.ini"
    13.  
    14. // Keys
    15. 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
    16. const OFFSET_CSMENUCODE = 205
    17.  
    18. // Primary Weapons Entities [Default Values]
    19. new const szPrimaryWeaponEnt[][] =
    20. {
    21.     "weapon_xm1014",  // Level 0
    22.     "weapon_ump45",   // Level 0
    23.     "weapon_m3",      // Level 1
    24.     "weapon_mp5navy", // Level 2
    25.     "weapon_p90",     // Level 3
    26.     "weapon_galil",   // Level 4
    27.     "weapon_famas",   // Level 5
    28.     "weapon_sg550",   // Level 6
    29.     "weapon_g3sg1",   // Level 7
    30.     "weapon_m249",    // Level 8
    31.     "weapon_sg552",   // Level 9
    32.     "weapon_aug",     // Level 10
    33.     "weapon_m4a1",    // Level 11
    34.     "weapon_ak47"     // Level 12
    35. }
    36.  
    37. // Secondary Weapons Entities [Default Values]
    38. new const szSecondaryWeaponEnt[][]=
    39. {
    40.     "weapon_usp",         // Level 0
    41.     "weapon_p228",        // Level 0
    42.     "weapon_glock18",     // Level 1
    43.     "weapon_fiveseven",   // Level 2
    44.     "weapon_deagle",      // Level 3
    45.     "weapon_elite"        // Level 4
    46. }
    47.  
    48. // Primary and Secondary Weapons Names [Default Values]
    49. new const szWeaponNames[][] =
    50. {
    51.     "",
    52.     "P228",
    53.     "",
    54.     "Scout",
    55.     "HE Grenade",
    56.     "XM1014",
    57.     "",
    58.     "MAC-10",
    59.     "AUG",
    60.     "Smoke Grenade",
    61.     "Dual Elite",
    62.     "Five Seven",
    63.     "UMP 45",
    64.     "SG-550",
    65.     "Galil",
    66.     "Famas",
    67.     "USP",
    68.     "Glock",
    69.     "AWP",
    70.     "MP5",
    71.     "M249",
    72.     "M3",
    73.     "M4A1",
    74.     "TMP",
    75.     "G3SG1",
    76.     "Flashbang",
    77.     "Desert Eagle",
    78.     "SG-552",
    79.     "AK-47",
    80.     "",
    81.     "P90"
    82. }
    83.  
    84. // Max Back Clip Ammo (Change it From here if you need)
    85. new const szMaxBPAmmo[] =
    86. {
    87.     -1,
    88.     200,
    89.     -1,
    90.     200,
    91.     1,
    92.     200,
    93.     1,
    94.     200,
    95.     200,
    96.     1,
    97.     200,
    98.     200,
    99.     200,
    100.     200,
    101.     200,
    102.     200,
    103.     200,
    104.     200,
    105.     200,
    106.     200,
    107.     200,
    108.     32,
    109.     200,
    110.     200,
    111.     200,
    112.     2,
    113.     200,
    114.     200,
    115.     200,
    116.     -1,
    117.     200
    118. }
    119.  
    120. // Menu selections
    121. const MENU_KEY_AUTOSELECT = 7
    122. const MENU_KEY_BACK = 7
    123. const MENU_KEY_NEXT = 8
    124. const MENU_KEY_EXIT = 9
    125.  
    126. // Variables
    127. new Array:g_szPrimaryWeapons, Array:g_szSecondaryWeapons
    128.  
    129. new g_iMenuData[33][4],
    130.     Float:g_fBuyTimeStart[33],
    131.     bool:g_bBoughtPrimary[33],
    132.     bool:g_bBoughtSecondary[33],
    133.     WPN_MAXIDS[33]
    134.  
    135. // Define
    136. #define WPN_STARTID g_iMenuData[id][0]
    137. #define WPN_SELECTION (g_iMenuData[id][0]+key)
    138. #define WPN_AUTO_ON g_iMenuData[id][1]
    139. #define WPN_AUTO_PRI g_iMenuData[id][2]
    140. #define WPN_AUTO_SEC g_iMenuData[id][3]
    141.  
    142. // Cvars
    143. new g_pCvarBuyTime,
    144.     g_pCvarHeGrenade,
    145.     g_pCvarSmokeGrenade,
    146.     g_pCvarFlashGrenade,
    147.     g_pCvarBlockWeapLowLevel
    148.  
    149. public plugin_natives()
    150. {
    151.     register_native("ze_show_weapon_menu", "native_ze_show_weapon_menu", 1)
    152.     register_native("ze_is_auto_buy_enabled", "native_ze_is_auto_buy_enabled", 1)
    153.     register_native("ze_disable_auto_buy", "native_ze_disable_auto_buy", 1)
    154. }
    155.  
    156. public plugin_precache()
    157. {
    158.     // Initialize arrays (32 is the max length of Weapon Entity like: weapon_ak47)
    159.     g_szPrimaryWeapons = ArrayCreate(32, 1)
    160.     g_szSecondaryWeapons = ArrayCreate(32, 1)
    161.    
    162.     // Load from external file
    163.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
    164.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
    165.    
    166.     // If we couldn't load from file, use and save default ones
    167.    
    168.     new iIndex
    169.    
    170.     if (ArraySize(g_szPrimaryWeapons) == 0)
    171.     {
    172.         for (iIndex = 0; iIndex < sizeof szPrimaryWeaponEnt; iIndex++)
    173.             ArrayPushString(g_szPrimaryWeapons, szPrimaryWeaponEnt[iIndex])
    174.        
    175.         // If not found .ini File Create it and save default values in it
    176.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
    177.     }
    178.    
    179.     if (ArraySize(g_szSecondaryWeapons) == 0)
    180.     {
    181.         for (iIndex = 0; iIndex < sizeof szSecondaryWeaponEnt; iIndex++)
    182.             ArrayPushString(g_szSecondaryWeapons, szSecondaryWeaponEnt[iIndex])
    183.        
    184.         // If not found .ini File Create it and save default values in it
    185.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
    186.     }
    187. }
    188.  
    189. public plugin_init()
    190. {
    191.     register_plugin("[ZE] Levels Weapons Menu", "1.1", "Raheem")
    192.    
    193.     // Commands
    194.     register_clcmd("guns", "Cmd_Buy")
    195.     register_clcmd("say /enable", "Cmd_Enable")
    196.     register_clcmd("say_team /enable", "Cmd_Enable")
    197.    
    198.     // Cvars
    199.     g_pCvarBuyTime = register_cvar("ze_buy_time", "60")
    200.     g_pCvarHeGrenade = register_cvar("ze_give_HE_nade", "1") // 0 Nothing || 1 Give HE
    201.     g_pCvarSmokeGrenade = register_cvar("ze_give_SM_nade", "0")
    202.     g_pCvarFlashGrenade = register_cvar("ze_give_FB_nade", "0")
    203.     g_pCvarBlockWeapLowLevel = register_cvar("ze_block_weapons_lowlvl", "1")
    204.    
    205.     // Menus
    206.     register_menu("Primary Weapons", KEYSMENU, "Menu_Buy_Primary")
    207.     register_menu("Secondary Weapons", KEYSMENU, "Menu_Buy_Secondary")
    208.    
    209.     // Hams
    210.     RegisterHam(Ham_Touch, "weaponbox", "Fw_TouchWeapon_Pre", 0)
    211.     RegisterHam(Ham_Touch, "armoury_entity", "Fw_TouchWeapon_Pre", 0)
    212. }
    213.  
    214. public client_disconnected(id)
    215. {
    216.     WPN_AUTO_ON = 0
    217.     WPN_STARTID = 0
    218. }
    219.  
    220. public Cmd_Enable(id)
    221. {
    222.     if (WPN_AUTO_ON)
    223.     {
    224.         ze_colored_print(id, "%L", LANG_PLAYER, "BUY_ENABLED")
    225.         WPN_AUTO_ON = 0
    226.     }
    227. }
    228.  
    229. public Cmd_Buy(id)
    230. {
    231.     // Player Zombie
    232.     if (ze_is_user_zombie(id))
    233.     {
    234.         ze_colored_print(id, "%L", LANG_PLAYER, "NO_BUY_ZOMBIE")
    235.         return
    236.     }
    237.    
    238.     // Player Dead
    239.     if (!is_user_alive(id))
    240.     {
    241.         ze_colored_print(id, "%L", LANG_PLAYER, "DEAD_CANT_BUY_WEAPON")
    242.         return
    243.     }
    244.    
    245.     // Already bought
    246.     if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
    247.     {
    248.         ze_colored_print(id, "%L", LANG_PLAYER, "ALREADY_BOUGHT")
    249.     }
    250.    
    251.     Show_Available_Buy_Menus(id)
    252. }
    253.  
    254. public ze_user_humanized(id)
    255. {
    256.     // Static Values
    257.     switch (ze_get_user_level(id))
    258.     {
    259.         case 0: WPN_MAXIDS[id] = 2
    260.         case 1: WPN_MAXIDS[id] = 3
    261.         case 2: WPN_MAXIDS[id] = 4
    262.         case 3: WPN_MAXIDS[id] = 5
    263.         case 4: WPN_MAXIDS[id] = 6
    264.         case 5: WPN_MAXIDS[id] = 7
    265.         case 6: WPN_MAXIDS[id] = 8
    266.         case 7: WPN_MAXIDS[id] = 9
    267.         case 8: WPN_MAXIDS[id] = 10
    268.         case 9: WPN_MAXIDS[id] = 11
    269.         case 10: WPN_MAXIDS[id] = 12
    270.         case 11: WPN_MAXIDS[id] = 13
    271.         case 12..14: WPN_MAXIDS[id] = 14
    272.         case 15..19: WPN_MAXIDS[id] = 15 // Golden m3
    273.         case 20..24: WPN_MAXIDS[id] = 16 // Golden MP5
    274.         case 25..29: WPN_MAXIDS[id] = 17 // Golden M4A1
    275.         case 30: WPN_MAXIDS[id] = 18     // Golden AK47
    276.     }
    277.    
    278.     if (ze_get_user_level(id) > 30)
    279.     {
    280.         WPN_MAXIDS[id] = 18
    281.     }
    282.  
    283.     // Buyzone time starts when player is set to human
    284.     g_fBuyTimeStart[id] = get_gametime()
    285.    
    286.     g_bBoughtPrimary[id] = false
    287.     g_bBoughtSecondary[id] = false
    288.    
    289.     // Player dead or zombie
    290.     if (!is_user_alive(id) || ze_is_user_zombie(id))
    291.         return
    292.    
    293.     if (WPN_AUTO_ON)
    294.     {
    295.         ze_colored_print(id, "%L", LANG_PLAYER, "RE_ENABLE_MENU")
    296.         Buy_Primary_Weapon(id, WPN_AUTO_PRI)
    297.         Buy_Secondary_Weapon(id, WPN_AUTO_SEC)
    298.     }
    299.    
    300.     // Open available buy menus
    301.     Show_Available_Buy_Menus(id)
    302.    
    303.     // Give HE Grenade
    304.     if (get_pcvar_num(g_pCvarHeGrenade) != 0)
    305.         rg_give_item(id, "weapon_hegrenade")
    306.    
    307.     // Give Smoke Grenade
    308.     if (get_pcvar_num(g_pCvarSmokeGrenade) != 0)
    309.         rg_give_item(id, "weapon_smokegrenade")
    310.    
    311.     // Give Flashbang Grenade
    312.     if (get_pcvar_num(g_pCvarFlashGrenade) != 0)
    313.         rg_give_item(id, "weapon_flashbang")
    314. }
    315.  
    316. public Show_Available_Buy_Menus(id)
    317. {
    318.     // Already Bought
    319.     if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
    320.         return
    321.    
    322.     // Here we use if and else if so we make sure that Primary weapon come first then secondary
    323.     if (!g_bBoughtPrimary[id])
    324.     {
    325.         // Primary     
    326.         Show_Menu_Buy_Primary(id)
    327.     }
    328.     else if (!g_bBoughtSecondary[id])
    329.     {
    330.         // Secondary
    331.         Show_Menu_Buy_Secondary(id)
    332.     }
    333. }
    334.  
    335. public Show_Menu_Buy_Primary(id)
    336. {
    337.     new iMenuTime = floatround(g_fBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
    338.    
    339.     if (iMenuTime <= 0)
    340.     {
    341.         ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
    342.         return
    343.     }
    344.    
    345.     static szMenu[300], szWeaponName[32]
    346.     new iLen, iIndex, iMaxLoops = min(WPN_STARTID+7, WPN_MAXIDS[id])
    347.    
    348.     // Title
    349.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L \w[\r%d\w-\r%d\w]^n^n", id, "MENU_PRIMARY_TITLE", WPN_STARTID+1, min(WPN_STARTID+7, WPN_MAXIDS[id]))
    350.    
    351.     // 1-7. Weapon List
    352.     for (iIndex = WPN_STARTID; iIndex < iMaxLoops; iIndex++)
    353.     {
    354.         if (ze_get_user_level(id) == 0 && iIndex >= 2||
    355.         ze_get_user_level(id) == 1 && iIndex >= 3 ||
    356.         ze_get_user_level(id) == 2 && iIndex >= 4 ||
    357.         ze_get_user_level(id) == 3 && iIndex >= 5 ||
    358.         ze_get_user_level(id) == 4 && iIndex >= 6 ||
    359.         ze_get_user_level(id) == 5 && iIndex >= 7 ||
    360.         ze_get_user_level(id) == 6 && iIndex >= 8 ||
    361.         ze_get_user_level(id) == 7 && iIndex >= 9 ||
    362.         ze_get_user_level(id) == 8 && iIndex >= 10 ||
    363.         ze_get_user_level(id) == 9 && iIndex >= 11 ||
    364.         ze_get_user_level(id) == 10 && iIndex >= 12 ||
    365.         ze_get_user_level(id) == 11 && iIndex >= 13 ||
    366.         ze_get_user_level(id) == 12 && iIndex >= 14)
    367.         {
    368.             break
    369.         }
    370.        
    371.         /*
    372.         *  Note that WPN_MAXIDS start from 1 but iIndex start from 0.
    373.         */
    374.        
    375.         // Golden M3
    376.         if (ze_get_user_level(id) >= 15 && ze_get_user_level(id) < 20)
    377.         {
    378.             if (iIndex == 14)
    379.             {
    380.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Frost M4A1")
    381.                 break;
    382.             }
    383.         }
    384.        
    385.         // Golden MP5
    386.         if (ze_get_user_level(id) >= 20 && ze_get_user_level(id) < 25)
    387.         {
    388.             if (iIndex == 14)
    389.             {
    390.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Frost M4A1")
    391.             }
    392.            
    393.             if (iIndex == 15)
    394.             {
    395.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
    396.                 break;
    397.             }
    398.         }
    399.        
    400.         // Golden M4A1
    401.         if (ze_get_user_level(id) >= 25 && ze_get_user_level(id) < 30)
    402.         {
    403.             if (iIndex == 14)
    404.             {
    405.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Frost M4A1")
    406.             }
    407.            
    408.             if (iIndex == 15)
    409.             {
    410.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
    411.             }
    412.            
    413.             if (iIndex == 16)
    414.             {
    415.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
    416.                 break;
    417.             }
    418.         }
    419.        
    420.         // Golden AK47
    421.         if (ze_get_user_level(id) >= 30)
    422.         {
    423.             if (iIndex == 14)
    424.             {
    425.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Frost M4A1")
    426.             }
    427.            
    428.             if (iIndex == 15)
    429.             {
    430.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
    431.             }
    432.            
    433.             if (iIndex == 16)
    434.             {
    435.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
    436.             }
    437.            
    438.             if (iIndex == 17)
    439.             {
    440.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Thantos-5")
    441.                 break;
    442.             }
    443.         }
    444.        
    445.         // Must check if iIndex < 14 means max is AK47
    446.         if (iIndex < 14)
    447.         {
    448.             ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
    449.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, szWeaponNames[get_weaponid(szWeaponName)])
    450.         }
    451.     }
    452.    
    453.     if (iIndex < 7)
    454.     {
    455.         ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
    456.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    457.     }
    458.    
    459.     if (ze_get_user_level(id) == 5)
    460.     {
    461.         ArrayGetString(g_szPrimaryWeapons, 7, szWeaponName, charsmax(szWeaponName))
    462.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    463.     }
    464.     else if (ze_get_user_level(id) == 6)
    465.     {
    466.         ArrayGetString(g_szPrimaryWeapons, 8, szWeaponName, charsmax(szWeaponName))
    467.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    468.     }
    469.     else if (ze_get_user_level(id) == 7)
    470.     {
    471.         ArrayGetString(g_szPrimaryWeapons, 9, szWeaponName, charsmax(szWeaponName))
    472.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    473.     }
    474.     else if (ze_get_user_level(id) == 8)
    475.     {
    476.         ArrayGetString(g_szPrimaryWeapons, 10, szWeaponName, charsmax(szWeaponName))
    477.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    478.     }
    479.     else if (ze_get_user_level(id) == 9)
    480.     {
    481.         ArrayGetString(g_szPrimaryWeapons, 11, szWeaponName, charsmax(szWeaponName))
    482.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    483.     }
    484.     else if (ze_get_user_level(id) == 10)
    485.     {
    486.         ArrayGetString(g_szPrimaryWeapons, 12, szWeaponName, charsmax(szWeaponName))
    487.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    488.     }
    489.     else if (ze_get_user_level(id) == 11)
    490.     {
    491.         ArrayGetString(g_szPrimaryWeapons, 13, szWeaponName, charsmax(szWeaponName))
    492.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    493.     }
    494.     else if (ze_get_user_level(id) >= 12 && ze_get_user_level(id) < 15) // Golden M3
    495.     {
    496.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 15 Unlock\w: \yFrost M4A1^n")
    497.     }
    498.     else if (ze_get_user_level(id) >= 15 && ze_get_user_level(id) < 20) // Golden MP5
    499.     {
    500.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 20 Unlock\w: \yGolden MP5^n")
    501.     }
    502.     else if (ze_get_user_level(id) >= 20 && ze_get_user_level(id) < 25) // Golden M4A1
    503.     {
    504.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 25 Unlock\w: \yGolden M4A1^n")
    505.     }
    506.     else if (ze_get_user_level(id) >= 25 && ze_get_user_level(id) < 30) // Thantos-5
    507.     {
    508.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 30 Unlock\w: \yThantos-5^n")
    509.     }
    510.  
    511.     // 8. Auto Select
    512.     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")
    513.    
    514.     // 9. Next/Back - 0. Exit
    515.     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")
    516.    
    517.     // Fix for AMXX custom menus
    518.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    519.     show_menu(id, KEYSMENU, szMenu, iMenuTime, "Primary Weapons")
    520. }
    521.  
    522. public Show_Menu_Buy_Secondary(id)
    523. {
    524.     new iMenuTime = floatround(g_fBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
    525.    
    526.     if (iMenuTime <= 0)
    527.     {
    528.         ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
    529.         return
    530.     }
    531.    
    532.     static szMenu[250], szWeaponName[32]
    533.     new iLen, iIndex, iMaxLoops = ArraySize(g_szSecondaryWeapons)
    534.    
    535.     // Title
    536.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L^n", id, "MENU_SECONDARY_TITLE")
    537.    
    538.     // 1-6. Weapon List
    539.     for (iIndex = 0; iIndex < iMaxLoops; iIndex++)
    540.     {
    541.         if (ze_get_user_level(id) == 0 && iIndex >= 2 ||
    542.         ze_get_user_level(id) == 1 && iIndex >= 3 ||
    543.         ze_get_user_level(id) == 2 && iIndex >= 4 ||
    544.         ze_get_user_level(id) == 3 && iIndex >= 5 ||
    545.         ze_get_user_level(id) == 4 && iIndex >= 6)
    546.         {
    547.             break
    548.         }
    549.        
    550.         ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
    551.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\w%d.\y %s", iIndex+1, szWeaponNames[get_weaponid(szWeaponName)])
    552.     }
    553.    
    554.     if (iIndex < ArraySize(g_szSecondaryWeapons))
    555.     {
    556.         ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
    557.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r Next Level Unlock\w: \y%s", szWeaponNames[get_weaponid(szWeaponName)])
    558.     }
    559.    
    560.     // 8. Auto Select
    561.     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")
    562.    
    563.     // 0. Exit
    564.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\y %L", id, "EXIT")
    565.    
    566.     // Fix for AMXX custom menus
    567.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    568.     show_menu(id, KEYSMENU, szMenu, iMenuTime, "Secondary Weapons")
    569. }
    570.  
    571. public Menu_Buy_Primary(id, key)
    572. {
    573.     // Player dead or zombie or already bought primary
    574.     if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtPrimary[id])
    575.         return PLUGIN_HANDLED
    576.    
    577.     // Special keys / weapon list exceeded
    578.     if (key >= MENU_KEY_AUTOSELECT || WPN_SELECTION >= WPN_MAXIDS[id])
    579.     {
    580.         switch (key)
    581.         {
    582.             case MENU_KEY_AUTOSELECT: // toggle auto select
    583.             {
    584.                 WPN_AUTO_ON = 1 - WPN_AUTO_ON
    585.             }
    586.             case MENU_KEY_NEXT: // next/back
    587.             {
    588.                 if (WPN_STARTID+7 < WPN_MAXIDS[id])
    589.                     WPN_STARTID += 7
    590.                 else
    591.                     WPN_STARTID = 0
    592.             }
    593.             case MENU_KEY_EXIT: // exit
    594.             {
    595.                 return PLUGIN_HANDLED
    596.             }
    597.         }
    598.        
    599.         // Show buy menu again
    600.         Show_Menu_Buy_Primary(id)
    601.         return PLUGIN_HANDLED
    602.     }
    603.    
    604.     // Store selected weapon id
    605.     WPN_AUTO_PRI = WPN_SELECTION
    606.    
    607.     // Buy primary weapon
    608.     Buy_Primary_Weapon(id, WPN_AUTO_PRI)
    609.    
    610.     // Show Secondary Weapons
    611.     Show_Available_Buy_Menus(id)
    612.    
    613.     return PLUGIN_HANDLED
    614. }
    615.  
    616. public Buy_Primary_Weapon(id, selection)
    617. {
    618.     if (selection == 14) // Frost M4A1
    619.     {
    620.         give_frost_m4a1(id)
    621.         g_bBoughtPrimary[id] = true
    622.         return true;
    623.     }
    624.     else if (selection == 15) // Golden MP5
    625.     {
    626.         give_golden_mp5(id)
    627.         g_bBoughtPrimary[id] = true
    628.         return true;
    629.     }
    630.     else if (selection == 16) // Golden M4A1
    631.     {
    632.         give_golden_m4a1(id)
    633.         g_bBoughtPrimary[id] = true
    634.         return true;
    635.     }
    636.     else if (selection == 17) // Thantos-5
    637.     {
    638.         give_thantos5(id)
    639.         g_bBoughtPrimary[id] = true
    640.         return true;
    641.     }
    642.    
    643.     static szWeaponName[32]
    644.     ArrayGetString(g_szPrimaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
    645.     new iWeaponId = get_weaponid(szWeaponName)
    646.    
    647.     // Strip and Give Full Weapon
    648.     rg_give_item(id, szWeaponName, GT_REPLACE)
    649.     rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
    650.    
    651.     // Primary bought
    652.     g_bBoughtPrimary[id] = true
    653.     return true;
    654. }
    655.  
    656. public Menu_Buy_Secondary(id, key)
    657. {
    658.     // Player dead or zombie or already bought secondary
    659.     if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtSecondary[id])
    660.         return PLUGIN_HANDLED
    661.    
    662.     // Special keys / weapon list exceeded
    663.     if (key >= ArraySize(g_szSecondaryWeapons))
    664.     {
    665.         // Toggle autoselect
    666.         if (key == MENU_KEY_AUTOSELECT)
    667.             WPN_AUTO_ON = 1 - WPN_AUTO_ON
    668.        
    669.         // Reshow menu unless user exited
    670.         if (key != MENU_KEY_EXIT)
    671.             Show_Menu_Buy_Secondary(id)
    672.        
    673.         return PLUGIN_HANDLED
    674.     }
    675.    
    676.     // Store selected weapon id
    677.     WPN_AUTO_SEC = key
    678.    
    679.     // Buy secondary weapon
    680.     Buy_Secondary_Weapon(id, key)
    681.    
    682.     return PLUGIN_HANDLED
    683. }
    684.  
    685. public Buy_Secondary_Weapon(id, selection)
    686. {
    687.     if ( ((selection == 2) && (ze_get_user_level(id) < 1)) ||
    688.     ((selection == 3) && (ze_get_user_level(id) < 2)) ||
    689.     ((selection == 4) && (ze_get_user_level(id) < 3)) ||
    690.     ((selection == 5) && (ze_get_user_level(id) < 4)) )
    691.     {
    692.         Show_Menu_Buy_Secondary(id)
    693.         return;
    694.     }
    695.  
    696.     static szWeaponName[32]
    697.     ArrayGetString(g_szSecondaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
    698.     new iWeaponId = get_weaponid(szWeaponName)
    699.    
    700.     // Strip and Give Full Weapon
    701.     rg_give_item(id, szWeaponName, GT_REPLACE)
    702.     rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
    703.     ze_giveminigun(id)
    704.  
    705.    
    706.     // Secondary bought
    707.     g_bBoughtSecondary[id] = true
    708. }
    709.  
    710. public Fw_TouchWeapon_Pre(iEnt, id)
    711. {
    712.     if (get_pcvar_num(g_pCvarBlockWeapLowLevel) == 0)
    713.         return HAM_IGNORED;
    714.    
    715.     // Not alive or Not Valid Weapon?
    716.     if(!is_user_alive(id) || !pev_valid(iEnt))
    717.         return HAM_IGNORED;
    718.    
    719.     // Get Weapon Model
    720.     new szWeapModel[32]
    721.     pev(iEnt, pev_model, szWeapModel, charsmax(szWeapModel))
    722.    
    723.     // Remove "models/w_" and ".mdl"
    724.     copyc(szWeapModel, charsmax(szWeapModel), szWeapModel[contain(szWeapModel, "_" ) + 1], '.')
    725.    
    726.     // Set for mp5 to be same as "weapon_mp5navy"
    727.     if(szWeapModel[1] == 'p' && szWeapModel[2] == '5')
    728.         szWeapModel = "mp5navy"
    729.    
    730.     // Add "weapon_" to all model names
    731.     static szWeaponEnt[32]
    732.     formatex(szWeaponEnt, charsmax(szWeaponEnt), "weapon_%s", szWeapModel)
    733.  
    734.     // Get it's index in Weapon Array
    735.     new iIndex, i
    736.    
    737.     // I won't explain the blew code if you need to understand ask me in Escapers-Zone.XYZ
    738.     for (i = 0; i < ArraySize(g_szPrimaryWeapons); i++)
    739.     {
    740.         new szPrimaryWeapon[32]
    741.         ArrayGetString(g_szPrimaryWeapons, i, szPrimaryWeapon, charsmax(szPrimaryWeapon))
    742.        
    743.         if (equali(szWeaponEnt, szPrimaryWeapon))
    744.             iIndex = i
    745.     }
    746.    
    747.     if (ze_get_user_level(id) == 0 && iIndex > 1)
    748.     {
    749.         return HAM_SUPERCEDE;
    750.     }
    751.    
    752.     for (i = 1; i <= 11; i++)
    753.     {
    754.         if ((ze_get_user_level(id) == i) && iIndex > i+1)
    755.         {
    756.             return HAM_SUPERCEDE;
    757.         }
    758.     }
    759.    
    760.     return HAM_IGNORED;
    761. }
    762.  
    763. // Natives
    764. public native_ze_show_weapon_menu(id)
    765. {
    766.     if (!is_user_connected(id))
    767.     {
    768.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    769.         return false
    770.     }
    771.    
    772.     Cmd_Buy(id)
    773.     return true
    774. }
    775.  
    776. public native_ze_is_auto_buy_enabled(id)
    777. {
    778.     if (!is_user_connected(id))
    779.     {
    780.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    781.         return -1;
    782.     }
    783.    
    784.     return WPN_AUTO_ON;
    785. }
    786.  
    787. public native_ze_disable_auto_buy(id)
    788. {
    789.     if (!is_user_connected(id))
    790.     {
    791.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    792.         return false
    793.     }
    794.    
    795.     WPN_AUTO_ON = 0;
    796.     return true
    797. }
Just added native for frost m4a1, and remove it from extra-items. Also just replaced golden m3 with this frost m4a1.
He who fails to plan is planning to fail

User avatar
Luxurious
Mod Tester
Mod Tester
Egypt
Posts: 177
Joined: 6 years ago
Location: Egypt
Contact:

#3

Post by Luxurious » 5 years ago

  • // D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\ze_frost_m4a1.sma(58) : error 017: undefined symbol "player"
    // D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\ze_frost_m4a1.sma(58 -- 60) : warning 215: expression has no effect
    // D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\ze_frost_m4a1.sma(60) : error 017: undefined symbol "player"
    // D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\ze_frost_m4a1.sma(60) : warning 215: expression has no effect
    // D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\ze_frost_m4a1.sma(60) : error 001: expected token: ";", but found ")"
    // D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\ze_frost_m4a1.sma(60) : fatal error 107: too many error messages on one line
DRK Zombie-Escape V1.6
IP : 81.169.153.129:27015

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

#4

Post by Mark » 5 years ago

Luxurious wrote: 5 years ago
  • // D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\ze_frost_m4a1.sma(58) : error 017: undefined symbol "player"
    // D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\ze_frost_m4a1.sma(58 -- 60) : warning 215: expression has no effect
    // D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\ze_frost_m4a1.sma(60) : error 017: undefined symbol "player"
    // D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\ze_frost_m4a1.sma(60) : warning 215: expression has no effect
    // D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\ze_frost_m4a1.sma(60) : error 001: expected token: ";", but found ")"
    // D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\ze_frost_m4a1.sma(60) : fatal error 107: too many error messages on one line
>>>>>>>>
  1. #include <zombie_escape>
  2. #include <engine>
  3.  
  4. new const V_M4A1_MODEL[] = "models/zombie_escape/v_frost_m4a1.mdl"
  5. new const P_M4A1_MODEL[] = "models/zombie_escape/p_frost_m4a1.mdl"
  6. new const W_M4A1_MODEL[] = "models/zombie_escape/w_frost_m4a1.mdl"
  7. new const W_OLD_M4A1_MODEL[] = "models/w_m4a1.mdl"
  8.  
  9. new g_iHudSync, g_iSpriteLaser, g_iFreezeDmg, g_iDmgMultiplier
  10. new bool:g_bHasFrostM4A1[33]
  11. new g_iDmg[33]
  12.  
  13. public plugin_init()
  14. {
  15.     register_plugin("[ZE] Extra Item: Frost M4A1", "1.0", "Raheem")
  16.    
  17.     // Cvars
  18.     g_iFreezeDmg = register_cvar("ze_freezing_m4a1_damage", "2000") // Damage Requried So Zombie got Frozen
  19.     g_iDmgMultiplier = register_cvar("ze_multiplier_m4a1_damage", "2") // Multiplie Weapon Damage
  20.  
  21.     // Message IDS
  22.     g_iHudSync = CreateHudSyncObj()
  23.    
  24.     // Events
  25.     register_event("WeapPickup", "CheckModel", "b", "1=19")
  26.     register_event("CurWeapon", "CurrentWeapon", "be", "1=1")
  27.    
  28.     // Forwards
  29.     register_forward(FM_SetModel, "Fw_SetModel")
  30.    
  31.     // HookChains
  32.     RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
  33.    
  34.     // Hams
  35.     RegisterHam(Ham_TraceAttack, "player", "Fw_TraceAttack_Post", 1)
  36.     RegisterHam(Ham_TraceAttack, "worldspawn", "Fw_TraceAttack_Post", 1)
  37.     RegisterHam(Ham_Item_AddToPlayer, "weapon_m4a1", "Fw_AddFrostM4A1ToPlayer")
  38. }
  39.  
  40. public plugin_precache()
  41. {
  42.     // Models
  43.     precache_model(V_M4A1_MODEL)
  44.     precache_model(P_M4A1_MODEL)
  45.     precache_model(W_M4A1_MODEL)
  46.    
  47.     // Sprites
  48.     g_iSpriteLaser = precache_model( "sprites/Newlightning.spr")
  49. }
  50.  
  51. public plugin_natives()
  52. {
  53.     register_native("give_frost_m4a1", "native_give_frost_m4a1", 1)
  54. }
  55.  
  56. public native_give_frost_m4a1(id)
  57. {
  58.     g_bHasFrostM4A1[id] = true
  59.  
  60.     rg_remove_item(id, "weapon_m4a1")
  61.     rg_give_item(id, "weapon_m4a1", GT_APPEND)
  62.     rg_set_user_bpammo(id, WeaponIdType:get_weaponid("weapon_m4a1"), 90)
  63.    
  64.     new szName[32]
  65.     get_user_name(id, szName, charsmax(szName))
  66.    
  67.     //set_hudmessage(random(255), random(255), random(255), -1.0, 0.17, 1, 0.0, 5.0, 1.0, 1.0, -1)
  68.     //show_hudmessage(0, "%s Has bought Frost M4A1!", szName)
  69.    
  70.     ze_colored_print(id, "!tYou choosed Frost M4A1!y!")
  71. }
  72.  
  73. public client_disconnected(id)
  74. {
  75.     g_bHasFrostM4A1[id] = false
  76. }
  77.  
  78. public Fw_TraceAttack_Post(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
  79. {
  80.     if(!is_user_alive(iAttacker))
  81.         return
  82.    
  83.     if(get_user_weapon(iAttacker) != CSW_M4A1 || !g_bHasFrostM4A1[iAttacker])
  84.         return
  85.    
  86.     set_hudmessage(34, 138, 255, -1.0, 0.17, 1, 0.0, 2.0, 1.0, 1.0, -1)
  87.     ShowSyncHudMsg(iAttacker, g_iHudSync, "Freeze Damage^n%d/%d", g_iDmg[iAttacker], get_pcvar_num(g_iFreezeDmg))
  88.    
  89.     new vec1[3], vec2[3]
  90.     get_user_origin(iAttacker, vec1, 1)
  91.     get_user_origin(iAttacker, vec2, 4)
  92.  
  93.     make_beam(vec1, vec2, g_iSpriteLaser, 0, 50, 200, 200)
  94. }
  95.  
  96. public ze_user_infected(infected)
  97. {
  98.     if (g_bHasFrostM4A1[infected])
  99.     {
  100.         g_bHasFrostM4A1[infected] = false
  101.     }
  102. }
  103.  
  104. public ze_user_humanized(id)
  105. {
  106.     g_bHasFrostM4A1[id] = false
  107.     g_iDmg[id] = 0
  108. }
  109.  
  110. public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
  111. {
  112.     // Not Vaild Victim or Attacker
  113.     if (!is_user_connected(iVictim) || !is_user_connected(iAttacker))
  114.         return HC_CONTINUE
  115.    
  116.     if (g_bHasFrostM4A1[iAttacker] && (get_user_weapon(iAttacker) == CSW_M4A1))
  117.     {
  118.         SetHookChainArg(4 , ATYPE_FLOAT, fDamage * get_pcvar_num(g_iDmgMultiplier))
  119.     }
  120.    
  121.     if((get_user_weapon(iAttacker) == CSW_M4A1) && g_bHasFrostM4A1[iAttacker])
  122.     {
  123.         g_iDmg[iAttacker] += (floatround(fDamage) * get_pcvar_num(g_iDmgMultiplier))
  124.     }
  125.    
  126.     if((g_iDmg[iAttacker] >= get_pcvar_num(g_iFreezeDmg)) && (get_user_weapon(iAttacker) == CSW_M4A1) && g_bHasFrostM4A1[iAttacker])
  127.     {
  128.         new szName[32]
  129.         get_user_name(iVictim, szName, charsmax(szName))
  130.        
  131.         ze_set_frost_grenade(iVictim, true)
  132.        
  133.         g_iDmg[iAttacker] = 0
  134.        
  135.         set_dhudmessage(34, 138, 255, -1.0, 0.25, 2, 6.0, 3.0, 0.1, 1.5)
  136.         show_dhudmessage(iAttacker, "%s Has been Freezed!", szName)
  137.     }
  138.     return HC_CONTINUE
  139. }
  140.  
  141. public CheckModel(id)
  142. {
  143.     if (is_user_alive(id))
  144.     {
  145.         set_pev(id, pev_viewmodel2, V_M4A1_MODEL)
  146.         set_pev(id, pev_weaponmodel2, P_M4A1_MODEL)
  147.     }
  148.     return PLUGIN_CONTINUE
  149. }
  150.  
  151. public CurrentWeapon(id)
  152. {
  153.     if ((get_user_weapon(id) == CSW_M4A1) && g_bHasFrostM4A1[id] == true)
  154.     {
  155.         CheckModel(id)
  156.     }
  157.     else
  158.     {
  159.         ClearSyncHud(id, g_iHudSync)
  160.     }
  161.     return PLUGIN_CONTINUE
  162. }
  163.  
  164. make_beam(const origin2[3], const origin[3], sprite, red, green, blue, alpha)
  165. {
  166.     //BEAMENTPOINTS
  167.     message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
  168.     write_byte (0) //TE_BEAMENTPOINTS 0
  169.     write_coord(origin2[0])
  170.     write_coord(origin2[1])
  171.     write_coord(origin2[2])
  172.     write_coord(origin[0])
  173.     write_coord(origin[1])
  174.     write_coord(origin[2])
  175.     write_short(sprite) // sprite
  176.     write_byte(1) // framestart
  177.     write_byte(5) // framerate
  178.     write_byte(2) // life
  179.     write_byte(20) // width
  180.     write_byte(0) // noise
  181.     write_byte(red) // r, g, b
  182.     write_byte(green) // r, g, b
  183.     write_byte(blue) // r, g, b
  184.     write_byte(alpha) // brightness
  185.     write_byte(150) // speed
  186.     message_end()
  187. }
  188.  
  189. public Fw_SetModel(entity, model[])
  190. {
  191.    
  192.     if(!is_valid_ent(entity))
  193.         return FMRES_IGNORED
  194.  
  195.     if(!equali(model, W_OLD_M4A1_MODEL))
  196.         return FMRES_IGNORED
  197.  
  198.     new className[33]
  199.     entity_get_string(entity, EV_SZ_classname, className, 32)
  200.  
  201.     static iOwner, iStoredM4A1ID
  202.  
  203.     // Frost M4A1 Owner
  204.     iOwner = entity_get_edict(entity, EV_ENT_owner)
  205.  
  206.     // Get drop weapon index (Frost M4A1) to use in fw_FrostM4A1AddToPlayer forward
  207.     iStoredM4A1ID = find_ent_by_owner(-1, "weapon_m4a1", entity)
  208.  
  209.     // If Player Has Frost M4A1 and It's weapon_m4a1
  210.     if(g_bHasFrostM4A1[iOwner] && is_valid_ent(iStoredM4A1ID))
  211.     {
  212.         // Setting weapon options
  213.         entity_set_int(iStoredM4A1ID, EV_INT_impulse, 1997)
  214.  
  215.         // Rest Var
  216.         g_bHasFrostM4A1[iOwner] = false
  217.        
  218.         // Set weaponbox new model
  219.         entity_set_model(entity, W_M4A1_MODEL)
  220.         return FMRES_SUPERCEDE
  221.     }
  222.     return FMRES_IGNORED
  223. }
  224.  
  225. public Fw_AddFrostM4A1ToPlayer(FrostM4A1, id)
  226. {
  227.     // Make sure that this is M4A1
  228.     if(is_valid_ent(FrostM4A1) && is_user_connected(id) && entity_get_int(FrostM4A1, EV_INT_impulse) == 1997)
  229.     {
  230.         // Update Var
  231.         g_bHasFrostM4A1[id] = true
  232.  
  233.         // Reset weapon options
  234.         entity_set_int(FrostM4A1, EV_INT_impulse, 0)
  235.         return HAM_HANDLED
  236.     }
  237.     return HAM_IGNORED
  238. }

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

#5

Post by Raheem » 5 years ago

OH, i don't notice this i just copied and pasted it. Don't know that this is id and this is player. Anyway [mention]Mark[/mention] did it :)
He who fails to plan is planning to fail

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 3 guests