Add gun to level_system

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

Add gun to level_system

#1

Post by czirimbolo » 5 years ago

Hello, can someone show me how to add a gun to my level system? Example: I would like to add JETPACK for players who have 40 level

here is jetpack.sma

Code: Select all

#include <zombie_escape>
#include <engine>
 
#define JETPACK_COST 1000
 
new const ClassInfoTarget[] = "info_target"
new const ClassBreakAble[] = "func_breakable"
new const ClassnameJetPack[] = "n4d_jetpack"
new const ClassnameRocket[] = "n4d_bazooka"
new const ModelVJetPack[] = "models/mu/v_jp_mu.mdl"
new const ModelPJetPack[] = "models/mu/p_jp_mu.mdl"
new const ModelWJetPack[] = "models/mu/w_jp_mu.mdl"
new const ModelRocket[] = "models/rpgrocket.mdl"
new const SoundPickup[] = "items/gunpickup2.wav"
new const SoundShoot[] = "mu/at4-1.wav"
new const SoundTravel[] = "mu/bfuu.wav"
new const SoundFly[] = "mu/fly.wav"
new const SoundBlow[] = "mu/blow.wav"
 
new bool:bHasJetPack[33]
new Float:fJetpackFuel[33]
new Float:fLastShoot[33]
new SprExp, SprTrail, ItemJetPack
new CvarMaxFuel, CvarRadius, CvarDamage, CvarSpeed, CvarCooldown, CvarRegen, CvarRocketSpeed, CvarRemove
new Float:CMaxFuel, Float:CRadius, Float:CDamage, CSpeed, Float:CCooldown, Float:CRegen, CRocketSpeed, Float:CRemove
new bool:g_bBlockBuy
 
//Uncomment this to draw ring effect
//#define DrawRing
 
//Uncomment this to draw flame effect
//#define DrawFlame
 
#if defined DrawRing
new SprRing
#endif
 
#if defined DrawFlame
new SprFlame
#endif
 
public plugin_precache()
{
    precache_sound(SoundPickup)
    precache_sound(SoundShoot)
    precache_sound(SoundTravel)
    precache_sound(SoundFly)
    precache_sound(SoundBlow)
   
    SprExp = precache_model("sprites/zerogxplode.spr")
    SprTrail = precache_model("sprites/smoke.spr")
   
    #if defined DrawFlame
    SprFlame = precache_model("sprites/xfireball3.spr")
    #endif
   
    #if defined DrawRing
    SprRing = precache_model("sprites/shockwave.spr")
    #endif
   
    precache_model(ModelVJetPack)
    precache_model(ModelPJetPack)
    precache_model(ModelWJetPack)
    precache_model(ModelRocket)
}
 
public plugin_init()
{
    register_plugin("New Jetpack", "0.0.3", "Bad_Bud,ZmOutStanding,Connor,wbyokomo")
   
    register_event("HLTV", "OnNewRound", "a", "1=0", "2=0")
    register_logevent("OnRoundEnd", 2, "1=Round_End")
   
    RegisterHam(Ham_Killed, "player", "OnPlayerKilled")
    RegisterHam(Ham_Player_Jump, "player", "OnPlayerJump")
    RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_knife", "OnKnifeSecAtkPost", 1)
    RegisterHam(Ham_Item_Deploy, "weapon_knife", "OnKnifeDeployPost", 1)
   
    register_forward(FM_PlayerPreThink, "OnPlayerPreThink")
   
    register_touch(ClassnameRocket, "*", "OnTouchRocket")
    register_touch(ClassnameJetPack, "player", "OnTouchJetPack")
    register_think(ClassnameJetPack, "OnThinkJetPack")
   
    CvarMaxFuel = register_cvar("jp_maxfuel", "250.0")
    CvarRadius = register_cvar("jp_radius", "250.0")
    CvarDamage = register_cvar("jp_damage", "600.0")
    CvarSpeed = register_cvar("jp_speed", "300")
    CvarCooldown = register_cvar("jp_cooldown", "10.0")
    CvarRegen = register_cvar("jp_regen", "0.5")
    CvarRocketSpeed = register_cvar("jp_rocket_speed", "1500")
    CvarRemove = register_cvar("jp_remove_time", "420.0")
 
    ItemJetPack = ze_register_item("Jetpack", JETPACK_COST, 0)
   
    register_clcmd("drop", "CmdDropJP")
}
 
public client_putinserver(id)
{
    ResetValues(id)
}
 
public ze_user_infected(iVictim)
{
    ResetValues(iVictim)
}
 
public client_disconnected(id)
{
    ResetValues(id)
}
 
public ze_game_started()
{
    g_bBlockBuy = true
    set_task(20.0, "EnableBuy")
}
 
public EnableBuy()
{
    g_bBlockBuy = false
}
 
public OnNewRound()
{
    RemoveAllJetPack()
    CMaxFuel = get_pcvar_float(CvarMaxFuel)
    CRadius = get_pcvar_float(CvarRadius)
    CDamage = get_pcvar_float(CvarDamage)
    CSpeed = get_pcvar_num(CvarSpeed)
    CCooldown = get_pcvar_float(CvarCooldown)
    CRegen = get_pcvar_float(CvarRegen)
    CRocketSpeed = get_pcvar_num(CvarRocketSpeed)
    CRemove = get_pcvar_float(CvarRemove)
}
 
public ze_user_humanized(id)
{
    ResetValues(id) // Item lasts only one round
}
 
public OnRoundEnd()
{
    RemoveAllJetPack()
}
 
public OnPlayerKilled(id)
{
    if(bHasJetPack[id]) DropJetPack(id);
   
    ResetValues(id)
}
 
public OnPlayerJump(id)
{
    if(bHasJetPack[id] && fJetpackFuel[id] > 0.0 && get_user_weapon(id) == CSW_KNIFE && pev(id, pev_button) & IN_DUCK && ~pev(id, pev_flags) & FL_ONGROUND)
    {
        static Float:vVelocity[3], Float:upSpeed
        pev(id, pev_velocity, vVelocity)
        upSpeed = vVelocity[2] + 35.0
        velocity_by_aim(id, CSpeed, vVelocity)
        vVelocity[2] = upSpeed > 300.0 ? 300.0 : upSpeed
        set_pev(id, pev_velocity, vVelocity)
       
        #if defined DrawFlame
        pev(id, pev_origin, vVelocity)
        engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vVelocity, 0)
        write_byte(TE_SPRITE)
        engfunc(EngFunc_WriteCoord, vVelocity[0])
        engfunc(EngFunc_WriteCoord, vVelocity[1])
        engfunc(EngFunc_WriteCoord, vVelocity[2])
        write_short(SprFlame)
        write_byte(8)
        write_byte(128)
        message_end()
        #endif
       
        fJetpackFuel[id] > 80.0 ? emit_sound(id, CHAN_STREAM, SoundFly, VOL_NORM, ATTN_NORM, 0,  PITCH_NORM) : emit_sound(id, CHAN_STREAM, SoundBlow, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
        fJetpackFuel[id] -= 1.0
    }
}
 
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 != ItemJetPack)
        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
 
    if (bHasJetPack[id])
        return ZE_ITEM_UNAVAILABLE
   
    if (g_bBlockBuy && itemid == ItemJetPack)
        return ZE_ITEM_UNAVAILABLE
   
    return ZE_ITEM_AVAILABLE
}
 
 
public ze_select_item_post(id, item)
{
    if (item == ItemJetPack)
    {
        bHasJetPack[id] = true
        ze_colored_print(id, "JetPack usage: JUMP+DUCK")
        engclient_cmd(id, "weapon_knife")
        ReplaceModel(id)
    }
}
 
public OnKnifeSecAtkPost(ent2)
{
    if(pev_valid(ent2) == 2)
    {
        static id, Float:ctime
        id = get_pdata_cbase(ent2, 41, 4)
        ctime = get_gametime()
        if(is_user_alive(id) && bHasJetPack[id] && fLastShoot[id] < ctime)
        {
            new ent = create_entity(ClassInfoTarget)
            if(ent)
            {
                engfunc(EngFunc_SetModel, ent, ModelRocket)
                engfunc(EngFunc_SetSize, ent, Float:{0.0, 0.0, 0.0}, Float:{0.0, 0.0, 0.0})
                new Float:fOrigin[3]
                pev(id, pev_origin, fOrigin)
                fOrigin[2] += 16.0
                engfunc(EngFunc_SetOrigin, ent, fOrigin)
                set_pev(ent, pev_classname, ClassnameRocket)
                set_pev(ent, pev_dmg, 100.0)
                set_pev(ent, pev_owner, id)
                velocity_by_aim(id, CRocketSpeed, fOrigin)
                set_pev(ent, pev_velocity, fOrigin)
                new Float:vecAngles[3]
                engfunc(EngFunc_VecToAngles, fOrigin, vecAngles)
                set_pev(ent, pev_angles, vecAngles)
                set_pev(ent, pev_movetype, MOVETYPE_FLY)
                set_pev(ent, pev_effects, EF_LIGHT)
                set_pev(ent, pev_solid, SOLID_BBOX)
               
                emit_sound(id, CHAN_STATIC, SoundShoot, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
                emit_sound(ent, CHAN_WEAPON, SoundTravel, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
               
                message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
                write_byte(TE_BEAMFOLLOW)
                write_short(ent)
                write_short(SprTrail)
                write_byte(40)
                write_byte(5)
                write_byte(224)
                write_byte(224)
                write_byte(255)
                write_byte(192)
                message_end()
               
                fLastShoot[id] = ctime+CCooldown
            }
            else
            {
                client_print(id, print_chat, "[JpDebug] Failed to create rocket.")
                fLastShoot[id] = ctime+1.5
            }
        }
    }
}
 
public OnKnifeDeployPost(ent)
{
    if(pev_valid(ent) == 2)
    {
        static id; id = get_pdata_cbase(ent, 41, 4)
        if(is_user_alive(id) && bHasJetPack[id]) ReplaceModel(id);
    }
}
 
public OnPlayerPreThink(id)
{
    if(bHasJetPack[id] && fJetpackFuel[id] < CMaxFuel)
    {
        static button; button = pev(id, pev_button)
        if(!(button & IN_DUCK) && !(button & IN_JUMP)) fJetpackFuel[id] += CRegen;
    }
}
 
public OnTouchRocket(ent, id)
{
    static Float:fOrigin[3]
    pev(ent, pev_origin, fOrigin)
   
    engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, fOrigin, 0)
    write_byte(TE_EXPLOSION)
    engfunc(EngFunc_WriteCoord, fOrigin[0])
    engfunc(EngFunc_WriteCoord, fOrigin[1])
    engfunc(EngFunc_WriteCoord, fOrigin[2])
    write_short(SprExp)
    write_byte(40)
    write_byte(30)
    write_byte(10)
    message_end()
   
    #if defined DrawRing
    engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, fOrigin, 0)
    write_byte(TE_BEAMCYLINDER)
    engfunc(EngFunc_WriteCoord, fOrigin[0])
    engfunc(EngFunc_WriteCoord, fOrigin[1])
    engfunc(EngFunc_WriteCoord, fOrigin[2])
    engfunc(EngFunc_WriteCoord, fOrigin[0])
    engfunc(EngFunc_WriteCoord, fOrigin[1])
    engfunc(EngFunc_WriteCoord, fOrigin[2]+555.0)
    write_short(SprRing)
    write_byte(0)
    write_byte(1)
    write_byte(6)
    write_byte(8)
    write_byte(10)
    write_byte(224)
    write_byte(224)
    write_byte(255)
    write_byte(192)
    write_byte(5)
    message_end()
    #endif
   
    static attacker; attacker = pev(ent, pev_owner)
    if(!is_user_connected(attacker))
    {
        engfunc(EngFunc_RemoveEntity, ent)
        return PLUGIN_CONTINUE;
    }
   
    if(pev_valid(id) && !is_user_connected(id))
    {
        static szClassname[32]
        pev(id, pev_classname, szClassname, 31)
        if(equal(szClassname, ClassBreakAble) && (pev(id, pev_solid) != SOLID_NOT))
        {
            dllfunc(DLLFunc_Use, id, ent)
        }
    }
   
    static victim; victim = -1
    while((victim = engfunc(EngFunc_FindEntityInSphere, victim, fOrigin, CRadius)) != 0)
    {
        if(is_user_alive(victim) && ze_is_user_zombie(victim))
        {
            static Float:originV[3], Float:dist, Float:damage
            pev(victim, pev_origin, originV)
            dist = get_distance_f(fOrigin, originV)
            damage = CDamage-(CDamage/CRadius)*dist
            if(damage > 0.0)
            {
                ExecuteHamB(Ham_TakeDamage, victim, ent, attacker, damage, DMG_BULLET)
                //client_print(attacker, print_chat, "[Jp] Rocket damage: %.1f", damage)
            }
        }
    }
   
    engfunc(EngFunc_RemoveEntity, ent)
   
    return PLUGIN_CONTINUE;
}
 
public OnTouchJetPack(ent, id)
{
    if((pev(ent, pev_iuser4) != 11111) && is_user_alive(id) && !ze_is_user_zombie(id) && !bHasJetPack[id])
    {
        engfunc(EngFunc_RemoveEntity, ent)
        bHasJetPack[id] = true
        emit_sound(id, CHAN_STATIC, SoundPickup, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
        engclient_cmd(id,"weapon_knife")
        ReplaceModel(id)
    }
}
 
public OnThinkJetPack(ent)
{
    if(pev_valid(ent) == 2)
    {
        switch(pev(ent, pev_flTimeStepSound))
        {
            case 200:
            {
                set_pev(ent, pev_iuser4, 22222)
                set_pev(ent, pev_flTimeStepSound, 201)
                set_pev(ent, pev_nextthink, get_gametime()+CRemove)
            }
            case 201:
            {
                engfunc(EngFunc_RemoveEntity, ent)
            }
        }
    }
}
 
public CmdDropJP(id)
{
    if(is_user_alive(id) && bHasJetPack[id] && get_user_weapon(id) == CSW_KNIFE)
    {
        DropJetPack(id)
        bHasJetPack[id] = false
        set_pev(id, pev_viewmodel2, "models/v_knife.mdl")
        set_pev(id, pev_weaponmodel2, "models/p_knife.mdl")
        return PLUGIN_HANDLED;
    }
   
    return PLUGIN_CONTINUE;
}
 
ReplaceModel(id)
{
    set_pev(id, pev_viewmodel2, ModelVJetPack)
    set_pev(id, pev_weaponmodel2, ModelPJetPack)
}
 
DropJetPack(id)
{
    new ent = create_entity(ClassInfoTarget)
    if(!ent) return;
   
    engfunc(EngFunc_SetModel, ent, ModelWJetPack)
    engfunc(EngFunc_SetSize, ent, Float:{-8.0, -8.0, -8.0}, Float:{8.0, 8.0, 8.0})
    new Float:fOrigin[3]
    pev(id, pev_origin, fOrigin)
    fOrigin[2] += 16.0
    engfunc(EngFunc_SetOrigin, ent, fOrigin)
    set_pev(ent, pev_classname, ClassnameJetPack)
    velocity_by_aim(id, 800, fOrigin) //if it too far then reduce it
    set_pev(ent, pev_velocity, fOrigin)
    set_pev(ent, pev_movetype, MOVETYPE_TOSS)
    set_pev(ent, pev_effects, EF_LIGHT)
    set_pev(ent, pev_iuser4, 11111)
    set_pev(ent, pev_solid, SOLID_TRIGGER)
    set_pev(ent, pev_flTimeStepSound, 200)
    set_pev(ent, pev_nextthink, get_gametime()+2.0) // prevent drop/pickup exploit
}
 
RemoveAllJetPack()
{
    new ent = engfunc(EngFunc_FindEntityByString, -1, "classname", ClassnameJetPack)
    while(ent > 0)
    {
        engfunc(EngFunc_RemoveEntity, ent)
        ent = engfunc(EngFunc_FindEntityByString, -1, "classname", ClassnameJetPack)
    }
}
 
ResetValues(id)
{
    bHasJetPack[id] = false
    fJetpackFuel[id] = CMaxFuel
}
here is my weapon menu:

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

// 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: 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, "Golden AK-47")
				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) // Golden Ak-47
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 30 Unlock\w: \yGolden AK-47^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) // Golden AK47
	{
		give_golden_ak47(id)
		g_bBoughtPrimary[id] = true
		return true;
	}
	
	static szWeaponName[32]
	ArrayGetString(g_szPrimaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
	new iWeaponId = get_weaponid(szWeaponName)
	
	// Strip and Give Full Weapon
	rg_give_item(id, szWeaponName, GT_REPLACE)
	rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
	
	// Primary bought
	g_bBoughtPrimary[id] = true
	return true;
}

public Menu_Buy_Secondary(id, key)
{
	// Player dead or zombie or already bought secondary
	if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtSecondary[id])
		return PLUGIN_HANDLED
	
	// Special keys / weapon list exceeded
	if (key >= ArraySize(g_szSecondaryWeapons))
	{
		// Toggle autoselect
		if (key == MENU_KEY_AUTOSELECT)
			WPN_AUTO_ON = 1 - WPN_AUTO_ON
		
		// Reshow menu unless user exited
		if (key != MENU_KEY_EXIT)
			Show_Menu_Buy_Secondary(id)
		
		return PLUGIN_HANDLED
	}
	
	// Store selected weapon id
	WPN_AUTO_SEC = key
	
	// Buy secondary weapon
	Buy_Secondary_Weapon(id, key)
	
	return PLUGIN_HANDLED
}

public Buy_Secondary_Weapon(id, selection)
{
	if ( ((selection == 2) && (ze_get_user_level(id) < 1)) ||
	((selection == 3) && (ze_get_user_level(id) < 2)) ||
	((selection == 4) && (ze_get_user_level(id) < 3)) ||
	((selection == 5) && (ze_get_user_level(id) < 4)) )
	{
		Show_Menu_Buy_Secondary(id)
		return;
	}

	static szWeaponName[32]
	ArrayGetString(g_szSecondaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
	new iWeaponId = get_weaponid(szWeaponName)
	
	// Strip and Give Full Weapon
	rg_give_item(id, szWeaponName, GT_REPLACE)
	rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
	
	// Secondary bought
	g_bBoughtSecondary[id] = true
}

public Fw_TouchWeapon_Pre(iEnt, id)
{
	if (get_pcvar_num(g_pCvarBlockWeapLowLevel) == 0)
		return HAM_IGNORED;
	
	// Not alive or Not Valid Weapon?
	if(!is_user_alive(id) || !pev_valid(iEnt))
		return HAM_IGNORED;
	
	// Get Weapon Model
	new szWeapModel[32]
	pev(iEnt, pev_model, szWeapModel, charsmax(szWeapModel))
	
	// Remove "models/w_" and ".mdl"
	copyc(szWeapModel, charsmax(szWeapModel), szWeapModel[contain(szWeapModel, "_" ) + 1], '.')
	
	// Set for mp5 to be same as "weapon_mp5navy"
	if(szWeapModel[1] == 'p' && szWeapModel[2] == '5')
		szWeapModel = "mp5navy"
	
	// Add "weapon_" to all model names
	static szWeaponEnt[32]
	formatex(szWeaponEnt, charsmax(szWeaponEnt), "weapon_%s", szWeapModel)

	// Get it's index in Weapon Array
	new iIndex, i
	
	// I won't explain the blew code if you need to understand ask me in Escapers-Zone.XYZ
	for (i = 0; i < ArraySize(g_szPrimaryWeapons); i++)
	{
		new szPrimaryWeapon[32]
		ArrayGetString(g_szPrimaryWeapons, i, szPrimaryWeapon, charsmax(szPrimaryWeapon))
		
		if (equali(szWeaponEnt, szPrimaryWeapon))
			iIndex = i
	}
	
	if (ze_get_user_level(id) == 0 && iIndex > 1)
	{
		return HAM_SUPERCEDE;
	}
	
	for (i = 1; i <= 11; i++)
	{
		if ((ze_get_user_level(id) == i) && iIndex > i+1)
		{
			return HAM_SUPERCEDE;
		}
	}
	
	return HAM_IGNORED;
}

// Natives
public native_ze_show_weapon_menu(id)
{
	if (!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
		return false
	}
	
	Cmd_Buy(id)
	return true
}

public native_ze_is_auto_buy_enabled(id)
{
	if (!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
		return -1;
	}
	
	return WPN_AUTO_ON;
}

public native_ze_disable_auto_buy(id)
{
	if (!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
		return false
	}
	
	WPN_AUTO_ON = 0;
	return true
}
Image

User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

#2

Post by Night Fury » 5 years ago

Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

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

#3

Post by czirimbolo » 5 years ago

Ok can you show me how to edit wepon menu and what should I change in gun's code?
Image

User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

#4

Post by Night Fury » 5 years ago

czirimbolo wrote: 5 years ago Ok can you show me how to edit wepon menu and what should I change in gun's code?
If there are other versions of weapon menu already contains extra guns then edit it for your needs.
Also, that native i provided it to make your gun appear in extra items menu & will be available for people who have the submitted level.
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

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

#5

Post by Raheem » 5 years ago

Steps not static but the idea based on:

1. Make native in the item you need to add so we can give weapon from another plugin, and remove it from extra items menu.
2. Add the weapon to the weapons menu. There things to be edited
    1.     switch (ze_get_user_level(id))
    2.     {
    3.         case 0: WPN_MAXIDS[id] = 2
    4.         case 1: WPN_MAXIDS[id] = 3
    5.         case 2: WPN_MAXIDS[id] = 4
    6.         case 3: WPN_MAXIDS[id] = 5
    7.         case 4: WPN_MAXIDS[id] = 6
    8.         case 5: WPN_MAXIDS[id] = 7
    9.         case 6: WPN_MAXIDS[id] = 8
    10.         case 7: WPN_MAXIDS[id] = 9
    11.         case 8: WPN_MAXIDS[id] = 10
    12.         case 9: WPN_MAXIDS[id] = 11
    13.         case 10: WPN_MAXIDS[id] = 12
    14.         case 11: WPN_MAXIDS[id] = 13
    15.         case 12..14: WPN_MAXIDS[id] = 14
    16.         case 15..19: WPN_MAXIDS[id] = 15 // Golden m3
    17.         case 20..24: WPN_MAXIDS[id] = 16 // Golden MP5
    18.         case 25..29: WPN_MAXIDS[id] = 17 // Golden M4A1
    19.         case 30..39: WPN_MAXIDS[id] = 18 // Golden AK47
    20.         case 40: WPN_MAXIDS[id] = 19    // JatPack
    21.     }
    1.         // JetPack
    2.         if (ze_get_user_level(id) >= 40)
    3.         {
    4.             if (iIndex == 14)
    5.             {
    6.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M3")
    7.             }
    8.            
    9.             if (iIndex == 15)
    10.             {
    11.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
    12.             }
    13.            
    14.             if (iIndex == 16)
    15.             {
    16.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
    17.             }
    18.            
    19.             if (iIndex == 17)
    20.             {
    21.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK-47")
    22.             }
    23.            
    24.             if (iIndex == 18)
    25.             {
    26.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "JetPack")
    27.                 break;
    28.             }
    29.         }
    1.     else if (ze_get_user_level(id) >= 30 && ze_get_user_level(id) < 40) // JetPack
    2.     {
    3.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 40 Unlock\w: \yJetPack^n")
    4.     }
So finally, jectpack:
    1. #include <zombie_escape>
    2. #include <engine>
    3.  
    4. #define JETPACK_COST 1000
    5.  
    6. new const ClassInfoTarget[] = "info_target"
    7. new const ClassBreakAble[] = "func_breakable"
    8. new const ClassnameJetPack[] = "n4d_jetpack"
    9. new const ClassnameRocket[] = "n4d_bazooka"
    10. new const ModelVJetPack[] = "models/mu/v_jp_mu.mdl"
    11. new const ModelPJetPack[] = "models/mu/p_jp_mu.mdl"
    12. new const ModelWJetPack[] = "models/mu/w_jp_mu.mdl"
    13. new const ModelRocket[] = "models/rpgrocket.mdl"
    14. new const SoundPickup[] = "items/gunpickup2.wav"
    15. new const SoundShoot[] = "mu/at4-1.wav"
    16. new const SoundTravel[] = "mu/bfuu.wav"
    17. new const SoundFly[] = "mu/fly.wav"
    18. new const SoundBlow[] = "mu/blow.wav"
    19.  
    20. new bool:bHasJetPack[33]
    21. new Float:fJetpackFuel[33]
    22. new Float:fLastShoot[33]
    23. new SprExp, SprTrail
    24. new CvarMaxFuel, CvarRadius, CvarDamage, CvarSpeed, CvarCooldown, CvarRegen, CvarRocketSpeed, CvarRemove
    25. new Float:CMaxFuel, Float:CRadius, Float:CDamage, CSpeed, Float:CCooldown, Float:CRegen, CRocketSpeed, Float:CRemove
    26.  
    27. //Uncomment this to draw ring effect
    28. //#define DrawRing
    29.  
    30. //Uncomment this to draw flame effect
    31. //#define DrawFlame
    32.  
    33. #if defined DrawRing
    34. new SprRing
    35. #endif
    36.  
    37. #if defined DrawFlame
    38. new SprFlame
    39. #endif
    40.  
    41. public plugin_precache()
    42. {
    43.     precache_sound(SoundPickup)
    44.     precache_sound(SoundShoot)
    45.     precache_sound(SoundTravel)
    46.     precache_sound(SoundFly)
    47.     precache_sound(SoundBlow)
    48.    
    49.     SprExp = precache_model("sprites/zerogxplode.spr")
    50.     SprTrail = precache_model("sprites/smoke.spr")
    51.    
    52.     #if defined DrawFlame
    53.     SprFlame = precache_model("sprites/xfireball3.spr")
    54.     #endif
    55.    
    56.     #if defined DrawRing
    57.     SprRing = precache_model("sprites/shockwave.spr")
    58.     #endif
    59.    
    60.     precache_model(ModelVJetPack)
    61.     precache_model(ModelPJetPack)
    62.     precache_model(ModelWJetPack)
    63.     precache_model(ModelRocket)
    64. }
    65.  
    66. public plugin_natives()
    67. {
    68.     register_native("ze_give_jetpack", "native_ze_give_jetpack", 1)
    69. }
    70.  
    71. public plugin_init()
    72. {
    73.     register_plugin("New Jetpack", "0.0.3", "Bad_Bud,ZmOutStanding,Connor,wbyokomo")
    74.    
    75.     register_event("HLTV", "OnNewRound", "a", "1=0", "2=0")
    76.     register_logevent("OnRoundEnd", 2, "1=Round_End")
    77.    
    78.     RegisterHam(Ham_Killed, "player", "OnPlayerKilled")
    79.     RegisterHam(Ham_Player_Jump, "player", "OnPlayerJump")
    80.     RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_knife", "OnKnifeSecAtkPost", 1)
    81.     RegisterHam(Ham_Item_Deploy, "weapon_knife", "OnKnifeDeployPost", 1)
    82.    
    83.     register_forward(FM_PlayerPreThink, "OnPlayerPreThink")
    84.    
    85.     register_touch(ClassnameRocket, "*", "OnTouchRocket")
    86.     register_touch(ClassnameJetPack, "player", "OnTouchJetPack")
    87.     register_think(ClassnameJetPack, "OnThinkJetPack")
    88.    
    89.     CvarMaxFuel = register_cvar("jp_maxfuel", "250.0")
    90.     CvarRadius = register_cvar("jp_radius", "250.0")
    91.     CvarDamage = register_cvar("jp_damage", "600.0")
    92.     CvarSpeed = register_cvar("jp_speed", "300")
    93.     CvarCooldown = register_cvar("jp_cooldown", "10.0")
    94.     CvarRegen = register_cvar("jp_regen", "0.5")
    95.     CvarRocketSpeed = register_cvar("jp_rocket_speed", "1500")
    96.     CvarRemove = register_cvar("jp_remove_time", "420.0")
    97.    
    98.     register_clcmd("drop", "CmdDropJP")
    99. }
    100.  
    101. public native_ze_give_jetpack(id)
    102. {
    103.     bHasJetPack[id] = true
    104.     ze_colored_print(id, "JetPack usage: JUMP+DUCK")
    105.     engclient_cmd(id, "weapon_knife")
    106.     ReplaceModel(id)
    107. }
    108.  
    109. public client_putinserver(id)
    110. {
    111.     ResetValues(id)
    112. }
    113.  
    114. public ze_user_infected(iVictim)
    115. {
    116.     ResetValues(iVictim)
    117. }
    118.  
    119. public client_disconnected(id)
    120. {
    121.     ResetValues(id)
    122. }
    123.  
    124. public OnNewRound()
    125. {
    126.     RemoveAllJetPack()
    127.     CMaxFuel = get_pcvar_float(CvarMaxFuel)
    128.     CRadius = get_pcvar_float(CvarRadius)
    129.     CDamage = get_pcvar_float(CvarDamage)
    130.     CSpeed = get_pcvar_num(CvarSpeed)
    131.     CCooldown = get_pcvar_float(CvarCooldown)
    132.     CRegen = get_pcvar_float(CvarRegen)
    133.     CRocketSpeed = get_pcvar_num(CvarRocketSpeed)
    134.     CRemove = get_pcvar_float(CvarRemove)
    135. }
    136.  
    137. public ze_user_humanized(id)
    138. {
    139.     ResetValues(id) // Item lasts only one round
    140. }
    141.  
    142. public OnRoundEnd()
    143. {
    144.     RemoveAllJetPack()
    145. }
    146.  
    147. public OnPlayerKilled(id)
    148. {
    149.     if(bHasJetPack[id]) DropJetPack(id);
    150.    
    151.     ResetValues(id)
    152. }
    153.  
    154. public OnPlayerJump(id)
    155. {
    156.     if(bHasJetPack[id] && fJetpackFuel[id] > 0.0 && get_user_weapon(id) == CSW_KNIFE && pev(id, pev_button) & IN_DUCK && ~pev(id, pev_flags) & FL_ONGROUND)
    157.     {
    158.         static Float:vVelocity[3], Float:upSpeed
    159.         pev(id, pev_velocity, vVelocity)
    160.         upSpeed = vVelocity[2] + 35.0
    161.         velocity_by_aim(id, CSpeed, vVelocity)
    162.         vVelocity[2] = upSpeed > 300.0 ? 300.0 : upSpeed
    163.         set_pev(id, pev_velocity, vVelocity)
    164.        
    165.         #if defined DrawFlame
    166.         pev(id, pev_origin, vVelocity)
    167.         engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vVelocity, 0)
    168.         write_byte(TE_SPRITE)
    169.         engfunc(EngFunc_WriteCoord, vVelocity[0])
    170.         engfunc(EngFunc_WriteCoord, vVelocity[1])
    171.         engfunc(EngFunc_WriteCoord, vVelocity[2])
    172.         write_short(SprFlame)
    173.         write_byte(8)
    174.         write_byte(128)
    175.         message_end()
    176.         #endif
    177.        
    178.         fJetpackFuel[id] > 80.0 ? emit_sound(id, CHAN_STREAM, SoundFly, VOL_NORM, ATTN_NORM, 0,  PITCH_NORM) : emit_sound(id, CHAN_STREAM, SoundBlow, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
    179.         fJetpackFuel[id] -= 1.0
    180.     }
    181. }
    182.  
    183. public OnKnifeSecAtkPost(ent2)
    184. {
    185.     if(pev_valid(ent2) == 2)
    186.     {
    187.         static id, Float:ctime
    188.         id = get_pdata_cbase(ent2, 41, 4)
    189.         ctime = get_gametime()
    190.         if(is_user_alive(id) && bHasJetPack[id] && fLastShoot[id] < ctime)
    191.         {
    192.             new ent = create_entity(ClassInfoTarget)
    193.             if(ent)
    194.             {
    195.                 engfunc(EngFunc_SetModel, ent, ModelRocket)
    196.                 engfunc(EngFunc_SetSize, ent, Float:{0.0, 0.0, 0.0}, Float:{0.0, 0.0, 0.0})
    197.                 new Float:fOrigin[3]
    198.                 pev(id, pev_origin, fOrigin)
    199.                 fOrigin[2] += 16.0
    200.                 engfunc(EngFunc_SetOrigin, ent, fOrigin)
    201.                 set_pev(ent, pev_classname, ClassnameRocket)
    202.                 set_pev(ent, pev_dmg, 100.0)
    203.                 set_pev(ent, pev_owner, id)
    204.                 velocity_by_aim(id, CRocketSpeed, fOrigin)
    205.                 set_pev(ent, pev_velocity, fOrigin)
    206.                 new Float:vecAngles[3]
    207.                 engfunc(EngFunc_VecToAngles, fOrigin, vecAngles)
    208.                 set_pev(ent, pev_angles, vecAngles)
    209.                 set_pev(ent, pev_movetype, MOVETYPE_FLY)
    210.                 set_pev(ent, pev_effects, EF_LIGHT)
    211.                 set_pev(ent, pev_solid, SOLID_BBOX)
    212.                
    213.                 emit_sound(id, CHAN_STATIC, SoundShoot, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
    214.                 emit_sound(ent, CHAN_WEAPON, SoundTravel, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
    215.                
    216.                 message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    217.                 write_byte(TE_BEAMFOLLOW)
    218.                 write_short(ent)
    219.                 write_short(SprTrail)
    220.                 write_byte(40)
    221.                 write_byte(5)
    222.                 write_byte(224)
    223.                 write_byte(224)
    224.                 write_byte(255)
    225.                 write_byte(192)
    226.                 message_end()
    227.                
    228.                 fLastShoot[id] = ctime+CCooldown
    229.             }
    230.             else
    231.             {
    232.                 client_print(id, print_chat, "[JpDebug] Failed to create rocket.")
    233.                 fLastShoot[id] = ctime+1.5
    234.             }
    235.         }
    236.     }
    237. }
    238.  
    239. public OnKnifeDeployPost(ent)
    240. {
    241.     if(pev_valid(ent) == 2)
    242.     {
    243.         static id; id = get_pdata_cbase(ent, 41, 4)
    244.         if(is_user_alive(id) && bHasJetPack[id]) ReplaceModel(id);
    245.     }
    246. }
    247.  
    248. public OnPlayerPreThink(id)
    249. {
    250.     if(bHasJetPack[id] && fJetpackFuel[id] < CMaxFuel)
    251.     {
    252.         static button; button = pev(id, pev_button)
    253.         if(!(button & IN_DUCK) && !(button & IN_JUMP)) fJetpackFuel[id] += CRegen;
    254.     }
    255. }
    256.  
    257. public OnTouchRocket(ent, id)
    258. {
    259.     static Float:fOrigin[3]
    260.     pev(ent, pev_origin, fOrigin)
    261.    
    262.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, fOrigin, 0)
    263.     write_byte(TE_EXPLOSION)
    264.     engfunc(EngFunc_WriteCoord, fOrigin[0])
    265.     engfunc(EngFunc_WriteCoord, fOrigin[1])
    266.     engfunc(EngFunc_WriteCoord, fOrigin[2])
    267.     write_short(SprExp)
    268.     write_byte(40)
    269.     write_byte(30)
    270.     write_byte(10)
    271.     message_end()
    272.    
    273.     #if defined DrawRing
    274.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, fOrigin, 0)
    275.     write_byte(TE_BEAMCYLINDER)
    276.     engfunc(EngFunc_WriteCoord, fOrigin[0])
    277.     engfunc(EngFunc_WriteCoord, fOrigin[1])
    278.     engfunc(EngFunc_WriteCoord, fOrigin[2])
    279.     engfunc(EngFunc_WriteCoord, fOrigin[0])
    280.     engfunc(EngFunc_WriteCoord, fOrigin[1])
    281.     engfunc(EngFunc_WriteCoord, fOrigin[2]+555.0)
    282.     write_short(SprRing)
    283.     write_byte(0)
    284.     write_byte(1)
    285.     write_byte(6)
    286.     write_byte(8)
    287.     write_byte(10)
    288.     write_byte(224)
    289.     write_byte(224)
    290.     write_byte(255)
    291.     write_byte(192)
    292.     write_byte(5)
    293.     message_end()
    294.     #endif
    295.    
    296.     static attacker; attacker = pev(ent, pev_owner)
    297.     if(!is_user_connected(attacker))
    298.     {
    299.         engfunc(EngFunc_RemoveEntity, ent)
    300.         return PLUGIN_CONTINUE;
    301.     }
    302.    
    303.     if(pev_valid(id) && !is_user_connected(id))
    304.     {
    305.         static szClassname[32]
    306.         pev(id, pev_classname, szClassname, 31)
    307.         if(equal(szClassname, ClassBreakAble) && (pev(id, pev_solid) != SOLID_NOT))
    308.         {
    309.             dllfunc(DLLFunc_Use, id, ent)
    310.         }
    311.     }
    312.    
    313.     static victim; victim = -1
    314.     while((victim = engfunc(EngFunc_FindEntityInSphere, victim, fOrigin, CRadius)) != 0)
    315.     {
    316.         if(is_user_alive(victim) && ze_is_user_zombie(victim))
    317.         {
    318.             static Float:originV[3], Float:dist, Float:damage
    319.             pev(victim, pev_origin, originV)
    320.             dist = get_distance_f(fOrigin, originV)
    321.             damage = CDamage-(CDamage/CRadius)*dist
    322.             if(damage > 0.0)
    323.             {
    324.                 ExecuteHamB(Ham_TakeDamage, victim, ent, attacker, damage, DMG_BULLET)
    325.                 //client_print(attacker, print_chat, "[Jp] Rocket damage: %.1f", damage)
    326.             }
    327.         }
    328.     }
    329.    
    330.     engfunc(EngFunc_RemoveEntity, ent)
    331.    
    332.     return PLUGIN_CONTINUE;
    333. }
    334.  
    335. public OnTouchJetPack(ent, id)
    336. {
    337.     if((pev(ent, pev_iuser4) != 11111) && is_user_alive(id) && !ze_is_user_zombie(id) && !bHasJetPack[id])
    338.     {
    339.         engfunc(EngFunc_RemoveEntity, ent)
    340.         bHasJetPack[id] = true
    341.         emit_sound(id, CHAN_STATIC, SoundPickup, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
    342.         engclient_cmd(id,"weapon_knife")
    343.         ReplaceModel(id)
    344.     }
    345. }
    346.  
    347. public OnThinkJetPack(ent)
    348. {
    349.     if(pev_valid(ent) == 2)
    350.     {
    351.         switch(pev(ent, pev_flTimeStepSound))
    352.         {
    353.             case 200:
    354.             {
    355.                 set_pev(ent, pev_iuser4, 22222)
    356.                 set_pev(ent, pev_flTimeStepSound, 201)
    357.                 set_pev(ent, pev_nextthink, get_gametime()+CRemove)
    358.             }
    359.             case 201:
    360.             {
    361.                 engfunc(EngFunc_RemoveEntity, ent)
    362.             }
    363.         }
    364.     }
    365. }
    366.  
    367. public CmdDropJP(id)
    368. {
    369.     if(is_user_alive(id) && bHasJetPack[id] && get_user_weapon(id) == CSW_KNIFE)
    370.     {
    371.         DropJetPack(id)
    372.         bHasJetPack[id] = false
    373.         set_pev(id, pev_viewmodel2, "models/v_knife.mdl")
    374.         set_pev(id, pev_weaponmodel2, "models/p_knife.mdl")
    375.         return PLUGIN_HANDLED;
    376.     }
    377.    
    378.     return PLUGIN_CONTINUE;
    379. }
    380.  
    381. ReplaceModel(id)
    382. {
    383.     set_pev(id, pev_viewmodel2, ModelVJetPack)
    384.     set_pev(id, pev_weaponmodel2, ModelPJetPack)
    385. }
    386.  
    387. DropJetPack(id)
    388. {
    389.     new ent = create_entity(ClassInfoTarget)
    390.     if(!ent) return;
    391.    
    392.     engfunc(EngFunc_SetModel, ent, ModelWJetPack)
    393.     engfunc(EngFunc_SetSize, ent, Float:{-8.0, -8.0, -8.0}, Float:{8.0, 8.0, 8.0})
    394.     new Float:fOrigin[3]
    395.     pev(id, pev_origin, fOrigin)
    396.     fOrigin[2] += 16.0
    397.     engfunc(EngFunc_SetOrigin, ent, fOrigin)
    398.     set_pev(ent, pev_classname, ClassnameJetPack)
    399.     velocity_by_aim(id, 800, fOrigin) //if it too far then reduce it
    400.     set_pev(ent, pev_velocity, fOrigin)
    401.     set_pev(ent, pev_movetype, MOVETYPE_TOSS)
    402.     set_pev(ent, pev_effects, EF_LIGHT)
    403.     set_pev(ent, pev_iuser4, 11111)
    404.     set_pev(ent, pev_solid, SOLID_TRIGGER)
    405.     set_pev(ent, pev_flTimeStepSound, 200)
    406.     set_pev(ent, pev_nextthink, get_gametime()+2.0) // prevent drop/pickup exploit
    407. }
    408.  
    409. RemoveAllJetPack()
    410. {
    411.     new ent = engfunc(EngFunc_FindEntityByString, -1, "classname", ClassnameJetPack)
    412.     while(ent > 0)
    413.     {
    414.         engfunc(EngFunc_RemoveEntity, ent)
    415.         ent = engfunc(EngFunc_FindEntityByString, -1, "classname", ClassnameJetPack)
    416.     }
    417. }
    418.  
    419. ResetValues(id)
    420. {
    421.     bHasJetPack[id] = false
    422.     fJetpackFuel[id] = CMaxFuel
    423. }
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 give_golden_ak47(id);
    8. native ze_give_jetpack(id);
    9.  
    10. // Setting File
    11. new const ZE_SETTING_RESOURCES[] = "zombie_escape.ini"
    12.  
    13. // Keys
    14. 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
    15. const OFFSET_CSMENUCODE = 205
    16.  
    17. // Primary Weapons Entities [Default Values]
    18. new const szPrimaryWeaponEnt[][] =
    19. {
    20.     "weapon_xm1014",  // Level 0
    21.     "weapon_ump45",   // Level 0
    22.     "weapon_m3",      // Level 1
    23.     "weapon_mp5navy", // Level 2
    24.     "weapon_p90",     // Level 3
    25.     "weapon_galil",   // Level 4
    26.     "weapon_famas",   // Level 5
    27.     "weapon_sg550",   // Level 6
    28.     "weapon_g3sg1",   // Level 7
    29.     "weapon_m249",    // Level 8
    30.     "weapon_sg552",   // Level 9
    31.     "weapon_aug",     // Level 10
    32.     "weapon_m4a1",    // Level 11
    33.     "weapon_ak47"     // Level 12
    34. }
    35.  
    36. // Secondary Weapons Entities [Default Values]
    37. new const szSecondaryWeaponEnt[][]=
    38. {
    39.     "weapon_usp",         // Level 0
    40.     "weapon_p228",        // Level 0
    41.     "weapon_glock18",     // Level 1
    42.     "weapon_fiveseven",   // Level 2
    43.     "weapon_deagle",      // Level 3
    44.     "weapon_elite"        // Level 4
    45. }
    46.  
    47. // Primary and Secondary Weapons Names [Default Values]
    48. new const szWeaponNames[][] =
    49. {
    50.     "",
    51.     "P228",
    52.     "",
    53.     "Scout",
    54.     "HE Grenade",
    55.     "XM1014",
    56.     "",
    57.     "MAC-10",
    58.     "AUG",
    59.     "Smoke Grenade",
    60.     "Dual Elite",
    61.     "Five Seven",
    62.     "UMP 45",
    63.     "SG-550",
    64.     "Galil",
    65.     "Famas",
    66.     "USP",
    67.     "Glock",
    68.     "AWP",
    69.     "MP5",
    70.     "M249",
    71.     "M3",
    72.     "M4A1",
    73.     "TMP",
    74.     "G3SG1",
    75.     "Flashbang",
    76.     "Desert Eagle",
    77.     "SG-552",
    78.     "AK-47",
    79.     "",
    80.     "P90"
    81. }
    82.  
    83. // Max Back Clip Ammo (Change it From here if you need)
    84. new const szMaxBPAmmo[] =
    85. {
    86.     -1,
    87.     52,
    88.     -1,
    89.     90,
    90.     1,
    91.     32,
    92.     1,
    93.     100,
    94.     90,
    95.     1,
    96.     120,
    97.     100,
    98.     100,
    99.     90,
    100.     90,
    101.     90,
    102.     100,
    103.     120,
    104.     30,
    105.     120,
    106.     200,
    107.     32,
    108.     90,
    109.     120,
    110.     90,
    111.     2,
    112.     35,
    113.     90,
    114.     90,
    115.     -1,
    116.     100
    117. }
    118.  
    119. // Menu selections
    120. const MENU_KEY_AUTOSELECT = 7
    121. const MENU_KEY_BACK = 7
    122. const MENU_KEY_NEXT = 8
    123. const MENU_KEY_EXIT = 9
    124.  
    125. // Variables
    126. new Array:g_szPrimaryWeapons, Array:g_szSecondaryWeapons
    127.  
    128. new g_iMenuData[33][4],
    129.     Float:g_fBuyTimeStart[33],
    130.     bool:g_bBoughtPrimary[33],
    131.     bool:g_bBoughtSecondary[33],
    132.     WPN_MAXIDS[33]
    133.  
    134. // Define
    135. #define WPN_STARTID g_iMenuData[id][0]
    136. #define WPN_SELECTION (g_iMenuData[id][0]+key)
    137. #define WPN_AUTO_ON g_iMenuData[id][1]
    138. #define WPN_AUTO_PRI g_iMenuData[id][2]
    139. #define WPN_AUTO_SEC g_iMenuData[id][3]
    140.  
    141. // Cvars
    142. new g_pCvarBuyTime,
    143.     g_pCvarHeGrenade,
    144.     g_pCvarSmokeGrenade,
    145.     g_pCvarFlashGrenade,
    146.     g_pCvarBlockWeapLowLevel
    147.  
    148. public plugin_natives()
    149. {
    150.     register_native("ze_show_weapon_menu", "native_ze_show_weapon_menu", 1)
    151.     register_native("ze_is_auto_buy_enabled", "native_ze_is_auto_buy_enabled", 1)
    152.     register_native("ze_disable_auto_buy", "native_ze_disable_auto_buy", 1)
    153. }
    154.  
    155. public plugin_precache()
    156. {
    157.     // Initialize arrays (32 is the max length of Weapon Entity like: weapon_ak47)
    158.     g_szPrimaryWeapons = ArrayCreate(32, 1)
    159.     g_szSecondaryWeapons = ArrayCreate(32, 1)
    160.    
    161.     // Load from external file
    162.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
    163.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
    164.    
    165.     // If we couldn't load from file, use and save default ones
    166.    
    167.     new iIndex
    168.    
    169.     if (ArraySize(g_szPrimaryWeapons) == 0)
    170.     {
    171.         for (iIndex = 0; iIndex < sizeof szPrimaryWeaponEnt; iIndex++)
    172.             ArrayPushString(g_szPrimaryWeapons, szPrimaryWeaponEnt[iIndex])
    173.        
    174.         // If not found .ini File Create it and save default values in it
    175.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
    176.     }
    177.    
    178.     if (ArraySize(g_szSecondaryWeapons) == 0)
    179.     {
    180.         for (iIndex = 0; iIndex < sizeof szSecondaryWeaponEnt; iIndex++)
    181.             ArrayPushString(g_szSecondaryWeapons, szSecondaryWeaponEnt[iIndex])
    182.        
    183.         // If not found .ini File Create it and save default values in it
    184.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
    185.     }
    186. }
    187.  
    188. public plugin_init()
    189. {
    190.     register_plugin("[ZE] Levels Weapons Menu", "1.1", "Raheem")
    191.    
    192.     // Commands
    193.     register_clcmd("guns", "Cmd_Buy")
    194.     register_clcmd("say /enable", "Cmd_Enable")
    195.     register_clcmd("say_team /enable", "Cmd_Enable")
    196.    
    197.     // Cvars
    198.     g_pCvarBuyTime = register_cvar("ze_buy_time", "60")
    199.     g_pCvarHeGrenade = register_cvar("ze_give_HE_nade", "1") // 0 Nothing || 1 Give HE
    200.     g_pCvarSmokeGrenade = register_cvar("ze_give_SM_nade", "1")
    201.     g_pCvarFlashGrenade = register_cvar("ze_give_FB_nade", "1")
    202.     g_pCvarBlockWeapLowLevel = register_cvar("ze_block_weapons_lowlvl", "1")
    203.    
    204.     // Menus
    205.     register_menu("Primary Weapons", KEYSMENU, "Menu_Buy_Primary")
    206.     register_menu("Secondary Weapons", KEYSMENU, "Menu_Buy_Secondary")
    207.    
    208.     // Hams
    209.     RegisterHam(Ham_Touch, "weaponbox", "Fw_TouchWeapon_Pre", 0)
    210.     RegisterHam(Ham_Touch, "armoury_entity", "Fw_TouchWeapon_Pre", 0)
    211. }
    212.  
    213. public client_disconnected(id)
    214. {
    215.     WPN_AUTO_ON = 0
    216.     WPN_STARTID = 0
    217. }
    218.  
    219. public Cmd_Enable(id)
    220. {
    221.     if (WPN_AUTO_ON)
    222.     {
    223.         ze_colored_print(id, "%L", LANG_PLAYER, "BUY_ENABLED")
    224.         WPN_AUTO_ON = 0
    225.     }
    226. }
    227.  
    228. public Cmd_Buy(id)
    229. {
    230.     // Player Zombie
    231.     if (ze_is_user_zombie(id))
    232.     {
    233.         ze_colored_print(id, "%L", LANG_PLAYER, "NO_BUY_ZOMBIE")
    234.         return
    235.     }
    236.    
    237.     // Player Dead
    238.     if (!is_user_alive(id))
    239.     {
    240.         ze_colored_print(id, "%L", LANG_PLAYER, "DEAD_CANT_BUY_WEAPON")
    241.         return
    242.     }
    243.    
    244.     // Already bought
    245.     if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
    246.     {
    247.         ze_colored_print(id, "%L", LANG_PLAYER, "ALREADY_BOUGHT")
    248.     }
    249.    
    250.     Show_Available_Buy_Menus(id)
    251. }
    252.  
    253. public ze_user_humanized(id)
    254. {
    255.     // Static Values
    256.     switch (ze_get_user_level(id))
    257.     {
    258.         case 0: WPN_MAXIDS[id] = 2
    259.         case 1: WPN_MAXIDS[id] = 3
    260.         case 2: WPN_MAXIDS[id] = 4
    261.         case 3: WPN_MAXIDS[id] = 5
    262.         case 4: WPN_MAXIDS[id] = 6
    263.         case 5: WPN_MAXIDS[id] = 7
    264.         case 6: WPN_MAXIDS[id] = 8
    265.         case 7: WPN_MAXIDS[id] = 9
    266.         case 8: WPN_MAXIDS[id] = 10
    267.         case 9: WPN_MAXIDS[id] = 11
    268.         case 10: WPN_MAXIDS[id] = 12
    269.         case 11: WPN_MAXIDS[id] = 13
    270.         case 12..14: WPN_MAXIDS[id] = 14
    271.         case 15..19: WPN_MAXIDS[id] = 15 // Golden m3
    272.         case 20..24: WPN_MAXIDS[id] = 16 // Golden MP5
    273.         case 25..29: WPN_MAXIDS[id] = 17 // Golden M4A1
    274.         case 30..39: WPN_MAXIDS[id] = 18 // Golden AK47
    275.         case 40: WPN_MAXIDS[id] = 19    // JatPack
    276.     }
    277.    
    278.     if (ze_get_user_level(id) > 40)
    279.     {
    280.         WPN_MAXIDS[id] = 19
    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, "Golden M3")
    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, "Golden M3")
    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, "Golden M3")
    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, "Golden M3")
    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, "Golden AK-47")
    441.                 break;
    442.             }
    443.         }
    444.        
    445.         // JetPack
    446.         if (ze_get_user_level(id) >= 40)
    447.         {
    448.             if (iIndex == 14)
    449.             {
    450.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M3")
    451.             }
    452.            
    453.             if (iIndex == 15)
    454.             {
    455.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
    456.             }
    457.            
    458.             if (iIndex == 16)
    459.             {
    460.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
    461.             }
    462.            
    463.             if (iIndex == 17)
    464.             {
    465.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK-47")
    466.             }
    467.            
    468.             if (iIndex == 18)
    469.             {
    470.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "JetPack")
    471.                 break;
    472.             }
    473.         }
    474.        
    475.         // Must check if iIndex < 14 means max is AK47
    476.         if (iIndex < 14)
    477.         {
    478.             ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
    479.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, szWeaponNames[get_weaponid(szWeaponName)])
    480.         }
    481.     }
    482.    
    483.     if (iIndex < 7)
    484.     {
    485.         ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
    486.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    487.     }
    488.    
    489.     if (ze_get_user_level(id) == 5)
    490.     {
    491.         ArrayGetString(g_szPrimaryWeapons, 7, 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) == 6)
    495.     {
    496.         ArrayGetString(g_szPrimaryWeapons, 8, szWeaponName, charsmax(szWeaponName))
    497.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    498.     }
    499.     else if (ze_get_user_level(id) == 7)
    500.     {
    501.         ArrayGetString(g_szPrimaryWeapons, 9, szWeaponName, charsmax(szWeaponName))
    502.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    503.     }
    504.     else if (ze_get_user_level(id) == 8)
    505.     {
    506.         ArrayGetString(g_szPrimaryWeapons, 10, szWeaponName, charsmax(szWeaponName))
    507.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    508.     }
    509.     else if (ze_get_user_level(id) == 9)
    510.     {
    511.         ArrayGetString(g_szPrimaryWeapons, 11, szWeaponName, charsmax(szWeaponName))
    512.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    513.     }
    514.     else if (ze_get_user_level(id) == 10)
    515.     {
    516.         ArrayGetString(g_szPrimaryWeapons, 12, szWeaponName, charsmax(szWeaponName))
    517.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    518.     }
    519.     else if (ze_get_user_level(id) == 11)
    520.     {
    521.         ArrayGetString(g_szPrimaryWeapons, 13, szWeaponName, charsmax(szWeaponName))
    522.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    523.     }
    524.     else if (ze_get_user_level(id) >= 12 && ze_get_user_level(id) < 15) // Golden M3
    525.     {
    526.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 15 Unlock\w: \yGolden M3^n")
    527.     }
    528.     else if (ze_get_user_level(id) >= 15 && ze_get_user_level(id) < 20) // Golden MP5
    529.     {
    530.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 20 Unlock\w: \yGolden MP5^n")
    531.     }
    532.     else if (ze_get_user_level(id) >= 20 && ze_get_user_level(id) < 25) // Golden M4A1
    533.     {
    534.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 25 Unlock\w: \yGolden M4A1^n")
    535.     }
    536.     else if (ze_get_user_level(id) >= 25 && ze_get_user_level(id) < 30) // Golden Ak-47
    537.     {
    538.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 30 Unlock\w: \yGolden AK-47^n")
    539.     }
    540.     else if (ze_get_user_level(id) >= 30 && ze_get_user_level(id) < 40) // JetPack
    541.     {
    542.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 40 Unlock\w: \yJetPack^n")
    543.     }
    544.  
    545.     // 8. Auto Select
    546.     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")
    547.    
    548.     // 9. Next/Back - 0. Exit
    549.     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")
    550.    
    551.     // Fix for AMXX custom menus
    552.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    553.     show_menu(id, KEYSMENU, szMenu, iMenuTime, "Primary Weapons")
    554. }
    555.  
    556. public Show_Menu_Buy_Secondary(id)
    557. {
    558.     new iMenuTime = floatround(g_fBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
    559.    
    560.     if (iMenuTime <= 0)
    561.     {
    562.         ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
    563.         return
    564.     }
    565.    
    566.     static szMenu[250], szWeaponName[32]
    567.     new iLen, iIndex, iMaxLoops = ArraySize(g_szSecondaryWeapons)
    568.    
    569.     // Title
    570.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L^n", id, "MENU_SECONDARY_TITLE")
    571.    
    572.     // 1-6. Weapon List
    573.     for (iIndex = 0; iIndex < iMaxLoops; iIndex++)
    574.     {
    575.         if (ze_get_user_level(id) == 0 && iIndex >= 2 ||
    576.         ze_get_user_level(id) == 1 && iIndex >= 3 ||
    577.         ze_get_user_level(id) == 2 && iIndex >= 4 ||
    578.         ze_get_user_level(id) == 3 && iIndex >= 5 ||
    579.         ze_get_user_level(id) == 4 && iIndex >= 6)
    580.         {
    581.             break
    582.         }
    583.        
    584.         ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
    585.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\w%d.\y %s", iIndex+1, szWeaponNames[get_weaponid(szWeaponName)])
    586.     }
    587.    
    588.     if (iIndex < ArraySize(g_szSecondaryWeapons))
    589.     {
    590.         ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
    591.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r Next Level Unlock\w: \y%s", szWeaponNames[get_weaponid(szWeaponName)])
    592.     }
    593.    
    594.     // 8. Auto Select
    595.     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")
    596.    
    597.     // 0. Exit
    598.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\y %L", id, "EXIT")
    599.    
    600.     // Fix for AMXX custom menus
    601.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    602.     show_menu(id, KEYSMENU, szMenu, iMenuTime, "Secondary Weapons")
    603. }
    604.  
    605. public Menu_Buy_Primary(id, key)
    606. {
    607.     // Player dead or zombie or already bought primary
    608.     if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtPrimary[id])
    609.         return PLUGIN_HANDLED
    610.    
    611.     // Special keys / weapon list exceeded
    612.     if (key >= MENU_KEY_AUTOSELECT || WPN_SELECTION >= WPN_MAXIDS[id])
    613.     {
    614.         switch (key)
    615.         {
    616.             case MENU_KEY_AUTOSELECT: // toggle auto select
    617.             {
    618.                 WPN_AUTO_ON = 1 - WPN_AUTO_ON
    619.             }
    620.             case MENU_KEY_NEXT: // next/back
    621.             {
    622.                 if (WPN_STARTID+7 < WPN_MAXIDS[id])
    623.                     WPN_STARTID += 7
    624.                 else
    625.                     WPN_STARTID = 0
    626.             }
    627.             case MENU_KEY_EXIT: // exit
    628.             {
    629.                 return PLUGIN_HANDLED
    630.             }
    631.         }
    632.        
    633.         // Show buy menu again
    634.         Show_Menu_Buy_Primary(id)
    635.         return PLUGIN_HANDLED
    636.     }
    637.    
    638.     // Store selected weapon id
    639.     WPN_AUTO_PRI = WPN_SELECTION
    640.    
    641.     // Buy primary weapon
    642.     Buy_Primary_Weapon(id, WPN_AUTO_PRI)
    643.    
    644.     // Show Secondary Weapons
    645.     Show_Available_Buy_Menus(id)
    646.    
    647.     return PLUGIN_HANDLED
    648. }
    649.  
    650. public Buy_Primary_Weapon(id, selection)
    651. {
    652.     if (selection == 14) // Golden M3
    653.     {
    654.         give_golden_m3(id)
    655.         g_bBoughtPrimary[id] = true
    656.         return true;
    657.     }
    658.     else if (selection == 15) // Golden MP5
    659.     {
    660.         give_golden_mp5(id)
    661.         g_bBoughtPrimary[id] = true
    662.         return true;
    663.     }
    664.     else if (selection == 16) // Golden M4A1
    665.     {
    666.         give_golden_m4a1(id)
    667.         g_bBoughtPrimary[id] = true
    668.         return true;
    669.     }
    670.     else if (selection == 17) // Golden AK47
    671.     {
    672.         give_golden_ak47(id)
    673.         g_bBoughtPrimary[id] = true
    674.         return true;
    675.     }
    676.     else if (selection == 18) // JetPack
    677.     {
    678.         ze_give_jetpack(id)
    679.         g_bBoughtPrimary[id] = true
    680.         return true;
    681.     }
    682.    
    683.     static szWeaponName[32]
    684.     ArrayGetString(g_szPrimaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
    685.     new iWeaponId = get_weaponid(szWeaponName)
    686.    
    687.     // Strip and Give Full Weapon
    688.     rg_give_item(id, szWeaponName, GT_REPLACE)
    689.     rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
    690.    
    691.     // Primary bought
    692.     g_bBoughtPrimary[id] = true
    693.     return true;
    694. }
    695.  
    696. public Menu_Buy_Secondary(id, key)
    697. {
    698.     // Player dead or zombie or already bought secondary
    699.     if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtSecondary[id])
    700.         return PLUGIN_HANDLED
    701.    
    702.     // Special keys / weapon list exceeded
    703.     if (key >= ArraySize(g_szSecondaryWeapons))
    704.     {
    705.         // Toggle autoselect
    706.         if (key == MENU_KEY_AUTOSELECT)
    707.             WPN_AUTO_ON = 1 - WPN_AUTO_ON
    708.        
    709.         // Reshow menu unless user exited
    710.         if (key != MENU_KEY_EXIT)
    711.             Show_Menu_Buy_Secondary(id)
    712.        
    713.         return PLUGIN_HANDLED
    714.     }
    715.    
    716.     // Store selected weapon id
    717.     WPN_AUTO_SEC = key
    718.    
    719.     // Buy secondary weapon
    720.     Buy_Secondary_Weapon(id, key)
    721.    
    722.     return PLUGIN_HANDLED
    723. }
    724.  
    725. public Buy_Secondary_Weapon(id, selection)
    726. {
    727.     if ( ((selection == 2) && (ze_get_user_level(id) < 1)) ||
    728.     ((selection == 3) && (ze_get_user_level(id) < 2)) ||
    729.     ((selection == 4) && (ze_get_user_level(id) < 3)) ||
    730.     ((selection == 5) && (ze_get_user_level(id) < 4)) )
    731.     {
    732.         Show_Menu_Buy_Secondary(id)
    733.         return;
    734.     }
    735.  
    736.     static szWeaponName[32]
    737.     ArrayGetString(g_szSecondaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
    738.     new iWeaponId = get_weaponid(szWeaponName)
    739.    
    740.     // Strip and Give Full Weapon
    741.     rg_give_item(id, szWeaponName, GT_REPLACE)
    742.     rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
    743.    
    744.     // Secondary bought
    745.     g_bBoughtSecondary[id] = true
    746. }
    747.  
    748. public Fw_TouchWeapon_Pre(iEnt, id)
    749. {
    750.     if (get_pcvar_num(g_pCvarBlockWeapLowLevel) == 0)
    751.         return HAM_IGNORED;
    752.    
    753.     // Not alive or Not Valid Weapon?
    754.     if(!is_user_alive(id) || !pev_valid(iEnt))
    755.         return HAM_IGNORED;
    756.    
    757.     // Get Weapon Model
    758.     new szWeapModel[32]
    759.     pev(iEnt, pev_model, szWeapModel, charsmax(szWeapModel))
    760.    
    761.     // Remove "models/w_" and ".mdl"
    762.     copyc(szWeapModel, charsmax(szWeapModel), szWeapModel[contain(szWeapModel, "_" ) + 1], '.')
    763.    
    764.     // Set for mp5 to be same as "weapon_mp5navy"
    765.     if(szWeapModel[1] == 'p' && szWeapModel[2] == '5')
    766.         szWeapModel = "mp5navy"
    767.    
    768.     // Add "weapon_" to all model names
    769.     static szWeaponEnt[32]
    770.     formatex(szWeaponEnt, charsmax(szWeaponEnt), "weapon_%s", szWeapModel)
    771.  
    772.     // Get it's index in Weapon Array
    773.     new iIndex, i
    774.    
    775.     // I won't explain the blew code if you need to understand ask me in Escapers-Zone.XYZ
    776.     for (i = 0; i < ArraySize(g_szPrimaryWeapons); i++)
    777.     {
    778.         new szPrimaryWeapon[32]
    779.         ArrayGetString(g_szPrimaryWeapons, i, szPrimaryWeapon, charsmax(szPrimaryWeapon))
    780.        
    781.         if (equali(szWeaponEnt, szPrimaryWeapon))
    782.             iIndex = i
    783.     }
    784.    
    785.     if (ze_get_user_level(id) == 0 && iIndex > 1)
    786.     {
    787.         return HAM_SUPERCEDE;
    788.     }
    789.    
    790.     for (i = 1; i <= 11; i++)
    791.     {
    792.         if ((ze_get_user_level(id) == i) && iIndex > i+1)
    793.         {
    794.             return HAM_SUPERCEDE;
    795.         }
    796.     }
    797.    
    798.     return HAM_IGNORED;
    799. }
    800.  
    801. // Natives
    802. public native_ze_show_weapon_menu(id)
    803. {
    804.     if (!is_user_connected(id))
    805.     {
    806.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    807.         return false
    808.     }
    809.    
    810.     Cmd_Buy(id)
    811.     return true
    812. }
    813.  
    814. public native_ze_is_auto_buy_enabled(id)
    815. {
    816.     if (!is_user_connected(id))
    817.     {
    818.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    819.         return -1;
    820.     }
    821.    
    822.     return WPN_AUTO_ON;
    823. }
    824.  
    825. public native_ze_disable_auto_buy(id)
    826. {
    827.     if (!is_user_connected(id))
    828.     {
    829.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    830.         return false
    831.     }
    832.    
    833.     WPN_AUTO_ON = 0;
    834.     return true
    835. }
Note that if you exceeded the page number 3 there will be special edit needed, if you stuck in this please let me know and i'll help you go out ;)
He who fails to plan is planning to fail

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

#6

Post by czirimbolo » 5 years ago

I think I will exceed the page nr 3, because I would like add abour 6-7 guns
Image

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

#7

Post by Raheem » 5 years ago

When you reach current page max, post your .sma and i'll add you another page.

One more thing if you don't know how to add native and remove the weapon from extra-items you can post it in public requests and it's easy for anyone to help you.
He who fails to plan is planning to fail

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

#8

Post by czirimbolo » 5 years ago

Raheem, I added this jetpack to my weapon list, but page 3rd is full with golden guns so I cant see jetpack because there is no 4th page. Can you make next page?

edit:
3rd page is full because of duplicated goldens, see the screen. By the way, you can delete M3 golden and mp5 GOLDEN, I won't be using them.
Attachments
ss.PNG
ss.PNG (133.24 KiB) Viewed 8762 times
ss.PNG
ss.PNG (133.24 KiB) Viewed 8762 times
Image

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

#9

Post by Raheem » 5 years ago

I forget small check:
    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 give_golden_ak47(id);
    8. native ze_give_jetpack(id);
    9.  
    10. // Setting File
    11. new const ZE_SETTING_RESOURCES[] = "zombie_escape.ini"
    12.  
    13. // Keys
    14. 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
    15. const OFFSET_CSMENUCODE = 205
    16.  
    17. // Primary Weapons Entities [Default Values]
    18. new const szPrimaryWeaponEnt[][] =
    19. {
    20.     "weapon_xm1014",  // Level 0
    21.     "weapon_ump45",   // Level 0
    22.     "weapon_m3",      // Level 1
    23.     "weapon_mp5navy", // Level 2
    24.     "weapon_p90",     // Level 3
    25.     "weapon_galil",   // Level 4
    26.     "weapon_famas",   // Level 5
    27.     "weapon_sg550",   // Level 6
    28.     "weapon_g3sg1",   // Level 7
    29.     "weapon_m249",    // Level 8
    30.     "weapon_sg552",   // Level 9
    31.     "weapon_aug",     // Level 10
    32.     "weapon_m4a1",    // Level 11
    33.     "weapon_ak47"     // Level 12
    34. }
    35.  
    36. // Secondary Weapons Entities [Default Values]
    37. new const szSecondaryWeaponEnt[][]=
    38. {
    39.     "weapon_usp",         // Level 0
    40.     "weapon_p228",        // Level 0
    41.     "weapon_glock18",     // Level 1
    42.     "weapon_fiveseven",   // Level 2
    43.     "weapon_deagle",      // Level 3
    44.     "weapon_elite"        // Level 4
    45. }
    46.  
    47. // Primary and Secondary Weapons Names [Default Values]
    48. new const szWeaponNames[][] =
    49. {
    50.     "",
    51.     "P228",
    52.     "",
    53.     "Scout",
    54.     "HE Grenade",
    55.     "XM1014",
    56.     "",
    57.     "MAC-10",
    58.     "AUG",
    59.     "Smoke Grenade",
    60.     "Dual Elite",
    61.     "Five Seven",
    62.     "UMP 45",
    63.     "SG-550",
    64.     "Galil",
    65.     "Famas",
    66.     "USP",
    67.     "Glock",
    68.     "AWP",
    69.     "MP5",
    70.     "M249",
    71.     "M3",
    72.     "M4A1",
    73.     "TMP",
    74.     "G3SG1",
    75.     "Flashbang",
    76.     "Desert Eagle",
    77.     "SG-552",
    78.     "AK-47",
    79.     "",
    80.     "P90"
    81. }
    82.  
    83. // Max Back Clip Ammo (Change it From here if you need)
    84. new const szMaxBPAmmo[] =
    85. {
    86.     -1,
    87.     52,
    88.     -1,
    89.     90,
    90.     1,
    91.     32,
    92.     1,
    93.     100,
    94.     90,
    95.     1,
    96.     120,
    97.     100,
    98.     100,
    99.     90,
    100.     90,
    101.     90,
    102.     100,
    103.     120,
    104.     30,
    105.     120,
    106.     200,
    107.     32,
    108.     90,
    109.     120,
    110.     90,
    111.     2,
    112.     35,
    113.     90,
    114.     90,
    115.     -1,
    116.     100
    117. }
    118.  
    119. // Menu selections
    120. const MENU_KEY_AUTOSELECT = 7
    121. const MENU_KEY_BACK = 7
    122. const MENU_KEY_NEXT = 8
    123. const MENU_KEY_EXIT = 9
    124.  
    125. // Variables
    126. new Array:g_szPrimaryWeapons, Array:g_szSecondaryWeapons
    127.  
    128. new g_iMenuData[33][4],
    129.     Float:g_fBuyTimeStart[33],
    130.     bool:g_bBoughtPrimary[33],
    131.     bool:g_bBoughtSecondary[33],
    132.     WPN_MAXIDS[33]
    133.  
    134. // Define
    135. #define WPN_STARTID g_iMenuData[id][0]
    136. #define WPN_SELECTION (g_iMenuData[id][0]+key)
    137. #define WPN_AUTO_ON g_iMenuData[id][1]
    138. #define WPN_AUTO_PRI g_iMenuData[id][2]
    139. #define WPN_AUTO_SEC g_iMenuData[id][3]
    140.  
    141. // Cvars
    142. new g_pCvarBuyTime,
    143.     g_pCvarHeGrenade,
    144.     g_pCvarSmokeGrenade,
    145.     g_pCvarFlashGrenade,
    146.     g_pCvarBlockWeapLowLevel
    147.  
    148. public plugin_natives()
    149. {
    150.     register_native("ze_show_weapon_menu", "native_ze_show_weapon_menu", 1)
    151.     register_native("ze_is_auto_buy_enabled", "native_ze_is_auto_buy_enabled", 1)
    152.     register_native("ze_disable_auto_buy", "native_ze_disable_auto_buy", 1)
    153. }
    154.  
    155. public plugin_precache()
    156. {
    157.     // Initialize arrays (32 is the max length of Weapon Entity like: weapon_ak47)
    158.     g_szPrimaryWeapons = ArrayCreate(32, 1)
    159.     g_szSecondaryWeapons = ArrayCreate(32, 1)
    160.    
    161.     // Load from external file
    162.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
    163.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
    164.    
    165.     // If we couldn't load from file, use and save default ones
    166.    
    167.     new iIndex
    168.    
    169.     if (ArraySize(g_szPrimaryWeapons) == 0)
    170.     {
    171.         for (iIndex = 0; iIndex < sizeof szPrimaryWeaponEnt; iIndex++)
    172.             ArrayPushString(g_szPrimaryWeapons, szPrimaryWeaponEnt[iIndex])
    173.        
    174.         // If not found .ini File Create it and save default values in it
    175.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
    176.     }
    177.    
    178.     if (ArraySize(g_szSecondaryWeapons) == 0)
    179.     {
    180.         for (iIndex = 0; iIndex < sizeof szSecondaryWeaponEnt; iIndex++)
    181.             ArrayPushString(g_szSecondaryWeapons, szSecondaryWeaponEnt[iIndex])
    182.        
    183.         // If not found .ini File Create it and save default values in it
    184.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
    185.     }
    186. }
    187.  
    188. public plugin_init()
    189. {
    190.     register_plugin("[ZE] Levels Weapons Menu", "1.1", "Raheem")
    191.    
    192.     // Commands
    193.     register_clcmd("guns", "Cmd_Buy")
    194.     register_clcmd("say /enable", "Cmd_Enable")
    195.     register_clcmd("say_team /enable", "Cmd_Enable")
    196.    
    197.     // Cvars
    198.     g_pCvarBuyTime = register_cvar("ze_buy_time", "60")
    199.     g_pCvarHeGrenade = register_cvar("ze_give_HE_nade", "1") // 0 Nothing || 1 Give HE
    200.     g_pCvarSmokeGrenade = register_cvar("ze_give_SM_nade", "1")
    201.     g_pCvarFlashGrenade = register_cvar("ze_give_FB_nade", "1")
    202.     g_pCvarBlockWeapLowLevel = register_cvar("ze_block_weapons_lowlvl", "1")
    203.    
    204.     // Menus
    205.     register_menu("Primary Weapons", KEYSMENU, "Menu_Buy_Primary")
    206.     register_menu("Secondary Weapons", KEYSMENU, "Menu_Buy_Secondary")
    207.    
    208.     // Hams
    209.     RegisterHam(Ham_Touch, "weaponbox", "Fw_TouchWeapon_Pre", 0)
    210.     RegisterHam(Ham_Touch, "armoury_entity", "Fw_TouchWeapon_Pre", 0)
    211. }
    212.  
    213. public client_disconnected(id)
    214. {
    215.     WPN_AUTO_ON = 0
    216.     WPN_STARTID = 0
    217. }
    218.  
    219. public Cmd_Enable(id)
    220. {
    221.     if (WPN_AUTO_ON)
    222.     {
    223.         ze_colored_print(id, "%L", LANG_PLAYER, "BUY_ENABLED")
    224.         WPN_AUTO_ON = 0
    225.     }
    226. }
    227.  
    228. public Cmd_Buy(id)
    229. {
    230.     // Player Zombie
    231.     if (ze_is_user_zombie(id))
    232.     {
    233.         ze_colored_print(id, "%L", LANG_PLAYER, "NO_BUY_ZOMBIE")
    234.         return
    235.     }
    236.    
    237.     // Player Dead
    238.     if (!is_user_alive(id))
    239.     {
    240.         ze_colored_print(id, "%L", LANG_PLAYER, "DEAD_CANT_BUY_WEAPON")
    241.         return
    242.     }
    243.    
    244.     // Already bought
    245.     if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
    246.     {
    247.         ze_colored_print(id, "%L", LANG_PLAYER, "ALREADY_BOUGHT")
    248.     }
    249.    
    250.     Show_Available_Buy_Menus(id)
    251. }
    252.  
    253. public ze_user_humanized(id)
    254. {
    255.     // Static Values
    256.     switch (ze_get_user_level(id))
    257.     {
    258.         case 0: WPN_MAXIDS[id] = 2
    259.         case 1: WPN_MAXIDS[id] = 3
    260.         case 2: WPN_MAXIDS[id] = 4
    261.         case 3: WPN_MAXIDS[id] = 5
    262.         case 4: WPN_MAXIDS[id] = 6
    263.         case 5: WPN_MAXIDS[id] = 7
    264.         case 6: WPN_MAXIDS[id] = 8
    265.         case 7: WPN_MAXIDS[id] = 9
    266.         case 8: WPN_MAXIDS[id] = 10
    267.         case 9: WPN_MAXIDS[id] = 11
    268.         case 10: WPN_MAXIDS[id] = 12
    269.         case 11: WPN_MAXIDS[id] = 13
    270.         case 12..14: WPN_MAXIDS[id] = 14
    271.         case 15..19: WPN_MAXIDS[id] = 15 // Golden m3
    272.         case 20..24: WPN_MAXIDS[id] = 16 // Golden MP5
    273.         case 25..29: WPN_MAXIDS[id] = 17 // Golden M4A1
    274.         case 30..39: WPN_MAXIDS[id] = 18 // Golden AK47
    275.         case 40: WPN_MAXIDS[id] = 19    // JatPack
    276.     }
    277.    
    278.     if (ze_get_user_level(id) > 40)
    279.     {
    280.         WPN_MAXIDS[id] = 19
    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, "Golden M3")
    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, "Golden M3")
    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, "Golden M3")
    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 && ze_get_user_level(id) < 40)
    422.         {
    423.             if (iIndex == 14)
    424.             {
    425.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M3")
    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, "Golden AK-47")
    441.                 break;
    442.             }
    443.         }
    444.        
    445.         // JetPack
    446.         if (ze_get_user_level(id) >= 40)
    447.         {
    448.             if (iIndex == 14)
    449.             {
    450.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M3")
    451.             }
    452.            
    453.             if (iIndex == 15)
    454.             {
    455.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
    456.             }
    457.            
    458.             if (iIndex == 16)
    459.             {
    460.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
    461.             }
    462.            
    463.             if (iIndex == 17)
    464.             {
    465.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK-47")
    466.             }
    467.            
    468.             if (iIndex == 18)
    469.             {
    470.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "JetPack")
    471.                 break;
    472.             }
    473.         }
    474.        
    475.         // Must check if iIndex < 14 means max is AK47
    476.         if (iIndex < 14)
    477.         {
    478.             ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
    479.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, szWeaponNames[get_weaponid(szWeaponName)])
    480.         }
    481.     }
    482.    
    483.     if (iIndex < 7)
    484.     {
    485.         ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
    486.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    487.     }
    488.    
    489.     if (ze_get_user_level(id) == 5)
    490.     {
    491.         ArrayGetString(g_szPrimaryWeapons, 7, 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) == 6)
    495.     {
    496.         ArrayGetString(g_szPrimaryWeapons, 8, szWeaponName, charsmax(szWeaponName))
    497.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    498.     }
    499.     else if (ze_get_user_level(id) == 7)
    500.     {
    501.         ArrayGetString(g_szPrimaryWeapons, 9, szWeaponName, charsmax(szWeaponName))
    502.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    503.     }
    504.     else if (ze_get_user_level(id) == 8)
    505.     {
    506.         ArrayGetString(g_szPrimaryWeapons, 10, szWeaponName, charsmax(szWeaponName))
    507.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    508.     }
    509.     else if (ze_get_user_level(id) == 9)
    510.     {
    511.         ArrayGetString(g_szPrimaryWeapons, 11, szWeaponName, charsmax(szWeaponName))
    512.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    513.     }
    514.     else if (ze_get_user_level(id) == 10)
    515.     {
    516.         ArrayGetString(g_szPrimaryWeapons, 12, szWeaponName, charsmax(szWeaponName))
    517.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    518.     }
    519.     else if (ze_get_user_level(id) == 11)
    520.     {
    521.         ArrayGetString(g_szPrimaryWeapons, 13, szWeaponName, charsmax(szWeaponName))
    522.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    523.     }
    524.     else if (ze_get_user_level(id) >= 12 && ze_get_user_level(id) < 15) // Golden M3
    525.     {
    526.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 15 Unlock\w: \yGolden M3^n")
    527.     }
    528.     else if (ze_get_user_level(id) >= 15 && ze_get_user_level(id) < 20) // Golden MP5
    529.     {
    530.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 20 Unlock\w: \yGolden MP5^n")
    531.     }
    532.     else if (ze_get_user_level(id) >= 20 && ze_get_user_level(id) < 25) // Golden M4A1
    533.     {
    534.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 25 Unlock\w: \yGolden M4A1^n")
    535.     }
    536.     else if (ze_get_user_level(id) >= 25 && ze_get_user_level(id) < 30) // Golden Ak-47
    537.     {
    538.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 30 Unlock\w: \yGolden AK-47^n")
    539.     }
    540.     else if (ze_get_user_level(id) >= 30 && ze_get_user_level(id) < 40) // JetPack
    541.     {
    542.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 40 Unlock\w: \yJetPack^n")
    543.     }
    544.  
    545.     // 8. Auto Select
    546.     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")
    547.    
    548.     // 9. Next/Back - 0. Exit
    549.     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")
    550.    
    551.     // Fix for AMXX custom menus
    552.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    553.     show_menu(id, KEYSMENU, szMenu, iMenuTime, "Primary Weapons")
    554. }
    555.  
    556. public Show_Menu_Buy_Secondary(id)
    557. {
    558.     new iMenuTime = floatround(g_fBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
    559.    
    560.     if (iMenuTime <= 0)
    561.     {
    562.         ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
    563.         return
    564.     }
    565.    
    566.     static szMenu[250], szWeaponName[32]
    567.     new iLen, iIndex, iMaxLoops = ArraySize(g_szSecondaryWeapons)
    568.    
    569.     // Title
    570.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L^n", id, "MENU_SECONDARY_TITLE")
    571.    
    572.     // 1-6. Weapon List
    573.     for (iIndex = 0; iIndex < iMaxLoops; iIndex++)
    574.     {
    575.         if (ze_get_user_level(id) == 0 && iIndex >= 2 ||
    576.         ze_get_user_level(id) == 1 && iIndex >= 3 ||
    577.         ze_get_user_level(id) == 2 && iIndex >= 4 ||
    578.         ze_get_user_level(id) == 3 && iIndex >= 5 ||
    579.         ze_get_user_level(id) == 4 && iIndex >= 6)
    580.         {
    581.             break
    582.         }
    583.        
    584.         ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
    585.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\w%d.\y %s", iIndex+1, szWeaponNames[get_weaponid(szWeaponName)])
    586.     }
    587.    
    588.     if (iIndex < ArraySize(g_szSecondaryWeapons))
    589.     {
    590.         ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
    591.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r Next Level Unlock\w: \y%s", szWeaponNames[get_weaponid(szWeaponName)])
    592.     }
    593.    
    594.     // 8. Auto Select
    595.     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")
    596.    
    597.     // 0. Exit
    598.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\y %L", id, "EXIT")
    599.    
    600.     // Fix for AMXX custom menus
    601.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    602.     show_menu(id, KEYSMENU, szMenu, iMenuTime, "Secondary Weapons")
    603. }
    604.  
    605. public Menu_Buy_Primary(id, key)
    606. {
    607.     // Player dead or zombie or already bought primary
    608.     if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtPrimary[id])
    609.         return PLUGIN_HANDLED
    610.    
    611.     // Special keys / weapon list exceeded
    612.     if (key >= MENU_KEY_AUTOSELECT || WPN_SELECTION >= WPN_MAXIDS[id])
    613.     {
    614.         switch (key)
    615.         {
    616.             case MENU_KEY_AUTOSELECT: // toggle auto select
    617.             {
    618.                 WPN_AUTO_ON = 1 - WPN_AUTO_ON
    619.             }
    620.             case MENU_KEY_NEXT: // next/back
    621.             {
    622.                 if (WPN_STARTID+7 < WPN_MAXIDS[id])
    623.                     WPN_STARTID += 7
    624.                 else
    625.                     WPN_STARTID = 0
    626.             }
    627.             case MENU_KEY_EXIT: // exit
    628.             {
    629.                 return PLUGIN_HANDLED
    630.             }
    631.         }
    632.        
    633.         // Show buy menu again
    634.         Show_Menu_Buy_Primary(id)
    635.         return PLUGIN_HANDLED
    636.     }
    637.    
    638.     // Store selected weapon id
    639.     WPN_AUTO_PRI = WPN_SELECTION
    640.    
    641.     // Buy primary weapon
    642.     Buy_Primary_Weapon(id, WPN_AUTO_PRI)
    643.    
    644.     // Show Secondary Weapons
    645.     Show_Available_Buy_Menus(id)
    646.    
    647.     return PLUGIN_HANDLED
    648. }
    649.  
    650. public Buy_Primary_Weapon(id, selection)
    651. {
    652.     if (selection == 14) // Golden M3
    653.     {
    654.         give_golden_m3(id)
    655.         g_bBoughtPrimary[id] = true
    656.         return true;
    657.     }
    658.     else if (selection == 15) // Golden MP5
    659.     {
    660.         give_golden_mp5(id)
    661.         g_bBoughtPrimary[id] = true
    662.         return true;
    663.     }
    664.     else if (selection == 16) // Golden M4A1
    665.     {
    666.         give_golden_m4a1(id)
    667.         g_bBoughtPrimary[id] = true
    668.         return true;
    669.     }
    670.     else if (selection == 17) // Golden AK47
    671.     {
    672.         give_golden_ak47(id)
    673.         g_bBoughtPrimary[id] = true
    674.         return true;
    675.     }
    676.     else if (selection == 18) // JetPack
    677.     {
    678.         ze_give_jetpack(id)
    679.         g_bBoughtPrimary[id] = true
    680.         return true;
    681.     }
    682.    
    683.     static szWeaponName[32]
    684.     ArrayGetString(g_szPrimaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
    685.     new iWeaponId = get_weaponid(szWeaponName)
    686.    
    687.     // Strip and Give Full Weapon
    688.     rg_give_item(id, szWeaponName, GT_REPLACE)
    689.     rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
    690.    
    691.     // Primary bought
    692.     g_bBoughtPrimary[id] = true
    693.     return true;
    694. }
    695.  
    696. public Menu_Buy_Secondary(id, key)
    697. {
    698.     // Player dead or zombie or already bought secondary
    699.     if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtSecondary[id])
    700.         return PLUGIN_HANDLED
    701.    
    702.     // Special keys / weapon list exceeded
    703.     if (key >= ArraySize(g_szSecondaryWeapons))
    704.     {
    705.         // Toggle autoselect
    706.         if (key == MENU_KEY_AUTOSELECT)
    707.             WPN_AUTO_ON = 1 - WPN_AUTO_ON
    708.        
    709.         // Reshow menu unless user exited
    710.         if (key != MENU_KEY_EXIT)
    711.             Show_Menu_Buy_Secondary(id)
    712.        
    713.         return PLUGIN_HANDLED
    714.     }
    715.    
    716.     // Store selected weapon id
    717.     WPN_AUTO_SEC = key
    718.    
    719.     // Buy secondary weapon
    720.     Buy_Secondary_Weapon(id, key)
    721.    
    722.     return PLUGIN_HANDLED
    723. }
    724.  
    725. public Buy_Secondary_Weapon(id, selection)
    726. {
    727.     if ( ((selection == 2) && (ze_get_user_level(id) < 1)) ||
    728.     ((selection == 3) && (ze_get_user_level(id) < 2)) ||
    729.     ((selection == 4) && (ze_get_user_level(id) < 3)) ||
    730.     ((selection == 5) && (ze_get_user_level(id) < 4)) )
    731.     {
    732.         Show_Menu_Buy_Secondary(id)
    733.         return;
    734.     }
    735.  
    736.     static szWeaponName[32]
    737.     ArrayGetString(g_szSecondaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
    738.     new iWeaponId = get_weaponid(szWeaponName)
    739.    
    740.     // Strip and Give Full Weapon
    741.     rg_give_item(id, szWeaponName, GT_REPLACE)
    742.     rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
    743.    
    744.     // Secondary bought
    745.     g_bBoughtSecondary[id] = true
    746. }
    747.  
    748. public Fw_TouchWeapon_Pre(iEnt, id)
    749. {
    750.     if (get_pcvar_num(g_pCvarBlockWeapLowLevel) == 0)
    751.         return HAM_IGNORED;
    752.    
    753.     // Not alive or Not Valid Weapon?
    754.     if(!is_user_alive(id) || !pev_valid(iEnt))
    755.         return HAM_IGNORED;
    756.    
    757.     // Get Weapon Model
    758.     new szWeapModel[32]
    759.     pev(iEnt, pev_model, szWeapModel, charsmax(szWeapModel))
    760.    
    761.     // Remove "models/w_" and ".mdl"
    762.     copyc(szWeapModel, charsmax(szWeapModel), szWeapModel[contain(szWeapModel, "_" ) + 1], '.')
    763.    
    764.     // Set for mp5 to be same as "weapon_mp5navy"
    765.     if(szWeapModel[1] == 'p' && szWeapModel[2] == '5')
    766.         szWeapModel = "mp5navy"
    767.    
    768.     // Add "weapon_" to all model names
    769.     static szWeaponEnt[32]
    770.     formatex(szWeaponEnt, charsmax(szWeaponEnt), "weapon_%s", szWeapModel)
    771.  
    772.     // Get it's index in Weapon Array
    773.     new iIndex, i
    774.    
    775.     // I won't explain the blew code if you need to understand ask me in Escapers-Zone.XYZ
    776.     for (i = 0; i < ArraySize(g_szPrimaryWeapons); i++)
    777.     {
    778.         new szPrimaryWeapon[32]
    779.         ArrayGetString(g_szPrimaryWeapons, i, szPrimaryWeapon, charsmax(szPrimaryWeapon))
    780.        
    781.         if (equali(szWeaponEnt, szPrimaryWeapon))
    782.             iIndex = i
    783.     }
    784.    
    785.     if (ze_get_user_level(id) == 0 && iIndex > 1)
    786.     {
    787.         return HAM_SUPERCEDE;
    788.     }
    789.    
    790.     for (i = 1; i <= 11; i++)
    791.     {
    792.         if ((ze_get_user_level(id) == i) && iIndex > i+1)
    793.         {
    794.             return HAM_SUPERCEDE;
    795.         }
    796.     }
    797.    
    798.     return HAM_IGNORED;
    799. }
    800.  
    801. // Natives
    802. public native_ze_show_weapon_menu(id)
    803. {
    804.     if (!is_user_connected(id))
    805.     {
    806.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    807.         return false
    808.     }
    809.    
    810.     Cmd_Buy(id)
    811.     return true
    812. }
    813.  
    814. public native_ze_is_auto_buy_enabled(id)
    815. {
    816.     if (!is_user_connected(id))
    817.     {
    818.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    819.         return -1;
    820.     }
    821.    
    822.     return WPN_AUTO_ON;
    823. }
    824.  
    825. public native_ze_disable_auto_buy(id)
    826. {
    827.     if (!is_user_connected(id))
    828.     {
    829.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    830.         return false
    831.     }
    832.    
    833.     WPN_AUTO_ON = 0;
    834.     return true
    835. }
He who fails to plan is planning to fail

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

#10

Post by czirimbolo » 5 years ago

Can you also remove Golden m3 and golden mp50 and add this gun for 30 level?

Code: Select all

/* Plugin generated by AMXX-Studio */

#pragma compress 1

#include <zombie_escape>
#include <fakemeta_util>
#include <fun>
#include <cstrike>
#include <xs>
#include <engine>

#define PLUGIN "Dual Sword Phantom Slayer"
#define VERSION "1.0"
#define AUTHOR "Bim Bim Cay"
#define VIP_FLAG "VIP_A"

#define v_model "models/v_dualsword.mdl"
#define v_modelfx "models/v_dualswordfx.mdl"

#define p_modela "models/p_dualsword_a.mdl"
#define p_modelb "models/p_dualsword_b.mdl"

#define skill_model "models/dualsword_skill.mdl"
#define blueblade_model "models/dualsword_skillfx2.mdl"
#define goldblade_model "models/dualsword_skillfx1.mdl"

//Blue Blade
#define spr_leaf1 "sprites/leaf01_dualsword.spr"
#define spr_leaf2 "sprites/leaf02_dualsword.spr"

//Gold Blade
#define spr_petal1 "sprites/petal01_dualsword.spr"
#define spr_petal2 "sprites/petal02_dualsword.spr"

//Ef Spr (Sorry, I think only csbte can do it)
#define spr_efleft "sprites/ef_dualsword_left.spr" 
#define spr_efright "sprites/ef_dualsword_right.spr" 

new const SwordsSounds[15][] = 
{
	"weapons/dualsword_fly1.wav",
	"weapons/dualsword_fly2.wav",
	"weapons/dualsword_fly3.wav",
	"weapons/dualsword_fly4.wav",
	"weapons/dualsword_fly5.wav",
	"weapons/dualsword_hit1.wav",
	"weapons/dualsword_hit2.wav",
	"weapons/dualsword_hit3.wav",
	"weapons/dualsword_skill_start.wav",
	"weapons/dualsword_skill_end.wav",
	"weapons/dualsword_stab1_hit.wav",
	"weapons/dualsword_stab2_hit.wav",
	"weapons/katana_hitwall.wav",
	"weapons/dualsword_slash_4_1.wav",
	"weapons/dualsword_slash_4_2.wav"
}

//Other Sounds
/*
dualsword_idle_a.wav
dualsword_idle_b.wav
dualsword_slash_1.wav
dualsword_slash_2.wav
dualsword_slash_3.wav
dualsword_slash_4.wav
dualsword_slash_4-1.wav
dualsword_slash_4-2.wav
dualsword_slash_end.wav
dualsword_stab1.wav 
dualsword_stab2.wav 
*/

//Animations
//Blades
#define ANIM_IDLEA		0
#define ANIM_SLASH1		1
#define ANIM_SLASH2		2
#define ANIM_SLASH3		3
#define ANIM_SLASH4		4
#define ANIM_SLASHEND		5
#define ANIM_DRAWA		6
#define ANIM_IDLEB		7
#define ANIM_STAB1		8
#define ANIM_STAB2		9
#define ANIM_STABEND		10
#define ANIM_DRAWB		11
#define ANIM_SWABA		12
#define ANIM_SWABB		13
#define ANIM_SKILLSTART		14
#define ANIM_SKILLLOOP		15

//Effects
#define ANIM_EFSLASH1		0
#define ANIM_EFSLASH2		1
#define ANIM_EFSLASH3		2
#define ANIM_EFSLASH4		3

//Config
#define DRAW_TIME 		0.233	
#define SWAB_TIME		0.366

//SLASH
#define SLASH_NEXTATTACK	0.1
#define SLASH4_NEXTATTACK	0.7
#define SLASH_NEXTIDLE     	1.0
#define SLASHEND_NEXTIDLE  	2.0
#define SLASH_DAMAGE 		150.0
#define SLASH_RANGE		175.0
#define SLASH_ANGLE		60.0

//STAB
#define STAB_DELAY1		0.06
#define STAB_DELAY2		0.4
#define STAB_NEXTATTACK1	0.43
#define STAB_NEXTATTACK2	0.86
#define STAB_NEXTIDLE1		0.7
#define STAB_NEXTIDLE2		0.93
#define STABEND_NEXTIDLE  	1.43
#define STAB_DAMAGE1 		200.0
#define STAB_RANGE1		200.0
#define STAB_ANGLE1		30.0
#define STAB_DAMAGE2 		1000.0
#define STAB_RANGE2		200.0
#define STAB_ANGLE2		45.0

//Skill
#define SKILL_STARTTIME		1.0
#define SKILL_TIME		11.36
#define SKILL_DAMAGE		200.0

//Entities 
#define ATK2_CLASSNAME		"Sugar"
#define EF_CLASSNAME		"1000Swords"
#define SWORD1_CLASSNAME	"Vinegar"
#define SWORD2_CLASSNAME	"Chilli"

//Hit
#define	HIT_NOTHING 			0
#define	HIT_ENEMY			1
#define	HIT_WALL			2

// MACROS
#define Get_BitVar(%1,%2) (%1 & (1 << (%2 & 31)))
#define Set_BitVar(%1,%2) %1 |= (1 << (%2 & 31))
#define UnSet_BitVar(%1,%2) %1 &= ~(1 << (%2 & 31))
#define MaskEnt(%0) (1<<(%0 & 31))

new g_had_dps, is_mode2, is_attacked
new PlayerAttack[33][11], Mode[33], Power[33] , Float:AttackDelay[33], AttackType[33]
new spr_blood_spray, spr_blood_drop, sprleaf1, sprleaf2, sprpetal1, sprpetal2
new dsp

new const Key[11] = 
{
	0,2,3,4,5,0,1,2,3,4,5
}

new const Float:Float1[42] = 
{ 
  50.0, -50.0, 60.0, -60.0, 70.0, -70.0, 80.0, -80.0, 90.0, -90.0, 100.0, -100.0, 110.0, -110.0, 120.0, -120.0, 130.0, -130.0, 140.0,-140.0,
  150.0, -150.0, 160.0, -160.0, 170.0, -170.0, 180.0, -180.0, 190.0, -190.0, 200.0, -200.0, 210.0, -210.0, 220.0, -220.0, 230.0, -230.0, 
  240.0, -240.0, 250.0, -250.0
}

new const Float:Float2[16] =
{
  -16.0, -15.0, -10.0, 0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 110.0, 120.0
}

new const Float:Float3[41] = 
{ 
  0.0, 10.0, -10.0, 20.0, -20.0, 30.0, -30.0, 40.0, -40.0, 50.0, -50.0, 60.0, -60.0, 70.0, -70.0, 80.0, -80.0, 90.0, -90.0, 100.0, -100.0, 110.0, -110.0, 120.0, -120.0, 130.0, -130.0, 140.0,-140.0,
  150.0, -150.0, 160.0, -160.0, 170.0, -170.0, 180.0, -180.0, 190.0, -190.0, 200.0, -200.0
}
	
public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
	register_forward(FM_AddToFullPack, "fw_AddToFullPack_Post", 1)
	
	register_think(ATK2_CLASSNAME, "Atk2_Think")
	register_think(EF_CLASSNAME, "Ef_Think")
	register_think(SWORD1_CLASSNAME, "Sword1_Think")
	register_think(SWORD2_CLASSNAME, "Sword2_Think")
	
	register_touch(SWORD1_CLASSNAME, "*", "Sword1_Touch")
	
	RegisterHam(Ham_Item_Deploy,"weapon_knife", "fw_Item_Deploy_Post", 1)
	RegisterHam(Ham_Item_Holster, "weapon_knife", "fw_Item_Holster_Post", 1)
	RegisterHam(Ham_Weapon_WeaponIdle,"weapon_knife", "fw_Weapon_WeaponIdle_Post", 1)
	
	RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_knife", "fw_Weapon_PrimaryAttack")
	RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_knife", "fw_Weapon_SecondaryAttack")
	RegisterHam(Ham_Item_PostFrame, "weapon_knife", "fw_Item_PostFrame")
	
	dsp = ze_register_item("Dual Sword Phantom Slayer", 150, 0)
	ze_set_item_vip(dsp, VIP_FLAG)
	register_clcmd("get_dsp", "get_dsp")
}

public plugin_precache()
{
	precache_model(v_model)
	precache_model(v_modelfx)
	precache_model(p_modela)
	precache_model(p_modelb)
	precache_model(skill_model)
	precache_model(blueblade_model)
	precache_model(goldblade_model)
	
	for(new i = 0; i < sizeof(SwordsSounds); i++)
		precache_sound(SwordsSounds[i])
	
	sprleaf1 = precache_model(spr_leaf1)
	sprleaf2 = precache_model(spr_leaf2)
	sprpetal1 = precache_model(spr_petal1)
	sprpetal2 = precache_model(spr_petal2)
	spr_blood_spray = precache_model("sprites/bloodspray.spr")
	spr_blood_drop = precache_model("sprites/blood.spr")
}

public ze_user_infected(iVictim)
{
    RemoveWeapon(iVictim)
}	
public ze_select_item_pre(id, itemid)
{
	// If it is not the gun the player is willing to buy then just make it available.
	// g_iItemID is the handler you made it before.
	// You can name itemid whatever you like but just not the same handler name.
	
	if (itemid != dsp)
		return ZE_ITEM_AVAILABLE
		
	// In this item we are working on, it will be for humans only so we need to hide it for zombies so they do not get it.
	//If you want it to be for zombies, you need to add the not operator "!" before the native so it's gonna be like this:
	// if (!ze_is_user_zombie(id))
	// If you want an item to be for zombies & humans then just don't add the next code.
	
	if (ze_is_user_zombie(id))
		return ZE_ITEM_DONT_SHOW
		
	// Here we need to return a value so you don't get a warning on compiling.
	return ZE_ITEM_AVAILABLE
}

public ze_select_item_post(id, itemid)
{
	// Here we just block buying the gun if it is not the gun the player is willing to buy so we just add return without values.
	if (itemid != dsp)
		return
	
	GetWeapon(id, itemid)
}
	
public GetWeapon(id, item)
{
	if(item == dsp) get_dsp(id)
}

public RemoveWeapon(id)
{
	remove_dsp(id)
}
	
public get_dsp(id)
{
	if(!is_user_alive(id))
		return
	
	if(Get_BitVar(g_had_dps, id))
		return
	
	Set_BitVar(g_had_dps, id)
	UnSet_BitVar(is_mode2, id)
	UnSet_BitVar(is_attacked, id)
	AttackType[id] = 0
	Power[id] = 0
	Mode[id] = 0

	static Ent; Ent = fm_get_user_weapon_entity(id, CSW_KNIFE)
	
	if(!pev_valid(Ent)) 
		return
	
	if(get_pdata_cbase(id, 373) != Ent) 
		return
	
	ExecuteHamB(Ham_Item_Deploy, Ent)
}

public remove_dsp(id)
{
	UnSet_BitVar(g_had_dps, id)
	UnSet_BitVar(is_mode2, id)
	UnSet_BitVar(is_attacked, id)
	AttackType[id] = 0
	Power[id] = 0
	Mode[id] = 0
}

public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
{
	if(!is_user_alive(id))
		return FMRES_IGNORED	
	if(get_user_weapon(id) == CSW_KNIFE && Get_BitVar(g_had_dps, id))
		set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001) 
	
	return FMRES_HANDLED
}	
//Too much CPU but I don't have other choices now
public fw_AddToFullPack_Post(esState, iE, iEnt, iHost, iHostFlags, iPlayer, pSet)
{
	if(!pev_valid(iEnt))
		return
	
	static classname[12]; pev(iEnt, pev_classname, classname, charsmax(classname))
	
	if(equali(classname, ATK2_CLASSNAME))
	{
		static Owner; Owner = pev(iEnt, pev_owner)
		
		if(iHost != Owner)
		{
			set_es(esState, ES_RenderAmt, 0.0)
		}
	} 
}

public fw_Item_Deploy_Post(Ent)
{
	static Id; Id = get_pdata_cbase(Ent, 41, 4)
	
	if(!Get_BitVar(g_had_dps, Id))
		return
	
	set_pev(Id, pev_viewmodel2, v_model)
	
	if(Get_BitVar(is_mode2, Id))
	{
		set_pev(Id, pev_weaponmodel2, p_modela)
		Set_WeaponAnim(Id, ANIM_DRAWA)
	}
	else
	{
		set_pev(Id, pev_weaponmodel2, p_modelb)
		Set_WeaponAnim(Id, ANIM_DRAWB)
	}
}

public fw_Item_Holster_Post(Ent)
{
	static Id; Id = get_pdata_cbase(Ent, 41, 4)
	
	if(!Get_BitVar(g_had_dps, Id))
		return
	
	UnSet_BitVar(is_attacked, Id)
	Mode[Id] = 0
	Power[Id] = 0
	AttackType[Id] = 0
}

public fw_Weapon_WeaponIdle_Post(Ent)
{
	static Id; Id = get_pdata_cbase(Ent, 41, 4)
	
	if(!Get_BitVar(g_had_dps, Id))
		return
		
	if(get_pdata_float(Ent, 48, 4) <= 0.25)
	{
		if(Get_BitVar(is_attacked, Id))
		{
			if(Get_BitVar(is_mode2, Id))
			{
				Set_WeaponAnim(Id, ANIM_SLASHEND)
				set_pdata_float(Ent, 48, SLASHEND_NEXTIDLE + 0.5, 4)
			}
			else
			{
				Set_WeaponAnim(Id, ANIM_STABEND)
				set_pdata_float(Ent, 48, STABEND_NEXTIDLE + 0.5, 4)
			}
			
			UnSet_BitVar(is_attacked, Id)
		}
		else
		{
			if(Mode[Id]) Mode[Id] = 0
			if(Power[Id]) Power[Id] = 0
			
			if(Get_BitVar(is_mode2, Id))
			{
				Set_WeaponAnim(Id, ANIM_IDLEA)
			}
			else
			{
				Set_WeaponAnim(Id, ANIM_IDLEB)
			}
			
			set_pdata_float(Ent, 48, 20.0, 4)
		}
	}
}

public fw_Item_PostFrame(Ent)
{
	static id; id = pev(Ent, pev_owner)
	
	if(!Get_BitVar(g_had_dps, id))
		return HAM_IGNORED	
	
	if(AttackType[id] && AttackDelay[id] < get_gametime())
	{
		if(AttackType[id] == 1) Attack1(id)
		else if(AttackType[id] == 2) Attack2(id)
		
		AttackType[id] = 0
	}
	
	if(!(pev(id, pev_button) & IN_ATTACK2) && Get_BitVar(is_mode2, id) && Mode[id]) Mode[id] = 0
	
	return HAM_IGNORED
}

public fw_Weapon_PrimaryAttack(Ent) 
{
	static id; id = pev(Ent, pev_owner)
	
	if(!Get_BitVar(g_had_dps, id))
		return HAM_IGNORED
	
	if(Get_BitVar(is_mode2, id))
	{
		UnSet_BitVar(is_mode2, id)
		UnSet_BitVar(is_attacked, id)
		
		Mode[id] = 0
		
		Set_WeaponAnim(id, ANIM_SWABA)
		
		set_pdata_float(Ent, 46, 0.1, 4)
		set_pdata_float(Ent, 47, 0.1, 4)
		set_pdata_float(Ent, 48, SWAB_TIME + 0.5, 4)
		
		set_pev(id, pev_weaponmodel2, p_modelb)
		
		return HAM_SUPERCEDE
	}
	
	Set_BitVar(is_attacked, id)
	
	switch(Mode[id])
	{
		case 0: 
		{
			Mode[id] = 1
			
			AttackType[id] = 1
			AttackDelay[id] = get_gametime() + STAB_DELAY1
			
			Set_WeaponAnim(id, ANIM_STAB1)
			
			set_pdata_float(Ent, 46, STAB_NEXTATTACK1, 4)
			set_pdata_float(Ent, 47, STAB_NEXTATTACK1, 4)
			set_pdata_float(Ent, 48, STAB_NEXTIDLE1 + 0.5, 4)
			
			PlayerAttack[id][Power[id]] = 0
			CheckCode(id)
		}
		case 1: 
		{
			Mode[id] = 0
			
			AttackType[id] = 2
			AttackDelay[id] = get_gametime() + STAB_DELAY2
			
			Set_WeaponAnim(id, ANIM_STAB2)
			
			set_pdata_float(Ent, 46, STAB_NEXTATTACK2, 4)
			set_pdata_float(Ent, 47, STAB_NEXTATTACK2, 4)
			set_pdata_float(Ent, 48, STAB_NEXTIDLE2 + 0.5, 4)
			
			PlayerAttack[id][Power[id]] = 1
			CheckCode(id)
		}
	}
	
	return HAM_SUPERCEDE
}

public fw_Weapon_SecondaryAttack(Ent) 
{
	static id; id = pev(Ent, pev_owner)
	
	if(!Get_BitVar(g_had_dps, id))
		return HAM_IGNORED
	
	if(!Get_BitVar(is_mode2, id))
	{
		Set_BitVar(is_mode2, id)
		UnSet_BitVar(is_attacked, id)
		
		Mode[id] = 0
		
		Set_WeaponAnim(id, ANIM_SWABB)
		
		set_pdata_float(Ent, 46, 0.1, 4)
		set_pdata_float(Ent, 47, 0.1, 4)
		set_pdata_float(Ent, 48, SWAB_TIME + 0.5, 4)
		
		set_pev(id, pev_weaponmodel2, p_modela)
		
		return HAM_SUPERCEDE
	}
	
	Set_BitVar(is_attacked, id)
	
	switch(Mode[id])
	{
		case 0: 
		{
			Mode[id] = 1
			
			Set_WeaponAnim(id, ANIM_SLASH1)
			Create_FakeEnt(id, 0, 0)
			
			set_pdata_float(Ent, 46, SLASH_NEXTATTACK, 4)
			set_pdata_float(Ent, 47, SLASH_NEXTATTACK, 4)
			set_pdata_float(Ent, 48, SLASH_NEXTIDLE + 0.5, 4)
			
			PlayerAttack[id][Power[id]] = 2
			CheckCode(id)
		}
		case 1: 
		{
			Mode[id] = 2
			
			Set_WeaponAnim(id, ANIM_SLASH2)
			Create_FakeEnt(id, 1, 0)
			
			set_pdata_float(Ent, 46, SLASH_NEXTATTACK, 4)
			set_pdata_float(Ent, 47, SLASH_NEXTATTACK, 4)
			set_pdata_float(Ent, 48, SLASH_NEXTIDLE  + 0.5, 4)
			
			PlayerAttack[id][Power[id]] = 3
			CheckCode(id)
		}
		case 2: 
		{
			Mode[id] = 3
			
			Set_WeaponAnim(id, ANIM_SLASH3)
			Create_FakeEnt(id, 2, 0)
			
			set_pdata_float(Ent, 46, SLASH_NEXTATTACK, 4)
			set_pdata_float(Ent, 47, SLASH_NEXTATTACK, 4)
			set_pdata_float(Ent, 48, SLASH_NEXTIDLE + 0.5, 4)
			
			PlayerAttack[id][Power[id]] = 4
			CheckCode(id)
		}
		case 3: 
		{
			Mode[id] = 0
			
			Set_WeaponAnim(id, ANIM_SLASH4)
			
			set_pdata_float(Ent, 46, SLASH4_NEXTATTACK, 4)
			set_pdata_float(Ent, 47, SLASH4_NEXTATTACK, 4)
			set_pdata_float(Ent, 48, SLASH_NEXTIDLE + 0.5, 4)
			
			PlayerAttack[id][Power[id]] = 5
			static Skill; Skill = CheckCode(id)
			Create_FakeEnt(id, 3, Skill)
		}
	}
	
	Attack3(id)
	
	return HAM_SUPERCEDE
}

public CheckCode(id)
{
	if(PlayerAttack[id][Power[id]] == Key[Power[id]])
	{
		Power[id]++
		if(Power[id] >= 11)
		{
			Power[id] = 0
			return 1
		}
	}
	else
	{
		Power[id] = 0
	}
	
	return 0
}

public Create_FakeEnt(id, Anim, HavePower)
{
	static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target")) 
	
	set_pev(Ent, pev_classname, ATK2_CLASSNAME)
	set_pev(Ent, pev_movetype, MOVETYPE_FLY)
	engfunc(EngFunc_SetModel, Ent, v_modelfx)
	set_pev(Ent, pev_owner, id)
	
	if(Anim == 3)
	{
		set_pev(Ent, pev_fuser4, get_gametime() + 0.5)
		set_pev(Ent, pev_iuser4, 1)
		set_pev(Ent, pev_iuser3, HavePower)
	}
	
	fm_set_rendering(Ent, kRenderNormal, 255, 255, 255, kRenderTransAdd, 255)
	
	set_pev(Ent, pev_sequence, Anim)
	set_pev(Ent, pev_framerate , 1.0)
	
	set_pev(Ent, pev_solid, SOLID_NOT)
	set_pev(Ent, pev_nextthink, get_gametime() + 0.01)
}

public Atk2_Think(Ent)
{
	if(!pev_valid(Ent))
		return

	static Owner; Owner = pev(Ent, pev_owner)
	
	if(!is_user_alive(Owner))
	{
		set_pev(Ent, pev_flags, FL_KILLME)
		return
	}
	
	if(get_user_weapon(Owner) != CSW_KNIFE || !Get_BitVar(g_had_dps, Owner) || !Get_BitVar(is_mode2, Owner))
	{
		set_pev(Ent, pev_flags, FL_KILLME)
		return
	}
	
	static Float:Light; pev(Ent, pev_renderamt, Light)
	
	Light -= 4.0
	//Light -= 20.0
	Light = floatmax(Light, 0.0)
	set_pev(Ent, pev_renderamt, Light)
	
	if(!Light)
	{
		set_pev(Ent, pev_flags, FL_KILLME)
		return
	}
	
	if(pev(Ent, pev_iuser4))
	{
		if(pev(Ent, pev_fuser4) < get_gametime())
		{
			set_pev(Ent, pev_iuser4, 0)
			if(pev(Ent, pev_iuser3))
			{
				Create_Skill(Owner)
				engfunc(EngFunc_EmitSound, Owner, CHAN_WEAPON, SwordsSounds[14], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
				set_pev(Ent, pev_flags, FL_KILLME)
			}
			else
			{
				engfunc(EngFunc_EmitSound, Owner, CHAN_WEAPON, SwordsSounds[13], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
			}
		}
	}
	
	static Float:vOrigin[3], Float:vUp[3], Float:Angles[3]
	
	pev(Owner, pev_origin, vOrigin)
	pev(Owner, pev_view_ofs,vUp)
	xs_vec_add(vOrigin, vUp, vOrigin)
	
	pev(Owner, pev_v_angle, Angles)
	angle_vector(Angles, ANGLEVECTOR_FORWARD, Angles)
	vector_to_angle(Angles, Angles)
	
	set_pev(Ent, pev_origin, vOrigin)
	set_pev(Ent, pev_angles, Angles)
	
	set_pev(Ent, pev_nextthink, get_gametime() + 0.01)
}

public Create_Skill(id)
{
	Set_WeaponAnim(id, ANIM_SKILLSTART)
	Set_WeaponIdleTime(id, CSW_KNIFE, SKILL_STARTTIME + 0.5)
	Set_PlayerNextAttack(id, SKILL_STARTTIME)
	
	UnSet_BitVar(is_attacked, id)
	Mode[id] = 0
	AttackType[id] = 0
	
	static Float:Origin[3]
	pev(id, pev_origin, Origin)
	
	static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
	
	set_pev(Ent, pev_classname, EF_CLASSNAME)
	engfunc(EngFunc_SetModel, Ent, skill_model)
	set_pev(Ent, pev_origin, Origin)
	set_pev(Ent, pev_movetype, MOVETYPE_FLY)
	set_pev(Ent, pev_owner, id)

	set_pev(Ent, pev_fuser4, get_gametime())
	set_pev(Ent, pev_fuser3, get_gametime())
	set_pev(Ent, pev_fuser2, get_gametime())
	set_pev(Ent, pev_fuser1, get_gametime())
	set_pev(Ent, pev_iuser4, 0)
	
	set_pev(Ent, pev_animtime, get_gametime())
	set_pev(Ent, pev_frame, 0)
	set_pev(Ent, pev_framerate , 1.0)
	set_pev(Ent, pev_sequence, 0)
	
	set_pev(Ent, pev_nextthink, get_gametime() + 0.01)
}

public Ef_Think(Ent)
{
	if(!pev_valid(Ent))
		return
	
	static Owner; Owner = pev(Ent, pev_owner)
	
	if(!is_user_alive(Owner))
	{
		set_pev(Ent, pev_flags, FL_KILLME)
		return
	}
		
	if(get_user_weapon(Owner) != CSW_KNIFE || !Get_BitVar(g_had_dps, Owner) || !Get_BitVar(is_mode2, Owner))
	{
		set_pev(Ent, pev_flags, FL_KILLME)
		return
	}
	
	static Float:Origin[3], Float:Angles[3]
	pev(Owner, pev_origin, Origin)
	pev(Owner, pev_angles, Angles)
	
	Stock_Hook_Ent(Ent, Origin, 1000.0)
	set_pev(Ent, pev_angles, Angles)
	
	static Mode; Mode = pev(Ent, pev_iuser4)
	static Float: Time; pev(Ent, pev_fuser4, Time)
	static Float: AttackTime1; pev(Ent, pev_fuser3, AttackTime1)
	static Float: AttackTime2; pev(Ent, pev_fuser2, AttackTime2)
	static Float: AttackTime3; pev(Ent, pev_fuser1, AttackTime3)
	
	if(Mode == 0)
	{
		if(get_gametime() - 1.0 > Time)
		{
			set_pev(Ent, pev_fuser4, get_gametime())
			set_pev(Ent, pev_iuser4, 1)
			
			Set_WeaponAnim(Owner, ANIM_SKILLLOOP)
			Set_WeaponIdleTime(Owner, CSW_KNIFE, SKILL_TIME + 0.5)
			Set_PlayerNextAttack(Owner, SKILL_TIME)
			
			set_pev(Ent, pev_origin, Origin)
			set_pev(Ent, pev_effects, pev(Ent, pev_effects) | EF_NODRAW) 
		}
	}
	else if(Mode == 1)
	{
		if(get_gametime() - 10.25 > Time)
		{
			set_pev(Ent, pev_fuser4, get_gametime())
			set_pev(Ent, pev_iuser4, 2)
				
			set_pev(Ent, pev_origin, Origin)
			set_pev(Ent, pev_effects, pev(Ent, pev_effects) &~ EF_NODRAW) 
			
			set_pev(Ent, pev_animtime, get_gametime())
			set_pev(Ent, pev_frame, 0)
			set_pev(Ent, pev_framerate , 1.0)
			set_pev(Ent, pev_sequence, 1)
		}
		if(get_gametime() - 0.15 > AttackTime1)
		{
			set_pev(Ent, pev_fuser3, get_gametime())
			DealDamage(Owner)
		}
		if(get_gametime() - 0.1 > AttackTime2)
		{
			set_pev(Ent, pev_fuser2, get_gametime())
			GoldSword(Owner)
		}
		if(get_gametime() - 0.05 > AttackTime3)
		{
			set_pev(Ent, pev_fuser1, get_gametime())
			BlueSword(Owner)
		}
	}
	else 
	{
		if(get_gametime() - 1.5 > Time)
		{
		 	set_pev(Ent, pev_flags, FL_KILLME)
			return
		}
	}
	
	set_pev(Ent, pev_nextthink, get_gametime() + 0.01)
}

public DealDamage(id)
{
	static Ent, Float:Origin[3]
	
	Ent = FM_NULLENT
	pev(id, pev_origin, Origin)
	
	while((Ent = engfunc(EngFunc_FindEntityInSphere, Ent, Origin, 250.0)) != 0)
	{
		if(!pev_valid(Ent))
			continue
		
		if(pev(Ent, pev_takedamage) == DAMAGE_NO)
			continue
			
		if(is_user_alive(Ent) && get_user_team(Ent) == get_user_team(id))
			continue
	
		ExecuteHamB(Ham_TakeDamage, Ent, id, id, SKILL_DAMAGE, DMG_BULLET)
		
		static Float:VicOrigin[3]
		pev(Ent, pev_origin, VicOrigin)
		
		SpawnBlood(VicOrigin, 247, 255)
	}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public BlueSword(id)
{
	static Float:Origin[3], Float:StartPoint[3], Float:EndPoint[3]
	static Float:FloatX, Float:FloatY, Float:FloatZ	
	
	pev(id, pev_origin, Origin)
	
	switch(random_num(0, 1))
	{
		case 0:
		{
			FloatX = Float1[random_num(0, 41)]
			FloatY = Float1[random_num(40, 41)]
			FloatZ = Float2[random_num(0, 15)]
		}
		case 1:
		{
			FloatX = Float1[random_num(40, 41)]
			FloatY = Float1[random_num(0, 41)]
			FloatZ = Float2[random_num(0, 15)]
		}
	}
	
	xs_vec_set(StartPoint, Origin[0] + FloatX, Origin[1] + FloatY, Origin[2] + FloatZ)
	
	engfunc(EngFunc_TraceLine, Origin, StartPoint, IGNORE_MONSTERS, 0, 0)
	get_tr2(0, TR_vecEndPos, StartPoint)
	
	xs_vec_set(EndPoint, Origin[0] + random_float(-150.0, 150.0), Origin[1] + random_float(-150.0, 150.0), Origin[2] + random_float(-18.0, 125.0))
	
	Create_BlueSword(id, StartPoint, EndPoint)
}

public Create_BlueSword(id, Float:Start[3], Float:End[3])
{
	static Ent, Float:Angles[3], Float:Velocity[3]
	
	xs_vec_sub(End, Start, Angles)
	vector_to_angle(Angles, Angles)
	get_speed_vector(Start, End, 1750.0, Velocity)
	
	Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
	
	set_pev(Ent, pev_classname, SWORD1_CLASSNAME)
	set_pev(Ent, pev_movetype, MOVETYPE_FLY)
	set_pev(Ent, pev_solid, SOLID_TRIGGER)
	set_pev(Ent, pev_origin, Start)
	set_pev(Ent, pev_angles, Angles)
	
	set_pev(Ent, pev_owner, id)
	set_pev(Ent, pev_iuser3, get_user_team(id))
	
	engfunc(EngFunc_SetModel, Ent, blueblade_model)
	fm_set_rendering(Ent, kRenderNormal, 255, 255, 255, kRenderTransAdd, 255)
	
	set_pev(Ent, pev_animtime, get_gametime())
	set_pev(Ent, pev_frame, 0)
	set_pev(Ent, pev_framerate , 1.0)
	set_pev(Ent, pev_sequence, 0)
	
	// Create Velocity
	set_pev(Ent, pev_velocity, Velocity)
	
	emit_sound(Ent, CHAN_BODY, SwordsSounds[random_num(0, 4)], 1.0, ATTN_NORM, 0, PITCH_NORM)
	
	set_pev(Ent, pev_nextthink, get_gametime() + 0.25)
}

public Sword1_Think(Ent)
{
	if(!pev_valid(Ent))
		return
	
	set_pev(Ent, pev_flags, FL_KILLME)
}

public Sword1_Touch(Ent, Touch)
{
	if(!pev_valid(Ent))
		return
	
	if(!is_user_alive(Touch))
	{
		static Classname[32]
		pev(Touch, pev_classname, Classname, charsmax(Classname))
		
		if(equali(Classname, SWORD1_CLASSNAME))
			return
	
		set_pev(Ent, pev_flags, FL_KILLME)
	}
	else
	{
		static Team; Team = pev(Ent, pev_iuser3)
		
		if(get_user_team(Touch) == Team)
			return
		
		static Float:Origin[3]
		pev(Ent, pev_origin, Origin)
		
		SpawnBlood(Origin, 247, 255)
	}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public GoldSword(id)
{
	static Float:Origin[3], Float:Point[3], Float:Angles[3]
	static Float:FloatX, Float:FloatY, Float:FloatZ 
	
	FloatX = Float3[random_num(0, 40)]
	FloatY = Float3[random_num(0, 40)]
	FloatZ = random_float(0.0, 75.0)
	
	pev(id, pev_origin, Origin)
	xs_vec_set(Point, Origin[0] + FloatX, Origin[1] + FloatY, Origin[2] + FloatZ)
	
	engfunc(EngFunc_TraceLine, Origin, Point, IGNORE_MONSTERS, 0, 0)
	get_tr2(0, TR_vecEndPos, Point)
	
	xs_vec_set(Angles, 0.0, random_float(-180.0, 180.0), 0.0)
	
	Create_GoldSword(id, Point, Angles)
	
	for(new i = 1; i <= get_playersnum(); i++)
	{
		if(!is_user_alive(i))	
			continue
			
		if(get_user_team(i) == get_user_team(id))
			continue
			
		if(fm_entity_range(i, id) > 100.0)
			continue
	
		static Float:VicOrigin[3]
		pev(i, pev_origin, VicOrigin)
		
		SpawnBlood(VicOrigin, 247, 255)
	}
}

public Create_GoldSword(id, Float:Origin[3], Float:Angles[3])
{
	static Ent
	
	Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_sprite"))
	
	set_pev(Ent, pev_classname, SWORD2_CLASSNAME)
	set_pev(Ent, pev_movetype, MOVETYPE_FLY)
	set_pev(Ent, pev_origin, Origin)
	set_pev(Ent, pev_angles, Angles)
	
	set_pev(Ent, pev_owner, id)
	
	engfunc(EngFunc_SetModel, Ent, goldblade_model)
	fm_set_rendering(Ent, kRenderNormal, 255, 255, 255, kRenderTransAdd, 255)
	
	set_pev(Ent, pev_fuser4, get_gametime() + 0.1)
	set_pev(Ent, pev_iuser4, 1)
	
	set_pev(Ent, pev_animtime, get_gametime())
	set_pev(Ent, pev_frame, 0)
	set_pev(Ent, pev_framerate , 1.0)
	set_pev(Ent, pev_sequence, random_num(0, 2))
	
	set_pev(Ent, pev_nextthink, get_gametime() + 0.01)
}

public Sword2_Think(Ent)
{
	if(!pev_valid(Ent))
		return
	
	if(pev(Ent, pev_iuser4))
	{
		static Float:Time; pev(Ent, pev_fuser4, Time)
		if(Time < get_gametime())
		{
			set_pev(Ent, pev_iuser4, 0)
		}
	}
	else
	{
		static Float:Light; pev(Ent, pev_renderamt, Light)
	
		Light -= 10.0
		Light = floatmax(Light, 0.0)
		set_pev(Ent, pev_renderamt, Light)
	
		if(!Light)
		{
			set_pev(Ent, pev_flags, FL_KILLME)
			return
		}
	}
	
	set_pev(Ent, pev_nextthink, get_gametime() + 0.01)
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public Attack1(id)
{
	static iHitResult2
	
	iHitResult2 = Knife_Damage(id, STAB_RANGE1, STAB_ANGLE1, STAB_DAMAGE1, 0)
	switch(iHitResult2)
	{
		case HIT_ENEMY:
		{
			engfunc(EngFunc_EmitSound, id, CHAN_WEAPON, SwordsSounds[random_num(10, 11)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
		}
		case HIT_WALL:
		{
			engfunc(EngFunc_EmitSound, id, CHAN_WEAPON, SwordsSounds[12], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
		}
	}
}

public Attack2(id)
{
	static iHitResult2
	
	iHitResult2 = Knife_Damage(id, STAB_RANGE2, STAB_ANGLE2, STAB_DAMAGE2, 0)
	switch(iHitResult2)
	{
		case HIT_ENEMY:
		{
			engfunc(EngFunc_EmitSound, id, CHAN_WEAPON, SwordsSounds[random_num(10, 11)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
		}
		case HIT_WALL:
		{
			engfunc(EngFunc_EmitSound, id, CHAN_WEAPON, SwordsSounds[12], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
		}
	}
}

public Attack3(id)
{
	static iHitResult2
	
	iHitResult2 = Knife_Damage(id, SLASH_RANGE, SLASH_ANGLE, SLASH_DAMAGE, 1)
	switch(iHitResult2)
	{
		case HIT_ENEMY:
		{
			engfunc(EngFunc_EmitSound, id, CHAN_WEAPON, SwordsSounds[random_num(5, 7)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
		}
		case HIT_WALL:
		{
			engfunc(EngFunc_EmitSound, id, CHAN_WEAPON, SwordsSounds[12], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
		}
	}	
}

public Knife_Damage(id, Float:flRange, Float:fAngle, Float:flDamage, Mode)
{
	new iHitResult = HIT_NOTHING
	new Float:vecOrigin[3], Float:vecScr[3], Float:vecEnd[3], Float:V_Angle[3], Float:vecForward[3]
	pev(id, pev_origin, vecOrigin)
	GetGunPosition(id, vecScr)
	pev(id, pev_v_angle, V_Angle)
	engfunc(EngFunc_MakeVectors, V_Angle)
	global_get(glb_v_forward, vecForward)
	xs_vec_mul_scalar(vecForward, flRange, vecForward)
	xs_vec_add(vecScr, vecForward, vecEnd)

	new tr = create_tr2()
	engfunc(EngFunc_TraceLine, vecScr, vecEnd, 0, id, tr)
	new Float:flFraction
	get_tr2(tr, TR_flFraction, flFraction)
	
	if(flFraction < 1.0) 
	{
		iHitResult = HIT_WALL
		
		new Float:EndPos2[3]
		get_tr2(tr, TR_vecEndPos, EndPos2)
		if(Mode) Make_Effect2(EndPos2)
		else Make_Effect1(EndPos2)
	}

	new Float:vecEndZ = vecEnd[2]
	new pEntity = -1
	
	while((pEntity = engfunc(EngFunc_FindEntityInSphere, pEntity, vecOrigin, flRange)) != 0)
	{
		if(!pev_valid(pEntity))
		continue

		if(!IsAlive(pEntity))
		continue

		if(fAngle < 120.0 && !CheckAngle(id, pEntity, fAngle))
		continue

		GetGunPosition(id, vecScr)
		Stock_Get_Origin(pEntity, vecEnd)
		vecEnd[2] = vecScr[2] + (vecEndZ - vecScr[2]) * (get_distance_f(vecScr, vecEnd) / flRange)
		
		engfunc(EngFunc_TraceLine, vecScr, vecEnd, 0, id, tr)
		get_tr2(tr, TR_flFraction, flFraction)

		if(flFraction >= 1.0) engfunc(EngFunc_TraceHull, vecScr, vecEnd, 0, 3, id, tr)
		
		get_tr2(tr, TR_flFraction, flFraction)
		new pHit = get_tr2(tr, TR_pHit)
		
		if(flFraction < 1.0)
		{
			new Float:EndPos[3]
			get_tr2(tr, TR_vecEndPos, EndPos)
			if(IsPlayer(pEntity) || IsHostage(pEntity))
			{
				iHitResult = HIT_ENEMY
				if(CheckBack(id, pEntity)) flDamage *= 3.0
				
				if(Mode) Make_Effect2(EndPos)
				else Make_Effect1(EndPos)
			}
		
			if(pev_valid(pEntity) && pHit == pEntity && id != pEntity && !(pev(pEntity, pev_spawnflags) & SF_BREAK_TRIGGER_ONLY))
			{
				Native_ExecuteAttack(id, pEntity, id, Float:flDamage, 1, DMG_NEVERGIB)
			}
		}
		free_tr2(tr)
	}
	return iHitResult
}

public Native_ExecuteAttack(iAttacker, iVictim, iEntity, Float:fDamage, iHeadShot, iDamageBit)
{
	if (pev(iVictim, pev_takedamage) <= 0.0)
	return 0

	new Float:fOrigin[3], Float:fEnd[3], iTarget, iBody, Float:fMultifDamage
	pev(iAttacker, pev_origin, fOrigin)
	get_user_aiming(iAttacker, iTarget, iBody)
	fm_get_aim_origin(iAttacker, fEnd)
	new ptr = create_tr2()
	new iHitGroup = get_tr2(ptr, TR_iHitgroup)
	if (iTarget == iVictim) iHitGroup = iBody
	else pev(iVictim, pev_origin, fEnd)
	engfunc(EngFunc_TraceLine, fOrigin, fEnd, DONT_IGNORE_MONSTERS, iAttacker, ptr)
	if (iHitGroup == HIT_HEAD && !iHeadShot) iHitGroup = HIT_CHEST

	set_pdata_int(iVictim, 75, iHitGroup, 4)
	switch(iHitGroup)
	{
		case HIT_HEAD: fMultifDamage  = 4.0
		case HIT_CHEST: fMultifDamage  = 1.0
		case 3: fMultifDamage  = 1.25
		case 4,5,6,7: fMultifDamage  = 0.75
		default: fMultifDamage  = 1.0
	}
	fDamage *= fMultifDamage

	if (get_cvar_num("mp_friendlyfire") || (!get_cvar_num("mp_friendlyfire") && get_pdata_int(iAttacker, 114) != get_pdata_int(iVictim, 114)))
	{
		if (is_user_alive(iVictim)) SpawnBlood(fEnd, 247, floatround(fDamage))
	}

	ExecuteHamB(Ham_TakeDamage, iVictim, iEntity, iAttacker, fDamage, iDamageBit)
	free_tr2(ptr)
	return 1
}

stock IsPlayer(pEntity) return is_user_connected(pEntity)

stock IsHostage(pEntity)
{
	new classname[32]; pev(pEntity, pev_classname, classname, charsmax(classname))
	return equal(classname, "hostage_entity")
}

stock IsAlive(pEntity)
{
	if (pEntity < 1) return 0
	return (pev(pEntity, pev_deadflag) == DEAD_NO && pev(pEntity, pev_health) > 0)
}

stock GetGunPosition(id, Float:vecScr[3])
{
	new Float:vecViewOfs[3]
	pev(id, pev_origin, vecScr)
	pev(id, pev_view_ofs, vecViewOfs)
	xs_vec_add(vecScr, vecViewOfs, vecScr)
}

stock CheckBack(iEnemy,id)
{
	new Float:anglea[3], Float:anglev[3]
	pev(iEnemy, pev_v_angle, anglea)
	pev(id, pev_v_angle, anglev)
	new Float:angle = anglea[1] - anglev[1] 
	if (angle < -180.0) angle += 360.0
	if (angle <= 45.0 && angle >= -45.0) return 1
	return 0
}

stock CheckAngle(iAttacker, iVictim, Float:fAngle)  return(Stock_CheckAngle(iAttacker, iVictim) > floatcos(fAngle,degrees))

stock Float:Stock_CheckAngle(id,iTarget)
{
	new Float:vOricross[2],Float:fRad,Float:vId_ori[3],Float:vTar_ori[3],Float:vId_ang[3],Float:fLength,Float:vForward[3]
	Stock_Get_Origin(id, vId_ori)
	Stock_Get_Origin(iTarget, vTar_ori)
	
	pev(id,pev_angles,vId_ang)
	for(new i=0;i<2;i++) vOricross[i] = vTar_ori[i] - vId_ori[i]
	
	fLength = floatsqroot(vOricross[0]*vOricross[0] + vOricross[1]*vOricross[1])
	
	if (fLength<=0.0)
	{
		vOricross[0]=0.0
		vOricross[1]=0.0
	} else {
		vOricross[0]=vOricross[0]*(1.0/fLength)
		vOricross[1]=vOricross[1]*(1.0/fLength)
	}
	
	engfunc(EngFunc_MakeVectors,vId_ang)
	global_get(glb_v_forward,vForward)
	
	fRad = vOricross[0]*vForward[0]+vOricross[1]*vForward[1]
	
	return fRad   //->   RAD 90' = 0.5rad
}

stock Stock_Get_Origin(id, Float:origin[3])
{
	new Float:maxs[3],Float:mins[3]
	if (pev(id, pev_solid) == SOLID_BSP)
	{
		pev(id,pev_maxs,maxs)
		pev(id,pev_mins,mins)
		origin[0] = (maxs[0] - mins[0]) / 2 + mins[0]
		origin[1] = (maxs[1] - mins[1]) / 2 + mins[1]
		origin[2] = (maxs[2] - mins[2]) / 2 + mins[2]
	} else pev(id, pev_origin, origin)
}

stock SpawnBlood(const Float:vecOrigin[3], iColor, iAmount)
{
	if(iAmount == 0)
	return

	if(!iColor)
	return

	iAmount *= 2
	if(iAmount > 255) iAmount = 255
	engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vecOrigin)
	write_byte(TE_BLOODSPRITE)
	engfunc(EngFunc_WriteCoord, vecOrigin[0])
	engfunc(EngFunc_WriteCoord, vecOrigin[1])
	engfunc(EngFunc_WriteCoord, vecOrigin[2])
	write_short(spr_blood_spray)
	write_short(spr_blood_drop)
	write_byte(iColor)
	write_byte(min(max(3, iAmount / 10), 16))
	message_end()
}

stock Make_Effect1(Float:Origin[3])
{
	engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin)
	write_byte(TE_BLOODSPRITE)
	engfunc(EngFunc_WriteCoord, Origin[0])
	engfunc(EngFunc_WriteCoord, Origin[1])
	engfunc(EngFunc_WriteCoord, Origin[2])
	write_short(sprleaf1)
	write_short(sprleaf1)
	write_byte(230)
	write_byte(3)
	message_end()
	
	engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin)
	write_byte(TE_BLOODSPRITE)
	engfunc(EngFunc_WriteCoord, Origin[0])
	engfunc(EngFunc_WriteCoord, Origin[1])
	engfunc(EngFunc_WriteCoord, Origin[2])
	write_short(sprleaf2)
	write_short(sprleaf2)
	write_byte(71)
	write_byte(3)
	message_end()
}

stock Make_Effect2(Float:Origin[3])
{
	engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin)
	write_byte(TE_BLOODSPRITE)
	engfunc(EngFunc_WriteCoord, Origin[0])
	engfunc(EngFunc_WriteCoord, Origin[1])
	engfunc(EngFunc_WriteCoord, Origin[2])
	write_short(sprpetal1)
	write_short(sprpetal1)
	write_byte(144)
	write_byte(3)
	message_end()
	
	engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin)
	write_byte(TE_BLOODSPRITE)
	engfunc(EngFunc_WriteCoord, Origin[0])
	engfunc(EngFunc_WriteCoord, Origin[1])
	engfunc(EngFunc_WriteCoord, Origin[2])
	write_short(sprpetal2)
	write_short(sprpetal2)
	write_byte(150)
	write_byte(3)
	message_end()
}

stock Set_WeaponAnim(id, anim)
{
	set_pev(id, pev_weaponanim, anim)
	
	message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id)
	write_byte(anim)
	write_byte(pev(id, pev_body))
	message_end()
}

stock get_angle_to_target(id, const Float:fTarget[3], Float:TargetSize = 0.0)
{
	static Float:fOrigin[3], iAimOrigin[3], Float:fAimOrigin[3], Float:fV1[3]
	pev(id, pev_origin, fOrigin)
	get_user_origin(id, iAimOrigin, 3) // end position from eyes
	IVecFVec(iAimOrigin, fAimOrigin)
	xs_vec_sub(fAimOrigin, fOrigin, fV1)
	
	static Float:fV2[3]
	xs_vec_sub(fTarget, fOrigin, fV2)
	
	static iResult; iResult = get_angle_between_vectors(fV1, fV2)
	
	if (TargetSize > 0.0)
	{
		static Float:fTan; fTan = TargetSize / get_distance_f(fOrigin, fTarget)
		static fAngleToTargetSize; fAngleToTargetSize = floatround( floatatan(fTan, degrees) )
		iResult -= (iResult > 0) ? fAngleToTargetSize : -fAngleToTargetSize
	}
	
	return iResult
}

stock get_angle_between_vectors(const Float:fV1[3], const Float:fV2[3])
{
	static Float:fA1[3], Float:fA2[3]
	engfunc(EngFunc_VecToAngles, fV1, fA1)
	engfunc(EngFunc_VecToAngles, fV2, fA2)
	
	static iResult; iResult = floatround(fA1[1] - fA2[1])
	iResult = iResult % 360
	iResult = (iResult > 180) ? (iResult - 360) : iResult
	
	return iResult
}	

stock get_position(id,Float:forw, Float:right, Float:up, Float:vStart[])
{
	new Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
	
	pev(id, pev_origin, vOrigin)
	pev(id, pev_view_ofs,vUp) //for player
	xs_vec_add(vOrigin,vUp,vOrigin)
	pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
	
	angle_vector(vAngle,ANGLEVECTOR_FORWARD,vForward) //or use EngFunc_AngleVectors
	angle_vector(vAngle,ANGLEVECTOR_RIGHT,vRight)
	angle_vector(vAngle,ANGLEVECTOR_UP,vUp)
	
	vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
	vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
	vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
}

stock Set_WeaponIdleTime(id, WeaponId ,Float:TimeIdle)
{
	static entwpn; entwpn = fm_get_user_weapon_entity(id, WeaponId)
	if(!pev_valid(entwpn)) 
		return
		
	set_pdata_float(entwpn, 48, TimeIdle + 0.5, 4)
}

stock Set_PlayerNextAttack(id, Float:nexttime)
{
	set_pdata_float(id, 83, nexttime, 5)
}

stock Stock_Hook_Ent(ent, Float:TargetOrigin[3], Float:Speed)
{
	static Float:fl_Velocity[3], Float:EntOrigin[3], Float:distance_f, Float:fl_Time
	pev(ent, pev_origin, EntOrigin)
	
	distance_f = get_distance_f(EntOrigin, TargetOrigin)
	fl_Time = distance_f / Speed
	
	if(distance_f > 0.1)
	{
		fl_Velocity[0] = (TargetOrigin[0] - EntOrigin[0]) / fl_Time
		fl_Velocity[1] = (TargetOrigin[1] - EntOrigin[1]) / fl_Time
		fl_Velocity[2] = (TargetOrigin[2] - EntOrigin[2]) / fl_Time
	}
	else
	{
		fl_Velocity[0] = 0.0
		fl_Velocity[1] = 0.0
		fl_Velocity[2] = 0.0
	}

	set_pev(ent, pev_velocity, fl_Velocity)
}

stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
{
	new_velocity[0] = origin2[0] - origin1[0]
	new_velocity[1] = origin2[1] - origin1[1]
	new_velocity[2] = origin2[2] - origin1[2]
	new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
	new_velocity[0] *= num
	new_velocity[1] *= num
	new_velocity[2] *= num
	
	return 1;
}
Image

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

#11

Post by Raheem » 5 years ago

Here i added native:

  1. /* Plugin generated by AMXX-Studio */
  2.  
  3. #pragma compress 1
  4.  
  5. #include <zombie_escape>
  6. #include <fakemeta_util>
  7. #include <fun>
  8. #include <cstrike>
  9. #include <xs>
  10. #include <engine>
  11.  
  12. #define PLUGIN "Dual Sword Phantom Slayer"
  13. #define VERSION "1.0"
  14. #define AUTHOR "Bim Bim Cay"
  15. #define VIP_FLAG "VIP_A"
  16.  
  17. #define v_model "models/v_dualsword.mdl"
  18. #define v_modelfx "models/v_dualswordfx.mdl"
  19.  
  20. #define p_modela "models/p_dualsword_a.mdl"
  21. #define p_modelb "models/p_dualsword_b.mdl"
  22.  
  23. #define skill_model "models/dualsword_skill.mdl"
  24. #define blueblade_model "models/dualsword_skillfx2.mdl"
  25. #define goldblade_model "models/dualsword_skillfx1.mdl"
  26.  
  27. //Blue Blade
  28. #define spr_leaf1 "sprites/leaf01_dualsword.spr"
  29. #define spr_leaf2 "sprites/leaf02_dualsword.spr"
  30.  
  31. //Gold Blade
  32. #define spr_petal1 "sprites/petal01_dualsword.spr"
  33. #define spr_petal2 "sprites/petal02_dualsword.spr"
  34.  
  35. //Ef Spr (Sorry, I think only csbte can do it)
  36. #define spr_efleft "sprites/ef_dualsword_left.spr"
  37. #define spr_efright "sprites/ef_dualsword_right.spr"
  38.  
  39. new const SwordsSounds[15][] =
  40. {
  41.     "weapons/dualsword_fly1.wav",
  42.     "weapons/dualsword_fly2.wav",
  43.     "weapons/dualsword_fly3.wav",
  44.     "weapons/dualsword_fly4.wav",
  45.     "weapons/dualsword_fly5.wav",
  46.     "weapons/dualsword_hit1.wav",
  47.     "weapons/dualsword_hit2.wav",
  48.     "weapons/dualsword_hit3.wav",
  49.     "weapons/dualsword_skill_start.wav",
  50.     "weapons/dualsword_skill_end.wav",
  51.     "weapons/dualsword_stab1_hit.wav",
  52.     "weapons/dualsword_stab2_hit.wav",
  53.     "weapons/katana_hitwall.wav",
  54.     "weapons/dualsword_slash_4_1.wav",
  55.     "weapons/dualsword_slash_4_2.wav"
  56. }
  57.  
  58. //Other Sounds
  59. /*
  60. dualsword_idle_a.wav
  61. dualsword_idle_b.wav
  62. dualsword_slash_1.wav
  63. dualsword_slash_2.wav
  64. dualsword_slash_3.wav
  65. dualsword_slash_4.wav
  66. dualsword_slash_4-1.wav
  67. dualsword_slash_4-2.wav
  68. dualsword_slash_end.wav
  69. dualsword_stab1.wav
  70. dualsword_stab2.wav
  71. */
  72.  
  73. //Animations
  74. //Blades
  75. #define ANIM_IDLEA      0
  76. #define ANIM_SLASH1     1
  77. #define ANIM_SLASH2     2
  78. #define ANIM_SLASH3     3
  79. #define ANIM_SLASH4     4
  80. #define ANIM_SLASHEND       5
  81. #define ANIM_DRAWA      6
  82. #define ANIM_IDLEB      7
  83. #define ANIM_STAB1      8
  84. #define ANIM_STAB2      9
  85. #define ANIM_STABEND        10
  86. #define ANIM_DRAWB      11
  87. #define ANIM_SWABA      12
  88. #define ANIM_SWABB      13
  89. #define ANIM_SKILLSTART     14
  90. #define ANIM_SKILLLOOP      15
  91.  
  92. //Effects
  93. #define ANIM_EFSLASH1       0
  94. #define ANIM_EFSLASH2       1
  95. #define ANIM_EFSLASH3       2
  96. #define ANIM_EFSLASH4       3
  97.  
  98. //Config
  99. #define DRAW_TIME       0.233  
  100. #define SWAB_TIME       0.366
  101.  
  102. //SLASH
  103. #define SLASH_NEXTATTACK    0.1
  104. #define SLASH4_NEXTATTACK   0.7
  105. #define SLASH_NEXTIDLE      1.0
  106. #define SLASHEND_NEXTIDLE   2.0
  107. #define SLASH_DAMAGE        150.0
  108. #define SLASH_RANGE     175.0
  109. #define SLASH_ANGLE     60.0
  110.  
  111. //STAB
  112. #define STAB_DELAY1     0.06
  113. #define STAB_DELAY2     0.4
  114. #define STAB_NEXTATTACK1    0.43
  115. #define STAB_NEXTATTACK2    0.86
  116. #define STAB_NEXTIDLE1      0.7
  117. #define STAB_NEXTIDLE2      0.93
  118. #define STABEND_NEXTIDLE    1.43
  119. #define STAB_DAMAGE1        200.0
  120. #define STAB_RANGE1     200.0
  121. #define STAB_ANGLE1     30.0
  122. #define STAB_DAMAGE2        1000.0
  123. #define STAB_RANGE2     200.0
  124. #define STAB_ANGLE2     45.0
  125.  
  126. //Skill
  127. #define SKILL_STARTTIME     1.0
  128. #define SKILL_TIME      11.36
  129. #define SKILL_DAMAGE        200.0
  130.  
  131. //Entities
  132. #define ATK2_CLASSNAME      "Sugar"
  133. #define EF_CLASSNAME        "1000Swords"
  134. #define SWORD1_CLASSNAME    "Vinegar"
  135. #define SWORD2_CLASSNAME    "Chilli"
  136.  
  137. //Hit
  138. #define HIT_NOTHING             0
  139. #define HIT_ENEMY           1
  140. #define HIT_WALL            2
  141.  
  142. // MACROS
  143. #define Get_BitVar(%1,%2) (%1 & (1 << (%2 & 31)))
  144. #define Set_BitVar(%1,%2) %1 |= (1 << (%2 & 31))
  145. #define UnSet_BitVar(%1,%2) %1 &= ~(1 << (%2 & 31))
  146. #define MaskEnt(%0) (1<<(%0 & 31))
  147.  
  148. new g_had_dps, is_mode2, is_attacked
  149. new PlayerAttack[33][11], Mode[33], Power[33] , Float:AttackDelay[33], AttackType[33]
  150. new spr_blood_spray, spr_blood_drop, sprleaf1, sprleaf2, sprpetal1, sprpetal2
  151.  
  152. new const Key[11] =
  153. {
  154.     0,2,3,4,5,0,1,2,3,4,5
  155. }
  156.  
  157. new const Float:Float1[42] =
  158. {
  159.   50.0, -50.0, 60.0, -60.0, 70.0, -70.0, 80.0, -80.0, 90.0, -90.0, 100.0, -100.0, 110.0, -110.0, 120.0, -120.0, 130.0, -130.0, 140.0,-140.0,
  160.   150.0, -150.0, 160.0, -160.0, 170.0, -170.0, 180.0, -180.0, 190.0, -190.0, 200.0, -200.0, 210.0, -210.0, 220.0, -220.0, 230.0, -230.0,
  161.   240.0, -240.0, 250.0, -250.0
  162. }
  163.  
  164. new const Float:Float2[16] =
  165. {
  166.   -16.0, -15.0, -10.0, 0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 110.0, 120.0
  167. }
  168.  
  169. new const Float:Float3[41] =
  170. {
  171.   0.0, 10.0, -10.0, 20.0, -20.0, 30.0, -30.0, 40.0, -40.0, 50.0, -50.0, 60.0, -60.0, 70.0, -70.0, 80.0, -80.0, 90.0, -90.0, 100.0, -100.0, 110.0, -110.0, 120.0, -120.0, 130.0, -130.0, 140.0,-140.0,
  172.   150.0, -150.0, 160.0, -160.0, 170.0, -170.0, 180.0, -180.0, 190.0, -190.0, 200.0, -200.0
  173. }
  174.    
  175. public plugin_init()
  176. {
  177.     register_plugin(PLUGIN, VERSION, AUTHOR)
  178.    
  179.     register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
  180.     register_forward(FM_AddToFullPack, "fw_AddToFullPack_Post", 1)
  181.    
  182.     register_think(ATK2_CLASSNAME, "Atk2_Think")
  183.     register_think(EF_CLASSNAME, "Ef_Think")
  184.     register_think(SWORD1_CLASSNAME, "Sword1_Think")
  185.     register_think(SWORD2_CLASSNAME, "Sword2_Think")
  186.    
  187.     register_touch(SWORD1_CLASSNAME, "*", "Sword1_Touch")
  188.    
  189.     RegisterHam(Ham_Item_Deploy,"weapon_knife", "fw_Item_Deploy_Post", 1)
  190.     RegisterHam(Ham_Item_Holster, "weapon_knife", "fw_Item_Holster_Post", 1)
  191.     RegisterHam(Ham_Weapon_WeaponIdle,"weapon_knife", "fw_Weapon_WeaponIdle_Post", 1)
  192.    
  193.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_knife", "fw_Weapon_PrimaryAttack")
  194.     RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_knife", "fw_Weapon_SecondaryAttack")
  195.     RegisterHam(Ham_Item_PostFrame, "weapon_knife", "fw_Item_PostFrame")
  196.    
  197.     dsp = ze_register_item("Dual Sword Phantom Slayer", 150, 0)
  198.     ze_set_item_vip(dsp, VIP_FLAG)
  199.     register_clcmd("get_dsp", "get_dsp")
  200. }
  201.  
  202. public plugin_precache()
  203. {
  204.     precache_model(v_model)
  205.     precache_model(v_modelfx)
  206.     precache_model(p_modela)
  207.     precache_model(p_modelb)
  208.     precache_model(skill_model)
  209.     precache_model(blueblade_model)
  210.     precache_model(goldblade_model)
  211.    
  212.     for(new i = 0; i < sizeof(SwordsSounds); i++)
  213.         precache_sound(SwordsSounds[i])
  214.    
  215.     sprleaf1 = precache_model(spr_leaf1)
  216.     sprleaf2 = precache_model(spr_leaf2)
  217.     sprpetal1 = precache_model(spr_petal1)
  218.     sprpetal2 = precache_model(spr_petal2)
  219.     spr_blood_spray = precache_model("sprites/bloodspray.spr")
  220.     spr_blood_drop = precache_model("sprites/blood.spr")
  221. }
  222.  
  223. public plugin_natives()
  224. {
  225.     register_native("give_daul_sword", "native_give_daul_sword", 1)
  226. }
  227.  
  228. public native_give_daul_sword(id)
  229. {
  230.     GetWeapon(id)
  231. }
  232.  
  233. public ze_user_infected(iVictim)
  234. {
  235.     RemoveWeapon(iVictim)
  236. }
  237.    
  238. public GetWeapon(id)
  239. {
  240.     get_dsp(id)
  241. }
  242.  
  243. public RemoveWeapon(id)
  244. {
  245.     remove_dsp(id)
  246. }
  247.    
  248. public get_dsp(id)
  249. {
  250.     if(!is_user_alive(id))
  251.         return
  252.    
  253.     if(Get_BitVar(g_had_dps, id))
  254.         return
  255.    
  256.     Set_BitVar(g_had_dps, id)
  257.     UnSet_BitVar(is_mode2, id)
  258.     UnSet_BitVar(is_attacked, id)
  259.     AttackType[id] = 0
  260.     Power[id] = 0
  261.     Mode[id] = 0
  262.  
  263.     static Ent; Ent = fm_get_user_weapon_entity(id, CSW_KNIFE)
  264.    
  265.     if(!pev_valid(Ent))
  266.         return
  267.    
  268.     if(get_pdata_cbase(id, 373) != Ent)
  269.         return
  270.    
  271.     ExecuteHamB(Ham_Item_Deploy, Ent)
  272. }
  273.  
  274. public remove_dsp(id)
  275. {
  276.     UnSet_BitVar(g_had_dps, id)
  277.     UnSet_BitVar(is_mode2, id)
  278.     UnSet_BitVar(is_attacked, id)
  279.     AttackType[id] = 0
  280.     Power[id] = 0
  281.     Mode[id] = 0
  282. }
  283.  
  284. public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
  285. {
  286.     if(!is_user_alive(id))
  287.         return FMRES_IGNORED   
  288.     if(get_user_weapon(id) == CSW_KNIFE && Get_BitVar(g_had_dps, id))
  289.         set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001)
  290.    
  291.     return FMRES_HANDLED
  292. }  
  293. //Too much CPU but I don't have other choices now
  294. public fw_AddToFullPack_Post(esState, iE, iEnt, iHost, iHostFlags, iPlayer, pSet)
  295. {
  296.     if(!pev_valid(iEnt))
  297.         return
  298.    
  299.     static classname[12]; pev(iEnt, pev_classname, classname, charsmax(classname))
  300.    
  301.     if(equali(classname, ATK2_CLASSNAME))
  302.     {
  303.         static Owner; Owner = pev(iEnt, pev_owner)
  304.        
  305.         if(iHost != Owner)
  306.         {
  307.             set_es(esState, ES_RenderAmt, 0.0)
  308.         }
  309.     }
  310. }
  311.  
  312. public fw_Item_Deploy_Post(Ent)
  313. {
  314.     static Id; Id = get_pdata_cbase(Ent, 41, 4)
  315.    
  316.     if(!Get_BitVar(g_had_dps, Id))
  317.         return
  318.    
  319.     set_pev(Id, pev_viewmodel2, v_model)
  320.    
  321.     if(Get_BitVar(is_mode2, Id))
  322.     {
  323.         set_pev(Id, pev_weaponmodel2, p_modela)
  324.         Set_WeaponAnim(Id, ANIM_DRAWA)
  325.     }
  326.     else
  327.     {
  328.         set_pev(Id, pev_weaponmodel2, p_modelb)
  329.         Set_WeaponAnim(Id, ANIM_DRAWB)
  330.     }
  331. }
  332.  
  333. public fw_Item_Holster_Post(Ent)
  334. {
  335.     static Id; Id = get_pdata_cbase(Ent, 41, 4)
  336.    
  337.     if(!Get_BitVar(g_had_dps, Id))
  338.         return
  339.    
  340.     UnSet_BitVar(is_attacked, Id)
  341.     Mode[Id] = 0
  342.     Power[Id] = 0
  343.     AttackType[Id] = 0
  344. }
  345.  
  346. public fw_Weapon_WeaponIdle_Post(Ent)
  347. {
  348.     static Id; Id = get_pdata_cbase(Ent, 41, 4)
  349.    
  350.     if(!Get_BitVar(g_had_dps, Id))
  351.         return
  352.        
  353.     if(get_pdata_float(Ent, 48, 4) <= 0.25)
  354.     {
  355.         if(Get_BitVar(is_attacked, Id))
  356.         {
  357.             if(Get_BitVar(is_mode2, Id))
  358.             {
  359.                 Set_WeaponAnim(Id, ANIM_SLASHEND)
  360.                 set_pdata_float(Ent, 48, SLASHEND_NEXTIDLE + 0.5, 4)
  361.             }
  362.             else
  363.             {
  364.                 Set_WeaponAnim(Id, ANIM_STABEND)
  365.                 set_pdata_float(Ent, 48, STABEND_NEXTIDLE + 0.5, 4)
  366.             }
  367.            
  368.             UnSet_BitVar(is_attacked, Id)
  369.         }
  370.         else
  371.         {
  372.             if(Mode[Id]) Mode[Id] = 0
  373.             if(Power[Id]) Power[Id] = 0
  374.            
  375.             if(Get_BitVar(is_mode2, Id))
  376.             {
  377.                 Set_WeaponAnim(Id, ANIM_IDLEA)
  378.             }
  379.             else
  380.             {
  381.                 Set_WeaponAnim(Id, ANIM_IDLEB)
  382.             }
  383.            
  384.             set_pdata_float(Ent, 48, 20.0, 4)
  385.         }
  386.     }
  387. }
  388.  
  389. public fw_Item_PostFrame(Ent)
  390. {
  391.     static id; id = pev(Ent, pev_owner)
  392.    
  393.     if(!Get_BitVar(g_had_dps, id))
  394.         return HAM_IGNORED 
  395.    
  396.     if(AttackType[id] && AttackDelay[id] < get_gametime())
  397.     {
  398.         if(AttackType[id] == 1) Attack1(id)
  399.         else if(AttackType[id] == 2) Attack2(id)
  400.        
  401.         AttackType[id] = 0
  402.     }
  403.    
  404.     if(!(pev(id, pev_button) & IN_ATTACK2) && Get_BitVar(is_mode2, id) && Mode[id]) Mode[id] = 0
  405.    
  406.     return HAM_IGNORED
  407. }
  408.  
  409. public fw_Weapon_PrimaryAttack(Ent)
  410. {
  411.     static id; id = pev(Ent, pev_owner)
  412.    
  413.     if(!Get_BitVar(g_had_dps, id))
  414.         return HAM_IGNORED
  415.    
  416.     if(Get_BitVar(is_mode2, id))
  417.     {
  418.         UnSet_BitVar(is_mode2, id)
  419.         UnSet_BitVar(is_attacked, id)
  420.        
  421.         Mode[id] = 0
  422.        
  423.         Set_WeaponAnim(id, ANIM_SWABA)
  424.        
  425.         set_pdata_float(Ent, 46, 0.1, 4)
  426.         set_pdata_float(Ent, 47, 0.1, 4)
  427.         set_pdata_float(Ent, 48, SWAB_TIME + 0.5, 4)
  428.        
  429.         set_pev(id, pev_weaponmodel2, p_modelb)
  430.        
  431.         return HAM_SUPERCEDE
  432.     }
  433.    
  434.     Set_BitVar(is_attacked, id)
  435.    
  436.     switch(Mode[id])
  437.     {
  438.         case 0:
  439.         {
  440.             Mode[id] = 1
  441.            
  442.             AttackType[id] = 1
  443.             AttackDelay[id] = get_gametime() + STAB_DELAY1
  444.            
  445.             Set_WeaponAnim(id, ANIM_STAB1)
  446.            
  447.             set_pdata_float(Ent, 46, STAB_NEXTATTACK1, 4)
  448.             set_pdata_float(Ent, 47, STAB_NEXTATTACK1, 4)
  449.             set_pdata_float(Ent, 48, STAB_NEXTIDLE1 + 0.5, 4)
  450.            
  451.             PlayerAttack[id][Power[id]] = 0
  452.             CheckCode(id)
  453.         }
  454.         case 1:
  455.         {
  456.             Mode[id] = 0
  457.            
  458.             AttackType[id] = 2
  459.             AttackDelay[id] = get_gametime() + STAB_DELAY2
  460.            
  461.             Set_WeaponAnim(id, ANIM_STAB2)
  462.            
  463.             set_pdata_float(Ent, 46, STAB_NEXTATTACK2, 4)
  464.             set_pdata_float(Ent, 47, STAB_NEXTATTACK2, 4)
  465.             set_pdata_float(Ent, 48, STAB_NEXTIDLE2 + 0.5, 4)
  466.            
  467.             PlayerAttack[id][Power[id]] = 1
  468.             CheckCode(id)
  469.         }
  470.     }
  471.    
  472.     return HAM_SUPERCEDE
  473. }
  474.  
  475. public fw_Weapon_SecondaryAttack(Ent)
  476. {
  477.     static id; id = pev(Ent, pev_owner)
  478.    
  479.     if(!Get_BitVar(g_had_dps, id))
  480.         return HAM_IGNORED
  481.    
  482.     if(!Get_BitVar(is_mode2, id))
  483.     {
  484.         Set_BitVar(is_mode2, id)
  485.         UnSet_BitVar(is_attacked, id)
  486.        
  487.         Mode[id] = 0
  488.        
  489.         Set_WeaponAnim(id, ANIM_SWABB)
  490.        
  491.         set_pdata_float(Ent, 46, 0.1, 4)
  492.         set_pdata_float(Ent, 47, 0.1, 4)
  493.         set_pdata_float(Ent, 48, SWAB_TIME + 0.5, 4)
  494.        
  495.         set_pev(id, pev_weaponmodel2, p_modela)
  496.        
  497.         return HAM_SUPERCEDE
  498.     }
  499.    
  500.     Set_BitVar(is_attacked, id)
  501.    
  502.     switch(Mode[id])
  503.     {
  504.         case 0:
  505.         {
  506.             Mode[id] = 1
  507.            
  508.             Set_WeaponAnim(id, ANIM_SLASH1)
  509.             Create_FakeEnt(id, 0, 0)
  510.            
  511.             set_pdata_float(Ent, 46, SLASH_NEXTATTACK, 4)
  512.             set_pdata_float(Ent, 47, SLASH_NEXTATTACK, 4)
  513.             set_pdata_float(Ent, 48, SLASH_NEXTIDLE + 0.5, 4)
  514.            
  515.             PlayerAttack[id][Power[id]] = 2
  516.             CheckCode(id)
  517.         }
  518.         case 1:
  519.         {
  520.             Mode[id] = 2
  521.            
  522.             Set_WeaponAnim(id, ANIM_SLASH2)
  523.             Create_FakeEnt(id, 1, 0)
  524.            
  525.             set_pdata_float(Ent, 46, SLASH_NEXTATTACK, 4)
  526.             set_pdata_float(Ent, 47, SLASH_NEXTATTACK, 4)
  527.             set_pdata_float(Ent, 48, SLASH_NEXTIDLE  + 0.5, 4)
  528.            
  529.             PlayerAttack[id][Power[id]] = 3
  530.             CheckCode(id)
  531.         }
  532.         case 2:
  533.         {
  534.             Mode[id] = 3
  535.            
  536.             Set_WeaponAnim(id, ANIM_SLASH3)
  537.             Create_FakeEnt(id, 2, 0)
  538.            
  539.             set_pdata_float(Ent, 46, SLASH_NEXTATTACK, 4)
  540.             set_pdata_float(Ent, 47, SLASH_NEXTATTACK, 4)
  541.             set_pdata_float(Ent, 48, SLASH_NEXTIDLE + 0.5, 4)
  542.            
  543.             PlayerAttack[id][Power[id]] = 4
  544.             CheckCode(id)
  545.         }
  546.         case 3:
  547.         {
  548.             Mode[id] = 0
  549.            
  550.             Set_WeaponAnim(id, ANIM_SLASH4)
  551.            
  552.             set_pdata_float(Ent, 46, SLASH4_NEXTATTACK, 4)
  553.             set_pdata_float(Ent, 47, SLASH4_NEXTATTACK, 4)
  554.             set_pdata_float(Ent, 48, SLASH_NEXTIDLE + 0.5, 4)
  555.            
  556.             PlayerAttack[id][Power[id]] = 5
  557.             static Skill; Skill = CheckCode(id)
  558.             Create_FakeEnt(id, 3, Skill)
  559.         }
  560.     }
  561.    
  562.     Attack3(id)
  563.    
  564.     return HAM_SUPERCEDE
  565. }
  566.  
  567. public CheckCode(id)
  568. {
  569.     if(PlayerAttack[id][Power[id]] == Key[Power[id]])
  570.     {
  571.         Power[id]++
  572.         if(Power[id] >= 11)
  573.         {
  574.             Power[id] = 0
  575.             return 1
  576.         }
  577.     }
  578.     else
  579.     {
  580.         Power[id] = 0
  581.     }
  582.    
  583.     return 0
  584. }
  585.  
  586. public Create_FakeEnt(id, Anim, HavePower)
  587. {
  588.     static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  589.    
  590.     set_pev(Ent, pev_classname, ATK2_CLASSNAME)
  591.     set_pev(Ent, pev_movetype, MOVETYPE_FLY)
  592.     engfunc(EngFunc_SetModel, Ent, v_modelfx)
  593.     set_pev(Ent, pev_owner, id)
  594.    
  595.     if(Anim == 3)
  596.     {
  597.         set_pev(Ent, pev_fuser4, get_gametime() + 0.5)
  598.         set_pev(Ent, pev_iuser4, 1)
  599.         set_pev(Ent, pev_iuser3, HavePower)
  600.     }
  601.    
  602.     fm_set_rendering(Ent, kRenderNormal, 255, 255, 255, kRenderTransAdd, 255)
  603.    
  604.     set_pev(Ent, pev_sequence, Anim)
  605.     set_pev(Ent, pev_framerate , 1.0)
  606.    
  607.     set_pev(Ent, pev_solid, SOLID_NOT)
  608.     set_pev(Ent, pev_nextthink, get_gametime() + 0.01)
  609. }
  610.  
  611. public Atk2_Think(Ent)
  612. {
  613.     if(!pev_valid(Ent))
  614.         return
  615.  
  616.     static Owner; Owner = pev(Ent, pev_owner)
  617.    
  618.     if(!is_user_alive(Owner))
  619.     {
  620.         set_pev(Ent, pev_flags, FL_KILLME)
  621.         return
  622.     }
  623.    
  624.     if(get_user_weapon(Owner) != CSW_KNIFE || !Get_BitVar(g_had_dps, Owner) || !Get_BitVar(is_mode2, Owner))
  625.     {
  626.         set_pev(Ent, pev_flags, FL_KILLME)
  627.         return
  628.     }
  629.    
  630.     static Float:Light; pev(Ent, pev_renderamt, Light)
  631.    
  632.     Light -= 4.0
  633.     //Light -= 20.0
  634.     Light = floatmax(Light, 0.0)
  635.     set_pev(Ent, pev_renderamt, Light)
  636.    
  637.     if(!Light)
  638.     {
  639.         set_pev(Ent, pev_flags, FL_KILLME)
  640.         return
  641.     }
  642.    
  643.     if(pev(Ent, pev_iuser4))
  644.     {
  645.         if(pev(Ent, pev_fuser4) < get_gametime())
  646.         {
  647.             set_pev(Ent, pev_iuser4, 0)
  648.             if(pev(Ent, pev_iuser3))
  649.             {
  650.                 Create_Skill(Owner)
  651.                 engfunc(EngFunc_EmitSound, Owner, CHAN_WEAPON, SwordsSounds[14], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  652.                 set_pev(Ent, pev_flags, FL_KILLME)
  653.             }
  654.             else
  655.             {
  656.                 engfunc(EngFunc_EmitSound, Owner, CHAN_WEAPON, SwordsSounds[13], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  657.             }
  658.         }
  659.     }
  660.    
  661.     static Float:vOrigin[3], Float:vUp[3], Float:Angles[3]
  662.    
  663.     pev(Owner, pev_origin, vOrigin)
  664.     pev(Owner, pev_view_ofs,vUp)
  665.     xs_vec_add(vOrigin, vUp, vOrigin)
  666.    
  667.     pev(Owner, pev_v_angle, Angles)
  668.     angle_vector(Angles, ANGLEVECTOR_FORWARD, Angles)
  669.     vector_to_angle(Angles, Angles)
  670.    
  671.     set_pev(Ent, pev_origin, vOrigin)
  672.     set_pev(Ent, pev_angles, Angles)
  673.    
  674.     set_pev(Ent, pev_nextthink, get_gametime() + 0.01)
  675. }
  676.  
  677. public Create_Skill(id)
  678. {
  679.     Set_WeaponAnim(id, ANIM_SKILLSTART)
  680.     Set_WeaponIdleTime(id, CSW_KNIFE, SKILL_STARTTIME + 0.5)
  681.     Set_PlayerNextAttack(id, SKILL_STARTTIME)
  682.    
  683.     UnSet_BitVar(is_attacked, id)
  684.     Mode[id] = 0
  685.     AttackType[id] = 0
  686.    
  687.     static Float:Origin[3]
  688.     pev(id, pev_origin, Origin)
  689.    
  690.     static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  691.    
  692.     set_pev(Ent, pev_classname, EF_CLASSNAME)
  693.     engfunc(EngFunc_SetModel, Ent, skill_model)
  694.     set_pev(Ent, pev_origin, Origin)
  695.     set_pev(Ent, pev_movetype, MOVETYPE_FLY)
  696.     set_pev(Ent, pev_owner, id)
  697.  
  698.     set_pev(Ent, pev_fuser4, get_gametime())
  699.     set_pev(Ent, pev_fuser3, get_gametime())
  700.     set_pev(Ent, pev_fuser2, get_gametime())
  701.     set_pev(Ent, pev_fuser1, get_gametime())
  702.     set_pev(Ent, pev_iuser4, 0)
  703.    
  704.     set_pev(Ent, pev_animtime, get_gametime())
  705.     set_pev(Ent, pev_frame, 0)
  706.     set_pev(Ent, pev_framerate , 1.0)
  707.     set_pev(Ent, pev_sequence, 0)
  708.    
  709.     set_pev(Ent, pev_nextthink, get_gametime() + 0.01)
  710. }
  711.  
  712. public Ef_Think(Ent)
  713. {
  714.     if(!pev_valid(Ent))
  715.         return
  716.    
  717.     static Owner; Owner = pev(Ent, pev_owner)
  718.    
  719.     if(!is_user_alive(Owner))
  720.     {
  721.         set_pev(Ent, pev_flags, FL_KILLME)
  722.         return
  723.     }
  724.        
  725.     if(get_user_weapon(Owner) != CSW_KNIFE || !Get_BitVar(g_had_dps, Owner) || !Get_BitVar(is_mode2, Owner))
  726.     {
  727.         set_pev(Ent, pev_flags, FL_KILLME)
  728.         return
  729.     }
  730.    
  731.     static Float:Origin[3], Float:Angles[3]
  732.     pev(Owner, pev_origin, Origin)
  733.     pev(Owner, pev_angles, Angles)
  734.    
  735.     Stock_Hook_Ent(Ent, Origin, 1000.0)
  736.     set_pev(Ent, pev_angles, Angles)
  737.    
  738.     static Mode; Mode = pev(Ent, pev_iuser4)
  739.     static Float: Time; pev(Ent, pev_fuser4, Time)
  740.     static Float: AttackTime1; pev(Ent, pev_fuser3, AttackTime1)
  741.     static Float: AttackTime2; pev(Ent, pev_fuser2, AttackTime2)
  742.     static Float: AttackTime3; pev(Ent, pev_fuser1, AttackTime3)
  743.    
  744.     if(Mode == 0)
  745.     {
  746.         if(get_gametime() - 1.0 > Time)
  747.         {
  748.             set_pev(Ent, pev_fuser4, get_gametime())
  749.             set_pev(Ent, pev_iuser4, 1)
  750.            
  751.             Set_WeaponAnim(Owner, ANIM_SKILLLOOP)
  752.             Set_WeaponIdleTime(Owner, CSW_KNIFE, SKILL_TIME + 0.5)
  753.             Set_PlayerNextAttack(Owner, SKILL_TIME)
  754.            
  755.             set_pev(Ent, pev_origin, Origin)
  756.             set_pev(Ent, pev_effects, pev(Ent, pev_effects) | EF_NODRAW)
  757.         }
  758.     }
  759.     else if(Mode == 1)
  760.     {
  761.         if(get_gametime() - 10.25 > Time)
  762.         {
  763.             set_pev(Ent, pev_fuser4, get_gametime())
  764.             set_pev(Ent, pev_iuser4, 2)
  765.                
  766.             set_pev(Ent, pev_origin, Origin)
  767.             set_pev(Ent, pev_effects, pev(Ent, pev_effects) &~ EF_NODRAW)
  768.            
  769.             set_pev(Ent, pev_animtime, get_gametime())
  770.             set_pev(Ent, pev_frame, 0)
  771.             set_pev(Ent, pev_framerate , 1.0)
  772.             set_pev(Ent, pev_sequence, 1)
  773.         }
  774.         if(get_gametime() - 0.15 > AttackTime1)
  775.         {
  776.             set_pev(Ent, pev_fuser3, get_gametime())
  777.             DealDamage(Owner)
  778.         }
  779.         if(get_gametime() - 0.1 > AttackTime2)
  780.         {
  781.             set_pev(Ent, pev_fuser2, get_gametime())
  782.             GoldSword(Owner)
  783.         }
  784.         if(get_gametime() - 0.05 > AttackTime3)
  785.         {
  786.             set_pev(Ent, pev_fuser1, get_gametime())
  787.             BlueSword(Owner)
  788.         }
  789.     }
  790.     else
  791.     {
  792.         if(get_gametime() - 1.5 > Time)
  793.         {
  794.             set_pev(Ent, pev_flags, FL_KILLME)
  795.             return
  796.         }
  797.     }
  798.    
  799.     set_pev(Ent, pev_nextthink, get_gametime() + 0.01)
  800. }
  801.  
  802. public DealDamage(id)
  803. {
  804.     static Ent, Float:Origin[3]
  805.    
  806.     Ent = FM_NULLENT
  807.     pev(id, pev_origin, Origin)
  808.    
  809.     while((Ent = engfunc(EngFunc_FindEntityInSphere, Ent, Origin, 250.0)) != 0)
  810.     {
  811.         if(!pev_valid(Ent))
  812.             continue
  813.        
  814.         if(pev(Ent, pev_takedamage) == DAMAGE_NO)
  815.             continue
  816.            
  817.         if(is_user_alive(Ent) && get_user_team(Ent) == get_user_team(id))
  818.             continue
  819.    
  820.         ExecuteHamB(Ham_TakeDamage, Ent, id, id, SKILL_DAMAGE, DMG_BULLET)
  821.        
  822.         static Float:VicOrigin[3]
  823.         pev(Ent, pev_origin, VicOrigin)
  824.        
  825.         SpawnBlood(VicOrigin, 247, 255)
  826.     }
  827. }
  828. ////////////////////////////////////////////////////////////////////////////////////////////////////
  829. public BlueSword(id)
  830. {
  831.     static Float:Origin[3], Float:StartPoint[3], Float:EndPoint[3]
  832.     static Float:FloatX, Float:FloatY, Float:FloatZ
  833.    
  834.     pev(id, pev_origin, Origin)
  835.    
  836.     switch(random_num(0, 1))
  837.     {
  838.         case 0:
  839.         {
  840.             FloatX = Float1[random_num(0, 41)]
  841.             FloatY = Float1[random_num(40, 41)]
  842.             FloatZ = Float2[random_num(0, 15)]
  843.         }
  844.         case 1:
  845.         {
  846.             FloatX = Float1[random_num(40, 41)]
  847.             FloatY = Float1[random_num(0, 41)]
  848.             FloatZ = Float2[random_num(0, 15)]
  849.         }
  850.     }
  851.    
  852.     xs_vec_set(StartPoint, Origin[0] + FloatX, Origin[1] + FloatY, Origin[2] + FloatZ)
  853.    
  854.     engfunc(EngFunc_TraceLine, Origin, StartPoint, IGNORE_MONSTERS, 0, 0)
  855.     get_tr2(0, TR_vecEndPos, StartPoint)
  856.    
  857.     xs_vec_set(EndPoint, Origin[0] + random_float(-150.0, 150.0), Origin[1] + random_float(-150.0, 150.0), Origin[2] + random_float(-18.0, 125.0))
  858.    
  859.     Create_BlueSword(id, StartPoint, EndPoint)
  860. }
  861.  
  862. public Create_BlueSword(id, Float:Start[3], Float:End[3])
  863. {
  864.     static Ent, Float:Angles[3], Float:Velocity[3]
  865.    
  866.     xs_vec_sub(End, Start, Angles)
  867.     vector_to_angle(Angles, Angles)
  868.     get_speed_vector(Start, End, 1750.0, Velocity)
  869.    
  870.     Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  871.    
  872.     set_pev(Ent, pev_classname, SWORD1_CLASSNAME)
  873.     set_pev(Ent, pev_movetype, MOVETYPE_FLY)
  874.     set_pev(Ent, pev_solid, SOLID_TRIGGER)
  875.     set_pev(Ent, pev_origin, Start)
  876.     set_pev(Ent, pev_angles, Angles)
  877.    
  878.     set_pev(Ent, pev_owner, id)
  879.     set_pev(Ent, pev_iuser3, get_user_team(id))
  880.    
  881.     engfunc(EngFunc_SetModel, Ent, blueblade_model)
  882.     fm_set_rendering(Ent, kRenderNormal, 255, 255, 255, kRenderTransAdd, 255)
  883.    
  884.     set_pev(Ent, pev_animtime, get_gametime())
  885.     set_pev(Ent, pev_frame, 0)
  886.     set_pev(Ent, pev_framerate , 1.0)
  887.     set_pev(Ent, pev_sequence, 0)
  888.    
  889.     // Create Velocity
  890.     set_pev(Ent, pev_velocity, Velocity)
  891.    
  892.     emit_sound(Ent, CHAN_BODY, SwordsSounds[random_num(0, 4)], 1.0, ATTN_NORM, 0, PITCH_NORM)
  893.    
  894.     set_pev(Ent, pev_nextthink, get_gametime() + 0.25)
  895. }
  896.  
  897. public Sword1_Think(Ent)
  898. {
  899.     if(!pev_valid(Ent))
  900.         return
  901.    
  902.     set_pev(Ent, pev_flags, FL_KILLME)
  903. }
  904.  
  905. public Sword1_Touch(Ent, Touch)
  906. {
  907.     if(!pev_valid(Ent))
  908.         return
  909.    
  910.     if(!is_user_alive(Touch))
  911.     {
  912.         static Classname[32]
  913.         pev(Touch, pev_classname, Classname, charsmax(Classname))
  914.        
  915.         if(equali(Classname, SWORD1_CLASSNAME))
  916.             return
  917.    
  918.         set_pev(Ent, pev_flags, FL_KILLME)
  919.     }
  920.     else
  921.     {
  922.         static Team; Team = pev(Ent, pev_iuser3)
  923.        
  924.         if(get_user_team(Touch) == Team)
  925.             return
  926.        
  927.         static Float:Origin[3]
  928.         pev(Ent, pev_origin, Origin)
  929.        
  930.         SpawnBlood(Origin, 247, 255)
  931.     }
  932. }
  933. ////////////////////////////////////////////////////////////////////////////////////////////////////
  934. public GoldSword(id)
  935. {
  936.     static Float:Origin[3], Float:Point[3], Float:Angles[3]
  937.     static Float:FloatX, Float:FloatY, Float:FloatZ
  938.    
  939.     FloatX = Float3[random_num(0, 40)]
  940.     FloatY = Float3[random_num(0, 40)]
  941.     FloatZ = random_float(0.0, 75.0)
  942.    
  943.     pev(id, pev_origin, Origin)
  944.     xs_vec_set(Point, Origin[0] + FloatX, Origin[1] + FloatY, Origin[2] + FloatZ)
  945.    
  946.     engfunc(EngFunc_TraceLine, Origin, Point, IGNORE_MONSTERS, 0, 0)
  947.     get_tr2(0, TR_vecEndPos, Point)
  948.    
  949.     xs_vec_set(Angles, 0.0, random_float(-180.0, 180.0), 0.0)
  950.    
  951.     Create_GoldSword(id, Point, Angles)
  952.    
  953.     for(new i = 1; i <= get_playersnum(); i++)
  954.     {
  955.         if(!is_user_alive(i))  
  956.             continue
  957.            
  958.         if(get_user_team(i) == get_user_team(id))
  959.             continue
  960.            
  961.         if(fm_entity_range(i, id) > 100.0)
  962.             continue
  963.    
  964.         static Float:VicOrigin[3]
  965.         pev(i, pev_origin, VicOrigin)
  966.        
  967.         SpawnBlood(VicOrigin, 247, 255)
  968.     }
  969. }
  970.  
  971. public Create_GoldSword(id, Float:Origin[3], Float:Angles[3])
  972. {
  973.     static Ent
  974.    
  975.     Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_sprite"))
  976.    
  977.     set_pev(Ent, pev_classname, SWORD2_CLASSNAME)
  978.     set_pev(Ent, pev_movetype, MOVETYPE_FLY)
  979.     set_pev(Ent, pev_origin, Origin)
  980.     set_pev(Ent, pev_angles, Angles)
  981.    
  982.     set_pev(Ent, pev_owner, id)
  983.    
  984.     engfunc(EngFunc_SetModel, Ent, goldblade_model)
  985.     fm_set_rendering(Ent, kRenderNormal, 255, 255, 255, kRenderTransAdd, 255)
  986.    
  987.     set_pev(Ent, pev_fuser4, get_gametime() + 0.1)
  988.     set_pev(Ent, pev_iuser4, 1)
  989.    
  990.     set_pev(Ent, pev_animtime, get_gametime())
  991.     set_pev(Ent, pev_frame, 0)
  992.     set_pev(Ent, pev_framerate , 1.0)
  993.     set_pev(Ent, pev_sequence, random_num(0, 2))
  994.    
  995.     set_pev(Ent, pev_nextthink, get_gametime() + 0.01)
  996. }
  997.  
  998. public Sword2_Think(Ent)
  999. {
  1000.     if(!pev_valid(Ent))
  1001.         return
  1002.    
  1003.     if(pev(Ent, pev_iuser4))
  1004.     {
  1005.         static Float:Time; pev(Ent, pev_fuser4, Time)
  1006.         if(Time < get_gametime())
  1007.         {
  1008.             set_pev(Ent, pev_iuser4, 0)
  1009.         }
  1010.     }
  1011.     else
  1012.     {
  1013.         static Float:Light; pev(Ent, pev_renderamt, Light)
  1014.    
  1015.         Light -= 10.0
  1016.         Light = floatmax(Light, 0.0)
  1017.         set_pev(Ent, pev_renderamt, Light)
  1018.    
  1019.         if(!Light)
  1020.         {
  1021.             set_pev(Ent, pev_flags, FL_KILLME)
  1022.             return
  1023.         }
  1024.     }
  1025.    
  1026.     set_pev(Ent, pev_nextthink, get_gametime() + 0.01)
  1027. }
  1028. ////////////////////////////////////////////////////////////////////////////////////////////////////
  1029. public Attack1(id)
  1030. {
  1031.     static iHitResult2
  1032.    
  1033.     iHitResult2 = Knife_Damage(id, STAB_RANGE1, STAB_ANGLE1, STAB_DAMAGE1, 0)
  1034.     switch(iHitResult2)
  1035.     {
  1036.         case HIT_ENEMY:
  1037.         {
  1038.             engfunc(EngFunc_EmitSound, id, CHAN_WEAPON, SwordsSounds[random_num(10, 11)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  1039.         }
  1040.         case HIT_WALL:
  1041.         {
  1042.             engfunc(EngFunc_EmitSound, id, CHAN_WEAPON, SwordsSounds[12], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  1043.         }
  1044.     }
  1045. }
  1046.  
  1047. public Attack2(id)
  1048. {
  1049.     static iHitResult2
  1050.    
  1051.     iHitResult2 = Knife_Damage(id, STAB_RANGE2, STAB_ANGLE2, STAB_DAMAGE2, 0)
  1052.     switch(iHitResult2)
  1053.     {
  1054.         case HIT_ENEMY:
  1055.         {
  1056.             engfunc(EngFunc_EmitSound, id, CHAN_WEAPON, SwordsSounds[random_num(10, 11)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  1057.         }
  1058.         case HIT_WALL:
  1059.         {
  1060.             engfunc(EngFunc_EmitSound, id, CHAN_WEAPON, SwordsSounds[12], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  1061.         }
  1062.     }
  1063. }
  1064.  
  1065. public Attack3(id)
  1066. {
  1067.     static iHitResult2
  1068.    
  1069.     iHitResult2 = Knife_Damage(id, SLASH_RANGE, SLASH_ANGLE, SLASH_DAMAGE, 1)
  1070.     switch(iHitResult2)
  1071.     {
  1072.         case HIT_ENEMY:
  1073.         {
  1074.             engfunc(EngFunc_EmitSound, id, CHAN_WEAPON, SwordsSounds[random_num(5, 7)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  1075.         }
  1076.         case HIT_WALL:
  1077.         {
  1078.             engfunc(EngFunc_EmitSound, id, CHAN_WEAPON, SwordsSounds[12], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  1079.         }
  1080.     }  
  1081. }
  1082.  
  1083. public Knife_Damage(id, Float:flRange, Float:fAngle, Float:flDamage, Mode)
  1084. {
  1085.     new iHitResult = HIT_NOTHING
  1086.     new Float:vecOrigin[3], Float:vecScr[3], Float:vecEnd[3], Float:V_Angle[3], Float:vecForward[3]
  1087.     pev(id, pev_origin, vecOrigin)
  1088.     GetGunPosition(id, vecScr)
  1089.     pev(id, pev_v_angle, V_Angle)
  1090.     engfunc(EngFunc_MakeVectors, V_Angle)
  1091.     global_get(glb_v_forward, vecForward)
  1092.     xs_vec_mul_scalar(vecForward, flRange, vecForward)
  1093.     xs_vec_add(vecScr, vecForward, vecEnd)
  1094.  
  1095.     new tr = create_tr2()
  1096.     engfunc(EngFunc_TraceLine, vecScr, vecEnd, 0, id, tr)
  1097.     new Float:flFraction
  1098.     get_tr2(tr, TR_flFraction, flFraction)
  1099.    
  1100.     if(flFraction < 1.0)
  1101.     {
  1102.         iHitResult = HIT_WALL
  1103.        
  1104.         new Float:EndPos2[3]
  1105.         get_tr2(tr, TR_vecEndPos, EndPos2)
  1106.         if(Mode) Make_Effect2(EndPos2)
  1107.         else Make_Effect1(EndPos2)
  1108.     }
  1109.  
  1110.     new Float:vecEndZ = vecEnd[2]
  1111.     new pEntity = -1
  1112.    
  1113.     while((pEntity = engfunc(EngFunc_FindEntityInSphere, pEntity, vecOrigin, flRange)) != 0)
  1114.     {
  1115.         if(!pev_valid(pEntity))
  1116.         continue
  1117.  
  1118.         if(!IsAlive(pEntity))
  1119.         continue
  1120.  
  1121.         if(fAngle < 120.0 && !CheckAngle(id, pEntity, fAngle))
  1122.         continue
  1123.  
  1124.         GetGunPosition(id, vecScr)
  1125.         Stock_Get_Origin(pEntity, vecEnd)
  1126.         vecEnd[2] = vecScr[2] + (vecEndZ - vecScr[2]) * (get_distance_f(vecScr, vecEnd) / flRange)
  1127.        
  1128.         engfunc(EngFunc_TraceLine, vecScr, vecEnd, 0, id, tr)
  1129.         get_tr2(tr, TR_flFraction, flFraction)
  1130.  
  1131.         if(flFraction >= 1.0) engfunc(EngFunc_TraceHull, vecScr, vecEnd, 0, 3, id, tr)
  1132.        
  1133.         get_tr2(tr, TR_flFraction, flFraction)
  1134.         new pHit = get_tr2(tr, TR_pHit)
  1135.        
  1136.         if(flFraction < 1.0)
  1137.         {
  1138.             new Float:EndPos[3]
  1139.             get_tr2(tr, TR_vecEndPos, EndPos)
  1140.             if(IsPlayer(pEntity) || IsHostage(pEntity))
  1141.             {
  1142.                 iHitResult = HIT_ENEMY
  1143.                 if(CheckBack(id, pEntity)) flDamage *= 3.0
  1144.                
  1145.                 if(Mode) Make_Effect2(EndPos)
  1146.                 else Make_Effect1(EndPos)
  1147.             }
  1148.        
  1149.             if(pev_valid(pEntity) && pHit == pEntity && id != pEntity && !(pev(pEntity, pev_spawnflags) & SF_BREAK_TRIGGER_ONLY))
  1150.             {
  1151.                 Native_ExecuteAttack(id, pEntity, id, Float:flDamage, 1, DMG_NEVERGIB)
  1152.             }
  1153.         }
  1154.         free_tr2(tr)
  1155.     }
  1156.     return iHitResult
  1157. }
  1158.  
  1159. public Native_ExecuteAttack(iAttacker, iVictim, iEntity, Float:fDamage, iHeadShot, iDamageBit)
  1160. {
  1161.     if (pev(iVictim, pev_takedamage) <= 0.0)
  1162.     return 0
  1163.  
  1164.     new Float:fOrigin[3], Float:fEnd[3], iTarget, iBody, Float:fMultifDamage
  1165.     pev(iAttacker, pev_origin, fOrigin)
  1166.     get_user_aiming(iAttacker, iTarget, iBody)
  1167.     fm_get_aim_origin(iAttacker, fEnd)
  1168.     new ptr = create_tr2()
  1169.     new iHitGroup = get_tr2(ptr, TR_iHitgroup)
  1170.     if (iTarget == iVictim) iHitGroup = iBody
  1171.     else pev(iVictim, pev_origin, fEnd)
  1172.     engfunc(EngFunc_TraceLine, fOrigin, fEnd, DONT_IGNORE_MONSTERS, iAttacker, ptr)
  1173.     if (iHitGroup == HIT_HEAD && !iHeadShot) iHitGroup = HIT_CHEST
  1174.  
  1175.     set_pdata_int(iVictim, 75, iHitGroup, 4)
  1176.     switch(iHitGroup)
  1177.     {
  1178.         case HIT_HEAD: fMultifDamage  = 4.0
  1179.         case HIT_CHEST: fMultifDamage  = 1.0
  1180.         case 3: fMultifDamage  = 1.25
  1181.         case 4,5,6,7: fMultifDamage  = 0.75
  1182.         default: fMultifDamage  = 1.0
  1183.     }
  1184.     fDamage *= fMultifDamage
  1185.  
  1186.     if (get_cvar_num("mp_friendlyfire") || (!get_cvar_num("mp_friendlyfire") && get_pdata_int(iAttacker, 114) != get_pdata_int(iVictim, 114)))
  1187.     {
  1188.         if (is_user_alive(iVictim)) SpawnBlood(fEnd, 247, floatround(fDamage))
  1189.     }
  1190.  
  1191.     ExecuteHamB(Ham_TakeDamage, iVictim, iEntity, iAttacker, fDamage, iDamageBit)
  1192.     free_tr2(ptr)
  1193.     return 1
  1194. }
  1195.  
  1196. stock IsPlayer(pEntity) return is_user_connected(pEntity)
  1197.  
  1198. stock IsHostage(pEntity)
  1199. {
  1200.     new classname[32]; pev(pEntity, pev_classname, classname, charsmax(classname))
  1201.     return equal(classname, "hostage_entity")
  1202. }
  1203.  
  1204. stock IsAlive(pEntity)
  1205. {
  1206.     if (pEntity < 1) return 0
  1207.     return (pev(pEntity, pev_deadflag) == DEAD_NO && pev(pEntity, pev_health) > 0)
  1208. }
  1209.  
  1210. stock GetGunPosition(id, Float:vecScr[3])
  1211. {
  1212.     new Float:vecViewOfs[3]
  1213.     pev(id, pev_origin, vecScr)
  1214.     pev(id, pev_view_ofs, vecViewOfs)
  1215.     xs_vec_add(vecScr, vecViewOfs, vecScr)
  1216. }
  1217.  
  1218. stock CheckBack(iEnemy,id)
  1219. {
  1220.     new Float:anglea[3], Float:anglev[3]
  1221.     pev(iEnemy, pev_v_angle, anglea)
  1222.     pev(id, pev_v_angle, anglev)
  1223.     new Float:angle = anglea[1] - anglev[1]
  1224.     if (angle < -180.0) angle += 360.0
  1225.     if (angle <= 45.0 && angle >= -45.0) return 1
  1226.     return 0
  1227. }
  1228.  
  1229. stock CheckAngle(iAttacker, iVictim, Float:fAngle)  return(Stock_CheckAngle(iAttacker, iVictim) > floatcos(fAngle,degrees))
  1230.  
  1231. stock Float:Stock_CheckAngle(id,iTarget)
  1232. {
  1233.     new Float:vOricross[2],Float:fRad,Float:vId_ori[3],Float:vTar_ori[3],Float:vId_ang[3],Float:fLength,Float:vForward[3]
  1234.     Stock_Get_Origin(id, vId_ori)
  1235.     Stock_Get_Origin(iTarget, vTar_ori)
  1236.    
  1237.     pev(id,pev_angles,vId_ang)
  1238.     for(new i=0;i<2;i++) vOricross[i] = vTar_ori[i] - vId_ori[i]
  1239.    
  1240.     fLength = floatsqroot(vOricross[0]*vOricross[0] + vOricross[1]*vOricross[1])
  1241.    
  1242.     if (fLength<=0.0)
  1243.     {
  1244.         vOricross[0]=0.0
  1245.         vOricross[1]=0.0
  1246.     } else {
  1247.         vOricross[0]=vOricross[0]*(1.0/fLength)
  1248.         vOricross[1]=vOricross[1]*(1.0/fLength)
  1249.     }
  1250.    
  1251.     engfunc(EngFunc_MakeVectors,vId_ang)
  1252.     global_get(glb_v_forward,vForward)
  1253.    
  1254.     fRad = vOricross[0]*vForward[0]+vOricross[1]*vForward[1]
  1255.    
  1256.     return fRad   //->   RAD 90' = 0.5rad
  1257. }
  1258.  
  1259. stock Stock_Get_Origin(id, Float:origin[3])
  1260. {
  1261.     new Float:maxs[3],Float:mins[3]
  1262.     if (pev(id, pev_solid) == SOLID_BSP)
  1263.     {
  1264.         pev(id,pev_maxs,maxs)
  1265.         pev(id,pev_mins,mins)
  1266.         origin[0] = (maxs[0] - mins[0]) / 2 + mins[0]
  1267.         origin[1] = (maxs[1] - mins[1]) / 2 + mins[1]
  1268.         origin[2] = (maxs[2] - mins[2]) / 2 + mins[2]
  1269.     } else pev(id, pev_origin, origin)
  1270. }
  1271.  
  1272. stock SpawnBlood(const Float:vecOrigin[3], iColor, iAmount)
  1273. {
  1274.     if(iAmount == 0)
  1275.     return
  1276.  
  1277.     if(!iColor)
  1278.     return
  1279.  
  1280.     iAmount *= 2
  1281.     if(iAmount > 255) iAmount = 255
  1282.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vecOrigin)
  1283.     write_byte(TE_BLOODSPRITE)
  1284.     engfunc(EngFunc_WriteCoord, vecOrigin[0])
  1285.     engfunc(EngFunc_WriteCoord, vecOrigin[1])
  1286.     engfunc(EngFunc_WriteCoord, vecOrigin[2])
  1287.     write_short(spr_blood_spray)
  1288.     write_short(spr_blood_drop)
  1289.     write_byte(iColor)
  1290.     write_byte(min(max(3, iAmount / 10), 16))
  1291.     message_end()
  1292. }
  1293.  
  1294. stock Make_Effect1(Float:Origin[3])
  1295. {
  1296.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin)
  1297.     write_byte(TE_BLOODSPRITE)
  1298.     engfunc(EngFunc_WriteCoord, Origin[0])
  1299.     engfunc(EngFunc_WriteCoord, Origin[1])
  1300.     engfunc(EngFunc_WriteCoord, Origin[2])
  1301.     write_short(sprleaf1)
  1302.     write_short(sprleaf1)
  1303.     write_byte(230)
  1304.     write_byte(3)
  1305.     message_end()
  1306.    
  1307.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin)
  1308.     write_byte(TE_BLOODSPRITE)
  1309.     engfunc(EngFunc_WriteCoord, Origin[0])
  1310.     engfunc(EngFunc_WriteCoord, Origin[1])
  1311.     engfunc(EngFunc_WriteCoord, Origin[2])
  1312.     write_short(sprleaf2)
  1313.     write_short(sprleaf2)
  1314.     write_byte(71)
  1315.     write_byte(3)
  1316.     message_end()
  1317. }
  1318.  
  1319. stock Make_Effect2(Float:Origin[3])
  1320. {
  1321.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin)
  1322.     write_byte(TE_BLOODSPRITE)
  1323.     engfunc(EngFunc_WriteCoord, Origin[0])
  1324.     engfunc(EngFunc_WriteCoord, Origin[1])
  1325.     engfunc(EngFunc_WriteCoord, Origin[2])
  1326.     write_short(sprpetal1)
  1327.     write_short(sprpetal1)
  1328.     write_byte(144)
  1329.     write_byte(3)
  1330.     message_end()
  1331.    
  1332.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin)
  1333.     write_byte(TE_BLOODSPRITE)
  1334.     engfunc(EngFunc_WriteCoord, Origin[0])
  1335.     engfunc(EngFunc_WriteCoord, Origin[1])
  1336.     engfunc(EngFunc_WriteCoord, Origin[2])
  1337.     write_short(sprpetal2)
  1338.     write_short(sprpetal2)
  1339.     write_byte(150)
  1340.     write_byte(3)
  1341.     message_end()
  1342. }
  1343.  
  1344. stock Set_WeaponAnim(id, anim)
  1345. {
  1346.     set_pev(id, pev_weaponanim, anim)
  1347.    
  1348.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id)
  1349.     write_byte(anim)
  1350.     write_byte(pev(id, pev_body))
  1351.     message_end()
  1352. }
  1353.  
  1354. stock get_angle_to_target(id, const Float:fTarget[3], Float:TargetSize = 0.0)
  1355. {
  1356.     static Float:fOrigin[3], iAimOrigin[3], Float:fAimOrigin[3], Float:fV1[3]
  1357.     pev(id, pev_origin, fOrigin)
  1358.     get_user_origin(id, iAimOrigin, 3) // end position from eyes
  1359.     IVecFVec(iAimOrigin, fAimOrigin)
  1360.     xs_vec_sub(fAimOrigin, fOrigin, fV1)
  1361.    
  1362.     static Float:fV2[3]
  1363.     xs_vec_sub(fTarget, fOrigin, fV2)
  1364.    
  1365.     static iResult; iResult = get_angle_between_vectors(fV1, fV2)
  1366.    
  1367.     if (TargetSize > 0.0)
  1368.     {
  1369.         static Float:fTan; fTan = TargetSize / get_distance_f(fOrigin, fTarget)
  1370.         static fAngleToTargetSize; fAngleToTargetSize = floatround( floatatan(fTan, degrees) )
  1371.         iResult -= (iResult > 0) ? fAngleToTargetSize : -fAngleToTargetSize
  1372.     }
  1373.    
  1374.     return iResult
  1375. }
  1376.  
  1377. stock get_angle_between_vectors(const Float:fV1[3], const Float:fV2[3])
  1378. {
  1379.     static Float:fA1[3], Float:fA2[3]
  1380.     engfunc(EngFunc_VecToAngles, fV1, fA1)
  1381.     engfunc(EngFunc_VecToAngles, fV2, fA2)
  1382.    
  1383.     static iResult; iResult = floatround(fA1[1] - fA2[1])
  1384.     iResult = iResult % 360
  1385.     iResult = (iResult > 180) ? (iResult - 360) : iResult
  1386.    
  1387.     return iResult
  1388. }  
  1389.  
  1390. stock get_position(id,Float:forw, Float:right, Float:up, Float:vStart[])
  1391. {
  1392.     new Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
  1393.    
  1394.     pev(id, pev_origin, vOrigin)
  1395.     pev(id, pev_view_ofs,vUp) //for player
  1396.     xs_vec_add(vOrigin,vUp,vOrigin)
  1397.     pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
  1398.    
  1399.     angle_vector(vAngle,ANGLEVECTOR_FORWARD,vForward) //or use EngFunc_AngleVectors
  1400.     angle_vector(vAngle,ANGLEVECTOR_RIGHT,vRight)
  1401.     angle_vector(vAngle,ANGLEVECTOR_UP,vUp)
  1402.    
  1403.     vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
  1404.     vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
  1405.     vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
  1406. }
  1407.  
  1408. stock Set_WeaponIdleTime(id, WeaponId ,Float:TimeIdle)
  1409. {
  1410.     static entwpn; entwpn = fm_get_user_weapon_entity(id, WeaponId)
  1411.     if(!pev_valid(entwpn))
  1412.         return
  1413.        
  1414.     set_pdata_float(entwpn, 48, TimeIdle + 0.5, 4)
  1415. }
  1416.  
  1417. stock Set_PlayerNextAttack(id, Float:nexttime)
  1418. {
  1419.     set_pdata_float(id, 83, nexttime, 5)
  1420. }
  1421.  
  1422. stock Stock_Hook_Ent(ent, Float:TargetOrigin[3], Float:Speed)
  1423. {
  1424.     static Float:fl_Velocity[3], Float:EntOrigin[3], Float:distance_f, Float:fl_Time
  1425.     pev(ent, pev_origin, EntOrigin)
  1426.    
  1427.     distance_f = get_distance_f(EntOrigin, TargetOrigin)
  1428.     fl_Time = distance_f / Speed
  1429.    
  1430.     if(distance_f > 0.1)
  1431.     {
  1432.         fl_Velocity[0] = (TargetOrigin[0] - EntOrigin[0]) / fl_Time
  1433.         fl_Velocity[1] = (TargetOrigin[1] - EntOrigin[1]) / fl_Time
  1434.         fl_Velocity[2] = (TargetOrigin[2] - EntOrigin[2]) / fl_Time
  1435.     }
  1436.     else
  1437.     {
  1438.         fl_Velocity[0] = 0.0
  1439.         fl_Velocity[1] = 0.0
  1440.         fl_Velocity[2] = 0.0
  1441.     }
  1442.  
  1443.     set_pev(ent, pev_velocity, fl_Velocity)
  1444. }
  1445.  
  1446. stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
  1447. {
  1448.     new_velocity[0] = origin2[0] - origin1[0]
  1449.     new_velocity[1] = origin2[1] - origin1[1]
  1450.     new_velocity[2] = origin2[2] - origin1[2]
  1451.     new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
  1452.     new_velocity[0] *= num
  1453.     new_velocity[1] *= num
  1454.     new_velocity[2] *= num
  1455.    
  1456.     return 1;
  1457. }

You can use it give_daul_sword(id), try just change the native in weapons menu to this one and change text and it's OK i think.
He who fails to plan is planning to fail

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

#12

Post by czirimbolo » 5 years ago

Ok I added dual sword to 41 level but I dont see it on menu. Where is my mistake?

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_give_jetpack(id);
native give_daul_sword(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..39: WPN_MAXIDS[id] = 18 // Golden AK47
        case 40: WPN_MAXIDS[id] = 19    // JatPack
		case 41: WPN_MAXIDS[id] = 20    // Dual Sword
    }
   
    if (ze_get_user_level(id) > 41)
    {
        WPN_MAXIDS[id] = 20
    }
 
    // 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) < 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")
                break;
            }
        }
       
        // Dual Sword
        if (ze_get_user_level(id) >= 41)
        {
            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, "JetPack")
                break;
            }
			
			if (iIndex == 19)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Dual Sword")
                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) // 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) < 40) // JetPack
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 40 Unlock\w: \yJetPack^n")
    }
	else if (ze_get_user_level(id) >= 40 && ze_get_user_level(id) < 41) // Dual Sword
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 41 Unlock\w: \yDual Sword^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) // Golden AK47
    {
        give_golden_ak47(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
    else if (selection == 18) // JetPack
    {
        ze_give_jetpack(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
	else if (selection == 19) // Dual Sword
    {
        give_daul_sword(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
   
    static szWeaponName[32]
    ArrayGetString(g_szPrimaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
    new iWeaponId = get_weaponid(szWeaponName)
   
    // Strip and Give Full Weapon
    rg_give_item(id, szWeaponName, GT_REPLACE)
    rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
   
    // Primary bought
    g_bBoughtPrimary[id] = true
    return true;
}
 
public Menu_Buy_Secondary(id, key)
{
    // Player dead or zombie or already bought secondary
    if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtSecondary[id])
        return PLUGIN_HANDLED
   
    // Special keys / weapon list exceeded
    if (key >= ArraySize(g_szSecondaryWeapons))
    {
        // Toggle autoselect
        if (key == MENU_KEY_AUTOSELECT)
            WPN_AUTO_ON = 1 - WPN_AUTO_ON
       
        // Reshow menu unless user exited
        if (key != MENU_KEY_EXIT)
            Show_Menu_Buy_Secondary(id)
       
        return PLUGIN_HANDLED
    }
   
    // Store selected weapon id
    WPN_AUTO_SEC = key
   
    // Buy secondary weapon
    Buy_Secondary_Weapon(id, key)
   
    return PLUGIN_HANDLED
}
 
public Buy_Secondary_Weapon(id, selection)
{
    if ( ((selection == 2) && (ze_get_user_level(id) < 1)) ||
    ((selection == 3) && (ze_get_user_level(id) < 2)) ||
    ((selection == 4) && (ze_get_user_level(id) < 3)) ||
    ((selection == 5) && (ze_get_user_level(id) < 4)) )
    {
        Show_Menu_Buy_Secondary(id)
        return;
    }
 
    static szWeaponName[32]
    ArrayGetString(g_szSecondaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
    new iWeaponId = get_weaponid(szWeaponName)
   
    // Strip and Give Full Weapon
    rg_give_item(id, szWeaponName, GT_REPLACE)
    rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
   
    // Secondary bought
    g_bBoughtSecondary[id] = true
}
 
public Fw_TouchWeapon_Pre(iEnt, id)
{
    if (get_pcvar_num(g_pCvarBlockWeapLowLevel) == 0)
        return HAM_IGNORED;
   
    // Not alive or Not Valid Weapon?
    if(!is_user_alive(id) || !pev_valid(iEnt))
        return HAM_IGNORED;
   
    // Get Weapon Model
    new szWeapModel[32]
    pev(iEnt, pev_model, szWeapModel, charsmax(szWeapModel))
   
    // Remove "models/w_" and ".mdl"
    copyc(szWeapModel, charsmax(szWeapModel), szWeapModel[contain(szWeapModel, "_" ) + 1], '.')
   
    // Set for mp5 to be same as "weapon_mp5navy"
    if(szWeapModel[1] == 'p' && szWeapModel[2] == '5')
        szWeapModel = "mp5navy"
   
    // Add "weapon_" to all model names
    static szWeaponEnt[32]
    formatex(szWeaponEnt, charsmax(szWeaponEnt), "weapon_%s", szWeapModel)
 
    // Get it's index in Weapon Array
    new iIndex, i
   
    // I won't explain the blew code if you need to understand ask me in Escapers-Zone.XYZ
    for (i = 0; i < ArraySize(g_szPrimaryWeapons); i++)
    {
        new szPrimaryWeapon[32]
        ArrayGetString(g_szPrimaryWeapons, i, szPrimaryWeapon, charsmax(szPrimaryWeapon))
       
        if (equali(szWeaponEnt, szPrimaryWeapon))
            iIndex = i
    }
   
    if (ze_get_user_level(id) == 0 && iIndex > 1)
    {
        return HAM_SUPERCEDE;
    }
   
    for (i = 1; i <= 11; i++)
    {
        if ((ze_get_user_level(id) == i) && iIndex > i+1)
        {
            return HAM_SUPERCEDE;
        }
    }
   
    return HAM_IGNORED;
}
 
// Natives
public native_ze_show_weapon_menu(id)
{
    if (!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
        return false
    }
   
    Cmd_Buy(id)
    return true
}
 
public native_ze_is_auto_buy_enabled(id)
{
    if (!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
        return -1;
    }
   
    return WPN_AUTO_ON;
}
 
public native_ze_disable_auto_buy(id)
{
    if (!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
        return false
    }
   
    WPN_AUTO_ON = 0;
    return true
}
Image

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

#13

Post by czirimbolo » 5 years ago

Ok Raheem to sum up. I would like to make this weapon menu:

6 level - Cyclone (add to Secondary weapon!) - "native_give_sfpistol"
10 level - Dual Pistols (add to Secondary weapon!) - "native_give_dualpistols"
15 level - Scar Beast - "native_give_weapon_add"
17 level - mini gun laser - "get_item" (I got this in code: register_native("give_laserminigun","get_item", 1)
20 level - Guardian Aug - "native_give_weapon_add" (its the same like in Scar Beast, should I rename it??)
25 level - golden m4 - already in code
26 level - golden AK - already in code
27 level - Thanatos 5 - "native_give_thanatos5"
30 level - AK47 Palladin Bloodmoon - "native_get_bak47p"
33 level - Brick Piece MG - I have this in code:

Code: Select all

public plugin_natives()
{
	new Buffer[512]
	formatex(Buffer, sizeof(Buffer), "get_%s", system_name)
	register_native(Buffer, "give_item", 1)
	formatex(Buffer, sizeof(Buffer), "remove_%s", system_name)
	register_native(Buffer, "remove_item", 1)
If I should make new native, lets name it: "native_get_brickpiece"

35 level - Dual Sword - already in code
40 level - Jetpack - already in code
50 level - Gauss Cannon - "native_get_gauss"

Please remove M3 golden and mp5 golden, you can also remove 2 pistols from secondary weapons
Image

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

#14

Post by Raheem » 5 years ago

First try following this: viewtopic.php?p=8467#p8467 and when the page is full let me know.

Post what you tried and where you failed.
He who fails to plan is planning to fail

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

#15

Post by czirimbolo » 5 years ago

Check post nr 12
Image

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

#16

Post by Raheem » 5 years ago

  1. if (iIndex == 18)
  2. {
  3.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "JetPack")
  4.     break;
  5. }

To --->>

  1. if (iIndex == 18)
  2. {
  3.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "JetPack")
  4. }

Break only in last case.
He who fails to plan is planning to fail

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

#17

Post by czirimbolo » 5 years ago

Ok thanks Raheem. Now I exceed page nr 3. Can you add 4th page and can you show me how to add new pistols to secondary weapons?

Code: Select all

#include <zombie_escape>
#include <ze_levels>
 
native give_golden_m4a1(id);
native give_golden_ak47(id);
native ze_give_jetpack(id);
native give_daul_sword(id);    
native get_bak47p(id);        
native get_item(id);
native give_tho4mpson(id);
native give_weapon_buffaug(id);


// Setting File
new const ZE_SETTING_RESOURCES[] = "zombie_escape.ini"
 
// Keys
const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0
const OFFSET_CSMENUCODE = 205
 
// Primary Weapons Entities [Default Values]
new const szPrimaryWeaponEnt[][] =
{
    "weapon_xm1014",  // Level 0
    "weapon_ump45",   // Level 0
    "weapon_m3",      // Level 1
    "weapon_mp5navy", // Level 2
    "weapon_p90",     // Level 3
    "weapon_galil",   // Level 4
    "weapon_famas",   // Level 5
    "weapon_sg550",   // Level 6
    "weapon_g3sg1",   // Level 7
    "weapon_m249",    // Level 8
    "weapon_sg552",   // Level 9
    "weapon_aug",     // Level 10
    "weapon_m4a1",    // Level 11
    "weapon_ak47"     // Level 12
}
 
// Secondary Weapons Entities [Default Values]
new const szSecondaryWeaponEnt[][]=
{
    "weapon_usp",         // Level 0
    "weapon_p228",        // Level 0
    "weapon_glock18",     // Level 1
    "weapon_fiveseven",   // Level 2
    "weapon_deagle",      // Level 3
    "weapon_elite"        // Level 4
}
 
// Primary and Secondary Weapons Names [Default Values]
new const szWeaponNames[][] =
{
    "",
    "P228",
    "",
    "Scout",
    "HE Grenade",
    "XM1014",
    "",
    "MAC-10",
    "AUG",
    "Smoke Grenade",
    "Dual Elite",
    "Five Seven",
    "UMP 45",
    "SG-550",
    "Galil",
    "Famas",
    "USP",
    "Glock",
    "AWP",
    "MP5",
    "M249",
    "M3",
    "M4A1",
    "TMP",
    "G3SG1",
    "Flashbang",
    "Desert Eagle",
    "SG-552",
    "AK-47",
    "",
    "P90"
}
 
// Max Back Clip Ammo (Change it From here if you need)
new const szMaxBPAmmo[] =
{
    -1,
    52,
    -1,
    90,
    1,
    32,
    1,
    100,
    90,
    1,
    120,
    100,
    100,
    90,
    90,
    90,
    100,
    120,
    30,
    120,
    200,
    32,
    90,
    120,
    90,
    2,
    35,
    90,
    90,
    -1,
    100
}
 
// Menu selections
const MENU_KEY_AUTOSELECT = 7
const MENU_KEY_BACK = 7
const MENU_KEY_NEXT = 8
const MENU_KEY_EXIT = 9
 
// Variables
new Array:g_szPrimaryWeapons, Array:g_szSecondaryWeapons
 
new g_iMenuData[33][4],
    Float:g_fBuyTimeStart[33],
    bool:g_bBoughtPrimary[33],
    bool:g_bBoughtSecondary[33],
    WPN_MAXIDS[33]
 
// Define
#define WPN_STARTID g_iMenuData[id][0]
#define WPN_SELECTION (g_iMenuData[id][0]+key)
#define WPN_AUTO_ON g_iMenuData[id][1]
#define WPN_AUTO_PRI g_iMenuData[id][2]
#define WPN_AUTO_SEC g_iMenuData[id][3]
 
// Cvars
new g_pCvarBuyTime,
    g_pCvarHeGrenade,
    g_pCvarSmokeGrenade,
    g_pCvarFlashGrenade,
    g_pCvarBlockWeapLowLevel
 
public plugin_natives()
{
    register_native("ze_show_weapon_menu", "native_ze_show_weapon_menu", 1)
    register_native("ze_is_auto_buy_enabled", "native_ze_is_auto_buy_enabled", 1)
    register_native("ze_disable_auto_buy", "native_ze_disable_auto_buy", 1)
}
 
public plugin_precache()
{
    // Initialize arrays (32 is the max length of Weapon Entity like: weapon_ak47)
    g_szPrimaryWeapons = ArrayCreate(32, 1)
    g_szSecondaryWeapons = ArrayCreate(32, 1)
   
    // Load from external file
    amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
    amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
   
    // If we couldn't load from file, use and save default ones
   
    new iIndex
   
    if (ArraySize(g_szPrimaryWeapons) == 0)
    {
        for (iIndex = 0; iIndex < sizeof szPrimaryWeaponEnt; iIndex++)
            ArrayPushString(g_szPrimaryWeapons, szPrimaryWeaponEnt[iIndex])
       
        // If not found .ini File Create it and save default values in it
        amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
    }
   
    if (ArraySize(g_szSecondaryWeapons) == 0)
    {
        for (iIndex = 0; iIndex < sizeof szSecondaryWeaponEnt; iIndex++)
            ArrayPushString(g_szSecondaryWeapons, szSecondaryWeaponEnt[iIndex])
       
        // If not found .ini File Create it and save default values in it
        amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
    }
}
 
public plugin_init()
{
    register_plugin("[ZE] Levels Weapons Menu", "1.1", "Raheem")
   
    // Commands
    register_clcmd("guns", "Cmd_Buy")
    register_clcmd("say /enable", "Cmd_Enable")
    register_clcmd("say_team /enable", "Cmd_Enable")
   
    // Cvars
    g_pCvarBuyTime = register_cvar("ze_buy_time", "60")
    g_pCvarHeGrenade = register_cvar("ze_give_HE_nade", "1") // 0 Nothing || 1 Give HE
    g_pCvarSmokeGrenade = register_cvar("ze_give_SM_nade", "1")
    g_pCvarFlashGrenade = register_cvar("ze_give_FB_nade", "1")
    g_pCvarBlockWeapLowLevel = register_cvar("ze_block_weapons_lowlvl", "1")
   
    // Menus
    register_menu("Primary Weapons", KEYSMENU, "Menu_Buy_Primary")
    register_menu("Secondary Weapons", KEYSMENU, "Menu_Buy_Secondary")
   
    // Hams
    RegisterHam(Ham_Touch, "weaponbox", "Fw_TouchWeapon_Pre", 0)
    RegisterHam(Ham_Touch, "armoury_entity", "Fw_TouchWeapon_Pre", 0)
}
 
public client_disconnected(id)
{
    WPN_AUTO_ON = 0
    WPN_STARTID = 0
}
 
public Cmd_Enable(id)
{
    if (WPN_AUTO_ON)
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "BUY_ENABLED")
        WPN_AUTO_ON = 0
    }
}
 
public Cmd_Buy(id)
{
    // Player Zombie
    if (ze_is_user_zombie(id))
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "NO_BUY_ZOMBIE")
        return
    }
   
    // Player Dead
    if (!is_user_alive(id))
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "DEAD_CANT_BUY_WEAPON")
        return
    }
   
    // Already bought
    if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "ALREADY_BOUGHT")
    }
   
    Show_Available_Buy_Menus(id)
}
 
public ze_user_humanized(id)
{
    // Static Values
    switch (ze_get_user_level(id))
    {
        case 0: WPN_MAXIDS[id] = 2
        case 1: WPN_MAXIDS[id] = 3
        case 2: WPN_MAXIDS[id] = 4
        case 3: WPN_MAXIDS[id] = 5
        case 4: WPN_MAXIDS[id] = 6
        case 5: WPN_MAXIDS[id] = 7
        case 6: WPN_MAXIDS[id] = 8
        case 7: WPN_MAXIDS[id] = 9
        case 8: WPN_MAXIDS[id] = 10
        case 9: WPN_MAXIDS[id] = 11
        case 10: WPN_MAXIDS[id] = 12
        case 11: WPN_MAXIDS[id] = 13
        case 12..14: WPN_MAXIDS[id] = 14 
	case 15..16: WPN_MAXIDS[id] = 15 // Scar Beast
	case 17..19: WPN_MAXIDS[id] = 16 // Laser MiniGun
	case 20..24: WPN_MAXIDS[id] = 17 // Aug Guardian
        case 25: WPN_MAXIDS[id] = 18 // Golden M4A1
	case 26..29: WPN_MAXIDS[id] = 19 // Golden AK47
        case 30..34: WPN_MAXIDS[id] = 20 // Ak47 bloodmoon
        case 35..39: WPN_MAXIDS[id] = 21   // Dual Sword
	case 40: WPN_MAXIDS[id] = 22    // Jetpack
    }
   
    if (ze_get_user_level(id) > 40)
    {
        WPN_MAXIDS[id] = 22
    }
 
    // Buyzone time starts when player is set to human
    g_fBuyTimeStart[id] = get_gametime()
   
    g_bBoughtPrimary[id] = false
    g_bBoughtSecondary[id] = false
   
    // Player dead or zombie
    if (!is_user_alive(id) || ze_is_user_zombie(id))
        return
   
    if (WPN_AUTO_ON)
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "RE_ENABLE_MENU")
        Buy_Primary_Weapon(id, WPN_AUTO_PRI)
        Buy_Secondary_Weapon(id, WPN_AUTO_SEC)
    }
   
    // Open available buy menus
    Show_Available_Buy_Menus(id)
   
    // Give HE Grenade
    if (get_pcvar_num(g_pCvarHeGrenade) != 0)
        rg_give_item(id, "weapon_hegrenade")
   
    // Give Smoke Grenade
    if (get_pcvar_num(g_pCvarSmokeGrenade) != 0)
        rg_give_item(id, "weapon_smokegrenade")
   
    // Give Flashbang Grenade
    if (get_pcvar_num(g_pCvarFlashGrenade) != 0)
        rg_give_item(id, "weapon_flashbang")
}
 
public Show_Available_Buy_Menus(id)
{
    // Already Bought
    if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
        return
   
    // Here we use if and else if so we make sure that Primary weapon come first then secondary
    if (!g_bBoughtPrimary[id])
    {
        // Primary    
        Show_Menu_Buy_Primary(id)
    }
    else if (!g_bBoughtSecondary[id])
    {
        // Secondary
        Show_Menu_Buy_Secondary(id)
    }
}
 
public Show_Menu_Buy_Primary(id)
{
    new iMenuTime = floatround(g_fBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
   
    if (iMenuTime <= 0)
    {
        ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
        return
    }
   
    static szMenu[300], szWeaponName[32]
    new iLen, iIndex, iMaxLoops = min(WPN_STARTID+7, WPN_MAXIDS[id])
   
    // Title
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L \w[\r%d\w-\r%d\w]^n^n", id, "MENU_PRIMARY_TITLE", WPN_STARTID+1, min(WPN_STARTID+7, WPN_MAXIDS[id]))
   
    // 1-7. Weapon List
    for (iIndex = WPN_STARTID; iIndex < iMaxLoops; iIndex++)
    {
        if (ze_get_user_level(id) == 0 && iIndex >= 2||
        ze_get_user_level(id) == 1 && iIndex >= 3 ||
        ze_get_user_level(id) == 2 && iIndex >= 4 ||
        ze_get_user_level(id) == 3 && iIndex >= 5 ||
        ze_get_user_level(id) == 4 && iIndex >= 6 ||
        ze_get_user_level(id) == 5 && iIndex >= 7 ||
        ze_get_user_level(id) == 6 && iIndex >= 8 ||
        ze_get_user_level(id) == 7 && iIndex >= 9 ||
        ze_get_user_level(id) == 8 && iIndex >= 10 ||
        ze_get_user_level(id) == 9 && iIndex >= 11 ||
        ze_get_user_level(id) == 10 && iIndex >= 12 ||
        ze_get_user_level(id) == 11 && iIndex >= 13 ||
        ze_get_user_level(id) == 12 && iIndex >= 14)
        {
            break
        }
       
        /*
        *  Note that WPN_MAXIDS start from 1 but iIndex start from 0.
        */
       
	   // Scar Beast
        if (ze_get_user_level(id) >= 15 && ze_get_user_level(id) < 17)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Scar Beast")
                break;
            }
        }
	   
        // Laser MiniGun
        if (ze_get_user_level(id) >= 17 && ze_get_user_level(id) < 20)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Scar Beast")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Laser MiniGun")
                break;
            }
        }
       
        // Guardian Aug
        if (ze_get_user_level(id) >= 20 && ze_get_user_level(id) < 25)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Scar Beast")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Laser MiniGun")
            }
           
            if (iIndex == 16)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Guardian Aug")
                break;
            }
        }
       
        // Golden M4A1
        if (ze_get_user_level(id) >= 25 && ze_get_user_level(id) < 26)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Scar Beast")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Laser MiniGun")
            }
           
            if (iIndex == 16)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Guardian Aug")
            }
           
            if (iIndex == 17)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
                break;
            }
        }
       
        // Golden AK47
        if (ze_get_user_level(id) >= 26 && ze_get_user_level(id) < 30)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Scar Beast")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Laser MiniGun")
            }
           
            if (iIndex == 16)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Guardian Aug")
            }
           
            if (iIndex == 17)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
            }
           
            if (iIndex == 18)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK47")
				break;
            }			
        }
		
		// AK 47 Bloodmoon
        if (ze_get_user_level(id) >= 30 && ze_get_user_level(id) < 35)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Scar Beast")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Laser MiniGun")
            }
           
            if (iIndex == 16)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Guardian Aug")
            }
           
            if (iIndex == 17)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
            }
           
            if (iIndex == 18)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK47")
            }		
			
			if (iIndex == 19)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AK47 Bloodmoon")
				break;
            }		
        }
		
		// Dual Sword
        if (ze_get_user_level(id) >= 35 && ze_get_user_level(id) < 40)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Scar Beast")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Laser MiniGun")
            }
           
            if (iIndex == 16)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Guardian Aug")
            }
           
            if (iIndex == 17)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
            }
           
            if (iIndex == 18)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK47")
            }		
			
			if (iIndex == 19)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AK47 Bloodmoon")
            }

			if (iIndex == 20)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Dual Sword")
				break;
            }		
        }
       
	   // JetPack
        if (ze_get_user_level(id) >= 40 && ze_get_user_level(id) < 40)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Scar Beast")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Laser MiniGun")
            }
           
            if (iIndex == 16)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Guardian Aug")
            }
           
            if (iIndex == 17)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
            }
           
            if (iIndex == 18)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK47")
            }		
			
			if (iIndex == 19)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "AK47 Bloodmoon")
            }

			if (iIndex == 20)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Dual Sword")
            }
			if (iIndex == 21)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Jetpack")
				break;
        }
		
        // Must check if iIndex < 14 means max is AK47
        if (iIndex < 14)
        {
            ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
            iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, szWeaponNames[get_weaponid(szWeaponName)])
        }
    }
   
    if (iIndex < 7)
    {
        ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
   
    if (ze_get_user_level(id) == 5)
    {
        ArrayGetString(g_szPrimaryWeapons, 7, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 6)
    {
        ArrayGetString(g_szPrimaryWeapons, 8, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 7)
    {
        ArrayGetString(g_szPrimaryWeapons, 9, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 8)
    {
        ArrayGetString(g_szPrimaryWeapons, 10, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 9)
    {
        ArrayGetString(g_szPrimaryWeapons, 11, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 10)
    {
        ArrayGetString(g_szPrimaryWeapons, 12, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 11)
    {
        ArrayGetString(g_szPrimaryWeapons, 13, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) >= 12 && ze_get_user_level(id) < 15) // Scar Beast
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 15 Unlock\w: \yScar Beast^n")
    }
    else if (ze_get_user_level(id) >= 15 && ze_get_user_level(id) < 17) // Laser MiniGun
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 17 Unlock\w: \yLaser MiniGun^n")
    }
    else if (ze_get_user_level(id) >= 17 && ze_get_user_level(id) < 20) // Guardian Aug
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 20 Unlock\w: \yGuardian Aug^n")
    }
    else if (ze_get_user_level(id) >= 20 && ze_get_user_level(id) < 25) // Golden M4A1
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 25 Unlock\w: \yGolden M4A1^n")
    }
    else if (ze_get_user_level(id) >= 25 && ze_get_user_level(id) < 26) // Golden AK47
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 26 Unlock\w: \yGolden AK47^n")
    }
	else if (ze_get_user_level(id) >= 26 && ze_get_user_level(id) < 30) // AK47 Bloodmoon
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 30 Unlock\w: \yAK47 Bloodmoon^n")
    }
    else if (ze_get_user_level(id) >= 30 && ze_get_user_level(id) < 35) // Dual Sword
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 35 Unlock\w: \yDual Sword^n")
    }
    else if (ze_get_user_level(id) >= 35 && ze_get_user_level(id) < 40) // Jetpack
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 26 Unlock\w: \yJetpack^n")
    }
	
    // 8. Auto Select
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\w8.\y %L \w[\r%L\w]", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "SAVE_YES" : "SAVE_NO")
   
    // 9. Next/Back - 0. Exit
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\y9.\r %L \w/ \r%L^n^n\w0.\y %L", id, "NEXT", id, "BACK", id, "EXIT")
   
    // Fix for AMXX custom menus
    set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    show_menu(id, KEYSMENU, szMenu, iMenuTime, "Primary Weapons")
}
 
public Show_Menu_Buy_Secondary(id)
{
    new iMenuTime = floatround(g_fBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
   
    if (iMenuTime <= 0)
    {
        ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
        return
    }
   
    static szMenu[250], szWeaponName[32]
    new iLen, iIndex, iMaxLoops = ArraySize(g_szSecondaryWeapons)
   
    // Title
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L^n", id, "MENU_SECONDARY_TITLE")
   
    // 1-6. Weapon List
    for (iIndex = 0; iIndex < iMaxLoops; iIndex++)
    {
        if (ze_get_user_level(id) == 0 && iIndex >= 2 ||
        ze_get_user_level(id) == 1 && iIndex >= 3 ||
        ze_get_user_level(id) == 2 && iIndex >= 4 ||
        ze_get_user_level(id) == 3 && iIndex >= 5 ||
        ze_get_user_level(id) == 4 && iIndex >= 6)
        {
            break
        }
       
        ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\w%d.\y %s", iIndex+1, szWeaponNames[get_weaponid(szWeaponName)])
    }
   
    if (iIndex < ArraySize(g_szSecondaryWeapons))
    {
        ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r Next Level Unlock\w: \y%s", szWeaponNames[get_weaponid(szWeaponName)])
    }
   
    // 8. Auto Select
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w8.\y %L \w[\r%L\w]", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "SAVE_YES" : "SAVE_NO")
   
    // 0. Exit
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\y %L", id, "EXIT")
   
    // Fix for AMXX custom menus
    set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    show_menu(id, KEYSMENU, szMenu, iMenuTime, "Secondary Weapons")
}
 
public Menu_Buy_Primary(id, key)
{
    // Player dead or zombie or already bought primary
    if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtPrimary[id])
        return PLUGIN_HANDLED
   
    // Special keys / weapon list exceeded
    if (key >= MENU_KEY_AUTOSELECT || WPN_SELECTION >= WPN_MAXIDS[id])
    {
        switch (key)
        {
            case MENU_KEY_AUTOSELECT: // toggle auto select
            {
                WPN_AUTO_ON = 1 - WPN_AUTO_ON
            }
            case MENU_KEY_NEXT: // next/back
            {
                if (WPN_STARTID+7 < WPN_MAXIDS[id])
                    WPN_STARTID += 7
                else
                    WPN_STARTID = 0
            }
            case MENU_KEY_EXIT: // exit
            {
                return PLUGIN_HANDLED
            }
        }
       
        // Show buy menu again
        Show_Menu_Buy_Primary(id)
        return PLUGIN_HANDLED
    }
   
    // Store selected weapon id
    WPN_AUTO_PRI = WPN_SELECTION
   
    // Buy primary weapon
    Buy_Primary_Weapon(id, WPN_AUTO_PRI)
   
    // Show Secondary Weapons
    Show_Available_Buy_Menus(id)
   
    return PLUGIN_HANDLED
}
 
public Buy_Primary_Weapon(id, selection)
{
    if (selection == 14) // Scar Beast
    {
        give_tho4mpson(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
    else if (selection == 15) // Laser MiniGun
    {
        get_item(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
	else if (selection == 16) // Guardian Aug
    {
        give_buffaug(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
	else if (selection == 17) // Golden M4A1
    {
        give_golden_m4a1
        g_bBoughtPrimary[id] = true
        return true;
    }
    else if (selection == 18) // Golden AK47
    {
        give_golden_ak47(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
	 else if (selection == 19) // AK47 Bloodmoon
    {
        get_bak47p(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
	else if (selection == 20) // Dual Sword
    {
        give_daul_sword(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
	else if (selection == 21) // Jetpack
    {
        ze_give_jetpack(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
   
    static szWeaponName[32]
    ArrayGetString(g_szPrimaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
    new iWeaponId = get_weaponid(szWeaponName)
   
    // Strip and Give Full Weapon
    rg_give_item(id, szWeaponName, GT_REPLACE)
    rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
   
    // Primary bought
    g_bBoughtPrimary[id] = true
    return true;
}
 
public Menu_Buy_Secondary(id, key)
{
    // Player dead or zombie or already bought secondary
    if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtSecondary[id])
        return PLUGIN_HANDLED
   
    // Special keys / weapon list exceeded
    if (key >= ArraySize(g_szSecondaryWeapons))
    {
        // Toggle autoselect
        if (key == MENU_KEY_AUTOSELECT)
            WPN_AUTO_ON = 1 - WPN_AUTO_ON
       
        // Reshow menu unless user exited
        if (key != MENU_KEY_EXIT)
            Show_Menu_Buy_Secondary(id)
       
        return PLUGIN_HANDLED
    }
   
    // Store selected weapon id
    WPN_AUTO_SEC = key
   
    // Buy secondary weapon
    Buy_Secondary_Weapon(id, key)
   
    return PLUGIN_HANDLED
}
 
public Buy_Secondary_Weapon(id, selection)
{
    if ( ((selection == 2) && (ze_get_user_level(id) < 1)) ||
    ((selection == 3) && (ze_get_user_level(id) < 2)) ||
    ((selection == 4) && (ze_get_user_level(id) < 3)) ||
    ((selection == 5) && (ze_get_user_level(id) < 4)) )
    {
        Show_Menu_Buy_Secondary(id)
        return;
    }
 
    static szWeaponName[32]
    ArrayGetString(g_szSecondaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
    new iWeaponId = get_weaponid(szWeaponName)
   
    // Strip and Give Full Weapon
    rg_give_item(id, szWeaponName, GT_REPLACE)
    rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
   
    // Secondary bought
    g_bBoughtSecondary[id] = true
}
 
public Fw_TouchWeapon_Pre(iEnt, id)
{
    if (get_pcvar_num(g_pCvarBlockWeapLowLevel) == 0)
        return HAM_IGNORED;
   
    // Not alive or Not Valid Weapon?
    if(!is_user_alive(id) || !pev_valid(iEnt))
        return HAM_IGNORED;
   
    // Get Weapon Model
    new szWeapModel[32]
    pev(iEnt, pev_model, szWeapModel, charsmax(szWeapModel))
   
    // Remove "models/w_" and ".mdl"
    copyc(szWeapModel, charsmax(szWeapModel), szWeapModel[contain(szWeapModel, "_" ) + 1], '.')
   
    // Set for mp5 to be same as "weapon_mp5navy"
    if(szWeapModel[1] == 'p' && szWeapModel[2] == '5')
        szWeapModel = "mp5navy"
   
    // Add "weapon_" to all model names
    static szWeaponEnt[32]
    formatex(szWeaponEnt, charsmax(szWeaponEnt), "weapon_%s", szWeapModel)
 
    // Get it's index in Weapon Array
    new iIndex, i
   
    // I won't explain the blew code if you need to understand ask me in Escapers-Zone.XYZ
    for (i = 0; i < ArraySize(g_szPrimaryWeapons); i++)
    {
        new szPrimaryWeapon[32]
        ArrayGetString(g_szPrimaryWeapons, i, szPrimaryWeapon, charsmax(szPrimaryWeapon))
       
        if (equali(szWeaponEnt, szPrimaryWeapon))
            iIndex = i
    }
   
    if (ze_get_user_level(id) == 0 && iIndex > 1)
    {
        return HAM_SUPERCEDE;
    }
   
    for (i = 1; i <= 11; i++)
    {
        if ((ze_get_user_level(id) == i) && iIndex > i+1)
        {
            return HAM_SUPERCEDE;
        }
    }
   
    return HAM_IGNORED;
}
 
// Natives
public native_ze_show_weapon_menu(id)
{
    if (!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
        return false
    }
   
    Cmd_Buy(id)
    return true
}
 
public native_ze_is_auto_buy_enabled(id)
{
    if (!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
        return -1;
    }
   
    return WPN_AUTO_ON;
}
 
public native_ze_disable_auto_buy(id)
{
    if (!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
        return false
    }
   
    WPN_AUTO_ON = 0;
    return true
}
Here is pistol, I want to add this for 7 level in Secondary Weapons

Code: Select all

give_sfpistol(id)
Image

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

#18

Post by Raheem » 5 years ago

Post a picture of how it looks when it's exceeded.
He who fails to plan is planning to fail

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

#19

Post by czirimbolo » 5 years ago

I added 2 guns it was ok, I added more guns and I cant compile this:

Code: Select all

 C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(303) : error 017: undefined symbol "Buy_Primary_Weapon"
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(304) : error 017: undefined symbol "Buy_Secondary_Weapon"
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(338) : error 017: undefined symbol "Show_Menu_Buy_Secondary"
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(350) : warning 209: function "Show_Menu_Buy_Primary" should return a value
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(478) : warning 217: loose indentation
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(510) : warning 217: loose indentation
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(513) : warning 217: loose indentation
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(545) : warning 217: loose indentation
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(553) : warning 217: loose indentation
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(585) : warning 217: loose indentation
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(597) : warning 217: loose indentation
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(601) : warning 217: loose indentation
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(608) : warning 217: loose indentation
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(673) : warning 217: loose indentation
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(693) : warning 217: loose indentation
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(693) : error 029: invalid expression, assumed zero
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(693) : error 017: undefined symbol "Show_Menu_Buy_Secondary"
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(701) : warning 209: function "Show_Menu_Buy_Primary" should return a value
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(742) : error 029: invalid expression, assumed zero
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(742) : error 017: undefined symbol "Menu_Buy_Primary"
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(746) : error 078: function uses both "return" and "return <value>"
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(749) : error 017: undefined symbol "key"
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(751) : error 017: undefined symbol "key"
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(766) : error 078: function uses both "return" and "return <value>"
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(772) : error 078: function uses both "return" and "return <value>"
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(776) : error 017: undefined symbol "key"
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(779) : error 017: undefined symbol "Buy_Primary_Weapon"
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(784) : error 078: function uses both "return" and "return <value>"
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(787) : warning 225: unreachable code
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(787) : error 029: invalid expression, assumed zero
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(787) : error 017: undefined symbol "Buy_Primary_Weapon"
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(789) : error 017: undefined symbol "selection"
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(793) : error 078: function uses both "return" and "return <value>"
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(795) : error 017: undefined symbol "selection"
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(799) : error 078: function uses both "return" and "return <value>"
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(801) : error 017: undefined symbol "selection"
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(803) : error 017: undefined symbol "give_buffaug"
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(805) : error 078: function uses both "return" and "return <value>"
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(807) : error 017: undefined symbol "selection"
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\ze_weapon_menu.sma(809 -- 810) : error 088: number of arguments does not match definition
//
// Compilation aborted.
// 26 Errors.
// Could not locate output file compiled\ze_weapon_menu.amx (compile failed).
code is above, in post nr 17
Image

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

#20

Post by Raheem » 5 years ago

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

You just forget } in if (iIndex == 21).
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 8 guests