VIP balrog

Unpaid Requests, Public Plugins
Post Reply
User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 258
Joined: 7 years ago
Contact:

VIP balrog

#1

Post by sPe3doN » 5 years ago

i try to add balrog to vip when he chose weapon from menu he get balrog with it but don't work i add native
balrog >

Code: Select all

/*================================================================================
 
            --------------------------------
            [ZE] Extra Item: Balrog Ethereal
            --------------------------------
 
        Balrog Ethereal
        Copyright (C) 2017 by Crazy + ZE DEV TEAM
 
        -------------------
        -*- Description -*-
        -------------------
 
        This plugin add a new weapon into your zombie plague mod with
        the name of Balrog Ethereal. That weapon launch a powerfull beams!
        When the laser hit any object, a explosion effect with red color appers.
 
        ----------------
        -*- Commands -*-
        ----------------
 
        * zp_give_balrog_ethereal <target> - Give the item to target.
 
        -------------
        -*- Cvars -*-
        -------------
 
        * ze_balrog_ethereal_ammo <number> - Ammo amout.
        * ze_balrog_ethereal_clip <number> - Clip amout. (Max: 100)
        * ze_balrog_ethereal_one_round <0/1> - Only one round.
        * ze_balrog_ethereal_damage <number> - Damage multiplier.
        * ze_balrog_ethereal_unlimited <0/1> - Unlimited ammunition.
 
        ------------------
        -*- Change Log -*-
        ------------------
 
        * v1.5: (Mar 2017)
            - Updated all the code, added explosion effect, added new cvars;
 
        * v1.6: (Mar 2017)
            - Added custom weapon hud;
 
        ---------------
        -*- Credits -*-
        ---------------
 
        * MeRcyLeZZ: for the nice zombie plague mod.
        * Crazy: created the extra item code.
        * deanamx: for the nice weapon model.
        * And all zombie-mod players that use this weapon.
        * ZE DEV TEAM : For converting this Item
 
 
=================================================================================*/
#include <zombie_escape>
#include <cstrike>
#include <engine>

/*================================================================================
 [Plugin Customization]
=================================================================================*/
 
// Item Name
#define ITEM_NAME "Balrog Ethereal"
 
 
/*================================================================================
 Customization ends here! Yes, that's it. Editing anything beyond
 here is not officially supported. Proceed at your own risk...
=================================================================================*/
 
new const PLUGIN_VERSION[] = "v1.6";
 
new const V_BALROG_MDL[64] = "models/zombie_escape/v_balrog_ethereal.mdl";
new const P_BALROG_MDL[64] = "models/zombie_escape/p_balrog_ethereal.mdl";
new const W_BALROG_MDL[64] = "models/zombie_escape/w_balrog_ethereal.mdl";
 
new const BALROG_SOUNDS[][] = { "weapons/ethereal_shoot.wav", "weapons/ethereal_reload.wav", "weapons/ethereal_idle1.wav", "weapons/ethereal_draw.wav" };
 
new g_has_balrog[33], g_laser_sprite, g_balrog_exp, g_balrog, g_event_balrog, g_playername[33][32], g_maxplayers, g_primary_attack, g_balrog_reload_clip[33], cvar_balrog_clip, cvar_balrog_ammo, cvar_balrog_damage, cvar_balrog_oneround, cvar_balrog_unlimited;
 
const BALROG_KEY = 0982478;
 
const m_iClip = 51;
const m_flNextAttack = 83;
const m_fInReload = 54;
 
const OFFSET_WEAPON_OWNER = 41;
const OFFSET_LINUX_WEAPONS = 4;
const OFFSET_LINUX = 5;
const OFFSET_ACTIVE_ITEM = 373;
 
const WEAPON_BITSUM = ((1<<CSW_SCOUT) | (1<<CSW_XM1014) | (1<<CSW_MAC10) | (1<<CSW_AUG) | (1<<CSW_UMP45) | (1<<CSW_SG550) | (1<<CSW_P90) | (1<<CSW_FAMAS) | (1<<CSW_AWP) | (1<<CSW_MP5NAVY) | (1<<CSW_M249) | (1<<CSW_M3) | (1<<CSW_M4A1) | (1<<CSW_TMP) | (1<<CSW_G3SG1) | (1<<CSW_SG552) | (1<<CSW_AK47) | (1<<CSW_GALIL));
 
enum
{
    idle = 0,
    reload,
    draw,
    shoot1,
    shoot2,
    shoot3
}
 
public plugin_init()
{
    /* Plugin register */
    register_plugin("[ZE] Extra Item: Balrog Ethereal", PLUGIN_VERSION, "Crazy");
 
    /* Item register */
    g_balrog = ze_register_item("Balrog Ethereal", 10, 0);
 
    /* Events */
    register_event("HLTV", "event_round_start", "a", "1=0", "2=0");
 
    /* Messages */
    register_message(get_user_msgid("CurWeapon"), "message_cur_weapon");
 
    /* Forwards */
    register_forward(FM_UpdateClientData, "fw_UpdateData_Post", 1);
    register_forward(FM_SetModel, "fw_SetModel");
    register_forward(FM_PlaybackEvent, "fw_PlaybackEvent");
 
    /* Ham Forwards */
    RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_Item_Deploy, "weapon_ump45", "fw_Item_Deploy_Post", 1);
    RegisterHam(Ham_Item_AddToPlayer, "weapon_ump45", "fw_Item_AddToPlayer_Post", 1);
    RegisterHam(Ham_Item_PostFrame, "weapon_ump45", "fw_Item_PostFrame");
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_PrimaryAttack");
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_PrimaryAttack_Post", 1);
    RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Reload");
    RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Reload_Post", 1);
    RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage");
 
    /* Cvars */
    cvar_balrog_clip = register_cvar("ze_balrog_minigun_clip", "50");
    cvar_balrog_ammo = register_cvar("ze_balrog_minigun_ammo", "200");
    cvar_balrog_damage = register_cvar("ze_balrog_minigun_damage", "3.0");
    cvar_balrog_oneround = register_cvar("ze_balrog_minigun_one_round", "0");
    cvar_balrog_unlimited = register_cvar("ze_balrog_minigun_unlimited", "0");
 
    /* Max Players */
    g_maxplayers = get_maxplayers()
}
 
public plugin_precache()
{
    engfunc(EngFunc_PrecacheModel, V_BALROG_MDL);
    engfunc(EngFunc_PrecacheModel, P_BALROG_MDL);
    engfunc(EngFunc_PrecacheModel, W_BALROG_MDL);
 
    engfunc(EngFunc_PrecacheGeneric, "sprites/weapon_bethereal.txt");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud2_bethereal.spr");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud10_bethereal.spr");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud74_bethereal.spr");
 
    for (new i = 0; i < sizeof BALROG_SOUNDS; i++)
    engfunc(EngFunc_PrecacheSound, BALROG_SOUNDS[i]);
 
    g_laser_sprite = precache_model("sprites/laserbeam.spr");
    g_balrog_exp = precache_model("sprites/zombie_plague/balrog_ethereal_exp.spr");
 
    register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1);
    register_clcmd("weapon_bethereal", "cmd_balrog_selected");
}
 
public ze_user_infected(id)
{
    g_has_balrog[id] = false;
}
 
public ze_user_humanized(id)
{
    g_has_balrog[id] = false;
}
 
public client_putinserver(id)
{
    g_has_balrog[id] = false;
 
    get_user_name(id, g_playername[id], charsmax(g_playername[]));
}
 
public event_round_start()
{
    for (new id = 0; id <= g_maxplayers; id++)
    {
        if (get_pcvar_num(cvar_balrog_oneround))
        g_has_balrog[id] = false;
    }
}
 
public cmd_balrog_selected(client)
{
    engclient_cmd(client, "weapon_ump45");
    return PLUGIN_HANDLED;
}
 
public message_cur_weapon(msg_id, msg_dest, msg_entity)
{
    if (!is_user_alive(msg_entity))
        return;
 
    if (!g_has_balrog[msg_entity])
        return;
 
    if (get_user_weapon(msg_entity) != CSW_UMP45)
        return;
 
    if (get_msg_arg_int(1) != 1)
        return;
 
    if (get_pcvar_num(cvar_balrog_unlimited))
    {
        static ent;
        ent = fm_cs_get_current_weapon_ent(msg_entity);
 
        if (!pev_valid(ent))
            return;
 
        cs_set_weapon_ammo(ent, get_pcvar_num(cvar_balrog_clip));
        set_msg_arg_int(3, get_msg_argtype(3), get_pcvar_num(cvar_balrog_clip));
    }
}
 
public ze_select_item_pre(id, itemid)
{
    // This not our item?
    if (itemid != g_balrog)
        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
   
    // Finally return that it's available
    return ZE_ITEM_AVAILABLE
}
 
public ze_select_item_post(id, itemid)
{
    if (itemid != g_balrog)
        return;
 
    if (g_has_balrog[id])
    {
        client_print(id, print_chat, "[ZE] You already have the %s.", ITEM_NAME);
        return;
    }
 
    give_balrog(id);
 
    client_print(id, print_chat, "[ZE] You bought the %s.", ITEM_NAME);
}
 
public fw_UpdateData_Post(id, sendweapons, cd_handle)
{
    if (!is_user_alive(id))
        return FMRES_IGNORED;
 
    if (!g_has_balrog[id])
        return FMRES_IGNORED;
 
    if (get_user_weapon(id) != CSW_UMP45)
        return FMRES_IGNORED;
 
    set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001);
 
    return FMRES_IGNORED;
}
 
public fw_SetModel(ent, const model[])
{
    if (!pev_valid(ent))
        return FMRES_IGNORED;
 
    if (!equal(model, "models/w_ump45.mdl"))
        return HAM_IGNORED;
 
    static class_name[33];
    pev(ent, pev_classname, class_name, charsmax(class_name));
 
    if (!equal(class_name, "weaponbox"))
        return FMRES_IGNORED;
 
    static owner, weapon;
    owner = pev(ent, pev_owner);
    weapon = find_ent_by_owner(-1, "weapon_ump45", ent);
 
    if (!g_has_balrog[owner] || !pev_valid(weapon))
        return FMRES_IGNORED;
 
    g_has_balrog[owner] = false;
 
    set_pev(weapon, pev_impulse, BALROG_KEY);
 
    engfunc(EngFunc_SetModel, ent, W_BALROG_MDL);
 
    return FMRES_SUPERCEDE;
}
 
public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
    if ((eventid != g_event_balrog) || !g_primary_attack)
        return FMRES_IGNORED;
 
    if (!(1 <= invoker <= g_maxplayers))
        return FMRES_IGNORED;
 
    playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2);
 
    return FMRES_SUPERCEDE;
}
 
public fw_PrecacheEvent_Post(type, const name[])
{
    if (!equal("events/ump45.sc", name))
        return HAM_IGNORED;
 
    g_event_balrog = get_orig_retval()
 
    return FMRES_HANDLED;
}
 
public fw_Item_Deploy_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    set_pev(id, pev_viewmodel2, V_BALROG_MDL);
    set_pev(id, pev_weaponmodel2, P_BALROG_MDL);
 
    play_weapon_anim(id, draw);
 
    return HAM_IGNORED;
}
 
public fw_Item_AddToPlayer_Post(ent, id)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (pev(ent, pev_impulse) == BALROG_KEY)
    {
        g_has_balrog[id] = true;
        set_pev(ent, pev_impulse, 0);
    }
 
    message_begin(MSG_ONE, get_user_msgid("WeaponList"), _, id)
    write_string((g_has_balrog[id] ? "weapon_bethereal" : "weapon_ump45"))
    write_byte(6)
    write_byte(100)
    write_byte(-1)
    write_byte(-1)
    write_byte(0)
    write_byte(15)
    write_byte(CSW_UMP45)
    write_byte(0)
    message_end()
 
    return HAM_IGNORED;
}
 
public fw_Item_PostFrame(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    static cvar_clip; cvar_clip = get_pcvar_num(cvar_balrog_clip);
 
    new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
    new bpammo = cs_get_user_bpammo(id, CSW_UMP45);
 
    new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, OFFSET_LINUX);
    new fInReload = get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS);
 
    if (fInReload && flNextAttack <= 0.0)
    {
        new temp_clip = min(cvar_clip - clip, bpammo);
 
        set_pdata_int(ent, m_iClip, clip + temp_clip, OFFSET_LINUX_WEAPONS);
 
        cs_set_user_bpammo(id, CSW_UMP45, bpammo-temp_clip);
 
        set_pdata_int(ent, m_fInReload, 0, OFFSET_LINUX_WEAPONS);
 
        fInReload = 0;
    }
 
    return HAM_IGNORED;
}
 
public fw_PrimaryAttack(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (!cs_get_weapon_ammo(ent))
        return HAM_IGNORED;
 
    g_primary_attack = true;
 
    return HAM_IGNORED;
}
 
public fw_PrimaryAttack_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (!cs_get_weapon_ammo(ent))
        return HAM_IGNORED;
 
    g_primary_attack = false;
 
    play_weapon_anim(id, random_num(shoot1, shoot3));
 
    emit_sound(id, CHAN_WEAPON, BALROG_SOUNDS[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
 
    make_laser_beam(id, 7, 100, 0, 0);
 
    return HAM_IGNORED;
}
 
public fw_Reload(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    static cvar_clip;
 
    if (g_has_balrog[id])
        cvar_clip = get_pcvar_num(cvar_balrog_clip);
 
    g_balrog_reload_clip[id] = -1;
 
    new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
    new bpammo = cs_get_user_bpammo(id, CSW_UMP45);
 
    if (bpammo <= 0)
        return HAM_SUPERCEDE;
 
    if (clip >= cvar_clip)
        return HAM_SUPERCEDE;
   
    g_balrog_reload_clip[id] = clip;
 
    return HAM_IGNORED;
}
 
public fw_Reload_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (g_balrog_reload_clip[id] == -1)
        return HAM_IGNORED;
 
    set_pdata_int(ent, m_iClip, g_balrog_reload_clip[id], OFFSET_LINUX_WEAPONS);
    set_pdata_int(ent, m_fInReload, 1, OFFSET_LINUX_WEAPONS);
 
    play_weapon_anim(id, reload);
 
    return HAM_IGNORED;
}
 
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, dmg_bits)
{
    if (!is_user_alive(attacker))
        return HAM_IGNORED;
 
    if (!g_has_balrog[attacker])
        return HAM_IGNORED;
 
    if (get_user_weapon(attacker) != CSW_UMP45)
        return HAM_IGNORED;
 
    SetHamParamFloat(OFFSET_LINUX_WEAPONS, damage * get_pcvar_float(cvar_balrog_damage));
 
    make_explosion_effect(attacker);
 
    return HAM_IGNORED;
}
 
public fw_TraceAttack_Post(ent, attacker, Float:damage, Float:dir[3], ptr, dmg_bits)
{
    if (!is_user_alive(attacker))
        return HAM_IGNORED;
 
    if (get_user_weapon(attacker) != CSW_UMP45)
        return HAM_IGNORED;
 
    if (!g_has_balrog[attacker])
        return HAM_IGNORED;
 
    make_explosion_effect(attacker);
 
    return HAM_IGNORED;
}
 
give_balrog(id)
{
    drop_primary(id);
 
    g_has_balrog[id] = true;
 
    new weapon = fm_give_item(id, "weapon_ump45");
 
    cs_set_weapon_ammo(weapon, get_pcvar_num(cvar_balrog_clip));
    cs_set_user_bpammo(id, CSW_UMP45, get_pcvar_num(cvar_balrog_ammo));
}
 
play_weapon_anim(id, frame)
{
    set_pev(id, pev_weaponanim, frame);
 
    message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = id)
    write_byte(frame)
    write_byte(pev(id, pev_body))
    message_end()
}
 
make_laser_beam(id, Size, R, G, B)
{
    static End[3];
    get_user_origin(id, End, 3);
   
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte (TE_BEAMENTPOINT)
    write_short( id |0x1000 )
    write_coord(End[0])
    write_coord(End[1])
    write_coord(End[2])
    write_short(g_laser_sprite)
    write_byte(0)
    write_byte(1)
    write_byte(1)
    write_byte(Size)
    write_byte(4)
    write_byte(R)
    write_byte(G)
    write_byte(B)
    write_byte(255)
    write_byte(0)
    message_end()
}
 
make_explosion_effect(id)
{
    static end[3];
    get_user_origin(id, end, 3);
 
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte(3)
    write_coord(end[0])
    write_coord(end[1])
    write_coord(end[2])
    write_short(g_balrog_exp)
    write_byte(10)
    write_byte(15)
    write_byte(4)
    message_end()
}
 
drop_primary(id)
{
    static weapons[32], num;
    get_user_weapons(id, weapons, num);
 
    for (new i = 0; i < num; i++)
    {
        if (WEAPON_BITSUM & (1<<weapons[i]))
        {
            static wname[32];
            get_weaponname(weapons[i], wname, sizeof wname - 1);
 
            engclient_cmd(id, "drop", wname);
        }
    }
}
 
stock fm_give_item(index, const item[])
{
    if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
        return 0;
 
    new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item));
    if (!pev_valid(ent))
        return 0;
 
    new Float:origin[3];
    pev(index, pev_origin, origin);
    set_pev(ent, pev_origin, origin);
    set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
    dllfunc(DLLFunc_Spawn, ent);
 
    new save = pev(ent, pev_solid);
    dllfunc(DLLFunc_Touch, ent, index);
    if (pev(ent, pev_solid) != save)
        return ent;
 
    engfunc(EngFunc_RemoveEntity, ent);
 
    return -1;
}
 
stock fm_cs_get_current_weapon_ent(id)
{
    if (pev_valid(id) != 2)
        return -1;
   
    return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX);
}

public plugin_natives()
{
	register_native("give_balrog", "native_give_balrog", 1)
}

public native_give_balrog(id)
{
	if ((get_user_flags(id) & ADMIN_LEVEL_H))
	{
		g_has_balrog[id] = true
		
		rg_give_item(id, "weapon_ump45", GT_APPEND)
	}

}
Weapon menu >

Code: Select all

#include <zombie_escape>

native give_balrog(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_m4a1",
	"weapon_ak47",
	"weapon_aug",
	"weapon_galil",
	"weapon_famas",
	"weapon_mp5navy",
	"weapon_p90"
}

// Secondary Weapons Entities [Default Values]
new const szSecondaryWeaponEnt[][]=
{
	"weapon_usp",
	"weapon_deagle",
	"weapon_p228",
	"weapon_elite",
}

// Primary and Secondary Weapons Names [Default Values]
new const szWeaponNames[][] = 
{ 
	"", 
	"P228", 
	"",
	"Scout",
	"HE Grenade",
	"XM1014",
	"",
	"MAC-10",
	"AUG",
	"Smoke Grenade", 
	"elite",
	"Five Seven",
	"UMP 45",
	"SG-550",
	"Galil",
	"Famas",
	"Usp",
	"Glock",
	"AWP",
	"MP5",
	"M249",
	"M3",
	"M4A1",
	"TMP",
	"G3SG1",
	"Flashbang",
	"Deagle",
	"SG-552",
	"AK-47",
	"",
	"P90"
}

// Max Back Clip Ammo (Change it From here if you need)
new const szMaxBPAmmo[] =
{
	-1,
	200,
	-1,
	200,
	1,
	200,
	1,
	200,
	200,
	1,
	200,
	200,
	200,
	200,
	200,
	200,
	200,
	200,
	200,
	200,
	200,
	200,
	200,
	200,
	200,
	2,
	200,
	200,
        200,
	-1,
	200
}

// Menu selections
const MENU_KEY_AUTOSELECT = 7
const MENU_KEY_BACK = 7
const MENU_KEY_NEXT = 8
const MENU_KEY_EXIT = 9

// Variables
new Array:g_szPrimaryWeapons,
	Array:g_szSecondaryWeapons

new g_iMenuData[33][4], 
	Float:g_fBuyTimeStart[33], 
	bool:g_bBoughtPrimary[33], 
	bool:g_bBoughtSecondary[33]

// Define
#define WPN_STARTID g_iMenuData[id][0]
#define WPN_MAXIDS ArraySize(g_szPrimaryWeapons)
#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
	
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] Weapons Menu", ZE_VERSION, AUTHORS)
	
	// 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", "600")
	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")
	
	// Menus
	register_menu("Primary Weapons", KEYSMENU, "Menu_Buy_Primary")
	register_menu("Secondary Weapons", KEYSMENU, "Menu_Buy_Secondary")
}

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)
{
	// 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")
		
	if (WPN_AUTO_ON)
	{
		Buy_Primary_Weapon(id, WPN_AUTO_PRI)
	}

	if (WPN_AUTO_ON)
	{
		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)
	
	// Title
	iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L ^n^n", id, "MENU_PRIMARY_TITLE", WPN_STARTID+1, min(WPN_STARTID+7, WPN_MAXIDS))
	
	// 1-7. Weapon List
	for (iIndex = WPN_STARTID; iIndex < iMaxLoops; iIndex++)
	{
		ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r%d.\w %s^n", iIndex-WPN_STARTID+1, szWeaponNames[get_weaponid(szWeaponName)])
	}

	// 8. Auto Select
	iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r8.\w %L \r%L", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "SAVE_YES" : "SAVE_NO")
	
	// 0. Exit
	iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r0.\r %L", 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++)
	{
		ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r%d.\w %s", iIndex+1, szWeaponNames[get_weaponid(szWeaponName)])
	}
	
	// 8. Auto Select
	iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r8.\w %L \r%L", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "SAVE_YES" : "SAVE_NO")
	
	// 0. Exit
	iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r0.\r %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)
	{
		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)
					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)
{
	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])
	give_balrog(id)
	
	// Primary bought
	g_bBoughtPrimary[id] = 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)
{
	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
}

// 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
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#2

Post by Mark » 5 years ago

sPe3doN wrote: 5 years ago i try to add balrog to vip when he chose weapon from menu he get balrog with it but don't work i add native
balrog >

Code: Select all

/*================================================================================
 
            --------------------------------
            [ZE] Extra Item: Balrog Ethereal
            --------------------------------
 
        Balrog Ethereal
        Copyright (C) 2017 by Crazy + ZE DEV TEAM
 
        -------------------
        -*- Description -*-
        -------------------
 
        This plugin add a new weapon into your zombie plague mod with
        the name of Balrog Ethereal. That weapon launch a powerfull beams!
        When the laser hit any object, a explosion effect with red color appers.
 
        ----------------
        -*- Commands -*-
        ----------------
 
        * zp_give_balrog_ethereal <target> - Give the item to target.
 
        -------------
        -*- Cvars -*-
        -------------
 
        * ze_balrog_ethereal_ammo <number> - Ammo amout.
        * ze_balrog_ethereal_clip <number> - Clip amout. (Max: 100)
        * ze_balrog_ethereal_one_round <0/1> - Only one round.
        * ze_balrog_ethereal_damage <number> - Damage multiplier.
        * ze_balrog_ethereal_unlimited <0/1> - Unlimited ammunition.
 
        ------------------
        -*- Change Log -*-
        ------------------
 
        * v1.5: (Mar 2017)
            - Updated all the code, added explosion effect, added new cvars;
 
        * v1.6: (Mar 2017)
            - Added custom weapon hud;
 
        ---------------
        -*- Credits -*-
        ---------------
 
        * MeRcyLeZZ: for the nice zombie plague mod.
        * Crazy: created the extra item code.
        * deanamx: for the nice weapon model.
        * And all zombie-mod players that use this weapon.
        * ZE DEV TEAM : For converting this Item
 
 
=================================================================================*/
#include <zombie_escape>
#include <cstrike>
#include <engine>

/*================================================================================
 [Plugin Customization]
=================================================================================*/
 
// Item Name
#define ITEM_NAME "Balrog Ethereal"
 
 
/*================================================================================
 Customization ends here! Yes, that's it. Editing anything beyond
 here is not officially supported. Proceed at your own risk...
=================================================================================*/
 
new const PLUGIN_VERSION[] = "v1.6";
 
new const V_BALROG_MDL[64] = "models/zombie_escape/v_balrog_ethereal.mdl";
new const P_BALROG_MDL[64] = "models/zombie_escape/p_balrog_ethereal.mdl";
new const W_BALROG_MDL[64] = "models/zombie_escape/w_balrog_ethereal.mdl";
 
new const BALROG_SOUNDS[][] = { "weapons/ethereal_shoot.wav", "weapons/ethereal_reload.wav", "weapons/ethereal_idle1.wav", "weapons/ethereal_draw.wav" };
 
new g_has_balrog[33], g_laser_sprite, g_balrog_exp, g_balrog, g_event_balrog, g_playername[33][32], g_maxplayers, g_primary_attack, g_balrog_reload_clip[33], cvar_balrog_clip, cvar_balrog_ammo, cvar_balrog_damage, cvar_balrog_oneround, cvar_balrog_unlimited;
 
const BALROG_KEY = 0982478;
 
const m_iClip = 51;
const m_flNextAttack = 83;
const m_fInReload = 54;
 
const OFFSET_WEAPON_OWNER = 41;
const OFFSET_LINUX_WEAPONS = 4;
const OFFSET_LINUX = 5;
const OFFSET_ACTIVE_ITEM = 373;
 
const WEAPON_BITSUM = ((1<<CSW_SCOUT) | (1<<CSW_XM1014) | (1<<CSW_MAC10) | (1<<CSW_AUG) | (1<<CSW_UMP45) | (1<<CSW_SG550) | (1<<CSW_P90) | (1<<CSW_FAMAS) | (1<<CSW_AWP) | (1<<CSW_MP5NAVY) | (1<<CSW_M249) | (1<<CSW_M3) | (1<<CSW_M4A1) | (1<<CSW_TMP) | (1<<CSW_G3SG1) | (1<<CSW_SG552) | (1<<CSW_AK47) | (1<<CSW_GALIL));
 
enum
{
    idle = 0,
    reload,
    draw,
    shoot1,
    shoot2,
    shoot3
}
 
public plugin_init()
{
    /* Plugin register */
    register_plugin("[ZE] Extra Item: Balrog Ethereal", PLUGIN_VERSION, "Crazy");
 
    /* Item register */
    g_balrog = ze_register_item("Balrog Ethereal", 10, 0);
 
    /* Events */
    register_event("HLTV", "event_round_start", "a", "1=0", "2=0");
 
    /* Messages */
    register_message(get_user_msgid("CurWeapon"), "message_cur_weapon");
 
    /* Forwards */
    register_forward(FM_UpdateClientData, "fw_UpdateData_Post", 1);
    register_forward(FM_SetModel, "fw_SetModel");
    register_forward(FM_PlaybackEvent, "fw_PlaybackEvent");
 
    /* Ham Forwards */
    RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_Item_Deploy, "weapon_ump45", "fw_Item_Deploy_Post", 1);
    RegisterHam(Ham_Item_AddToPlayer, "weapon_ump45", "fw_Item_AddToPlayer_Post", 1);
    RegisterHam(Ham_Item_PostFrame, "weapon_ump45", "fw_Item_PostFrame");
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_PrimaryAttack");
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_PrimaryAttack_Post", 1);
    RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Reload");
    RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Reload_Post", 1);
    RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage");
 
    /* Cvars */
    cvar_balrog_clip = register_cvar("ze_balrog_minigun_clip", "50");
    cvar_balrog_ammo = register_cvar("ze_balrog_minigun_ammo", "200");
    cvar_balrog_damage = register_cvar("ze_balrog_minigun_damage", "3.0");
    cvar_balrog_oneround = register_cvar("ze_balrog_minigun_one_round", "0");
    cvar_balrog_unlimited = register_cvar("ze_balrog_minigun_unlimited", "0");
 
    /* Max Players */
    g_maxplayers = get_maxplayers()
}
 
public plugin_precache()
{
    engfunc(EngFunc_PrecacheModel, V_BALROG_MDL);
    engfunc(EngFunc_PrecacheModel, P_BALROG_MDL);
    engfunc(EngFunc_PrecacheModel, W_BALROG_MDL);
 
    engfunc(EngFunc_PrecacheGeneric, "sprites/weapon_bethereal.txt");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud2_bethereal.spr");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud10_bethereal.spr");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud74_bethereal.spr");
 
    for (new i = 0; i < sizeof BALROG_SOUNDS; i++)
    engfunc(EngFunc_PrecacheSound, BALROG_SOUNDS[i]);
 
    g_laser_sprite = precache_model("sprites/laserbeam.spr");
    g_balrog_exp = precache_model("sprites/zombie_plague/balrog_ethereal_exp.spr");
 
    register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1);
    register_clcmd("weapon_bethereal", "cmd_balrog_selected");
}
 
public ze_user_infected(id)
{
    g_has_balrog[id] = false;
}
 
public ze_user_humanized(id)
{
    g_has_balrog[id] = false;
}
 
public client_putinserver(id)
{
    g_has_balrog[id] = false;
 
    get_user_name(id, g_playername[id], charsmax(g_playername[]));
}
 
public event_round_start()
{
    for (new id = 0; id <= g_maxplayers; id++)
    {
        if (get_pcvar_num(cvar_balrog_oneround))
        g_has_balrog[id] = false;
    }
}
 
public cmd_balrog_selected(client)
{
    engclient_cmd(client, "weapon_ump45");
    return PLUGIN_HANDLED;
}
 
public message_cur_weapon(msg_id, msg_dest, msg_entity)
{
    if (!is_user_alive(msg_entity))
        return;
 
    if (!g_has_balrog[msg_entity])
        return;
 
    if (get_user_weapon(msg_entity) != CSW_UMP45)
        return;
 
    if (get_msg_arg_int(1) != 1)
        return;
 
    if (get_pcvar_num(cvar_balrog_unlimited))
    {
        static ent;
        ent = fm_cs_get_current_weapon_ent(msg_entity);
 
        if (!pev_valid(ent))
            return;
 
        cs_set_weapon_ammo(ent, get_pcvar_num(cvar_balrog_clip));
        set_msg_arg_int(3, get_msg_argtype(3), get_pcvar_num(cvar_balrog_clip));
    }
}
 
public ze_select_item_pre(id, itemid)
{
    // This not our item?
    if (itemid != g_balrog)
        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
   
    // Finally return that it's available
    return ZE_ITEM_AVAILABLE
}
 
public ze_select_item_post(id, itemid)
{
    if (itemid != g_balrog)
        return;
 
    if (g_has_balrog[id])
    {
        client_print(id, print_chat, "[ZE] You already have the %s.", ITEM_NAME);
        return;
    }
 
    give_balrog(id);
 
    client_print(id, print_chat, "[ZE] You bought the %s.", ITEM_NAME);
}
 
public fw_UpdateData_Post(id, sendweapons, cd_handle)
{
    if (!is_user_alive(id))
        return FMRES_IGNORED;
 
    if (!g_has_balrog[id])
        return FMRES_IGNORED;
 
    if (get_user_weapon(id) != CSW_UMP45)
        return FMRES_IGNORED;
 
    set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001);
 
    return FMRES_IGNORED;
}
 
public fw_SetModel(ent, const model[])
{
    if (!pev_valid(ent))
        return FMRES_IGNORED;
 
    if (!equal(model, "models/w_ump45.mdl"))
        return HAM_IGNORED;
 
    static class_name[33];
    pev(ent, pev_classname, class_name, charsmax(class_name));
 
    if (!equal(class_name, "weaponbox"))
        return FMRES_IGNORED;
 
    static owner, weapon;
    owner = pev(ent, pev_owner);
    weapon = find_ent_by_owner(-1, "weapon_ump45", ent);
 
    if (!g_has_balrog[owner] || !pev_valid(weapon))
        return FMRES_IGNORED;
 
    g_has_balrog[owner] = false;
 
    set_pev(weapon, pev_impulse, BALROG_KEY);
 
    engfunc(EngFunc_SetModel, ent, W_BALROG_MDL);
 
    return FMRES_SUPERCEDE;
}
 
public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
    if ((eventid != g_event_balrog) || !g_primary_attack)
        return FMRES_IGNORED;
 
    if (!(1 <= invoker <= g_maxplayers))
        return FMRES_IGNORED;
 
    playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2);
 
    return FMRES_SUPERCEDE;
}
 
public fw_PrecacheEvent_Post(type, const name[])
{
    if (!equal("events/ump45.sc", name))
        return HAM_IGNORED;
 
    g_event_balrog = get_orig_retval()
 
    return FMRES_HANDLED;
}
 
public fw_Item_Deploy_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    set_pev(id, pev_viewmodel2, V_BALROG_MDL);
    set_pev(id, pev_weaponmodel2, P_BALROG_MDL);
 
    play_weapon_anim(id, draw);
 
    return HAM_IGNORED;
}
 
public fw_Item_AddToPlayer_Post(ent, id)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (pev(ent, pev_impulse) == BALROG_KEY)
    {
        g_has_balrog[id] = true;
        set_pev(ent, pev_impulse, 0);
    }
 
    message_begin(MSG_ONE, get_user_msgid("WeaponList"), _, id)
    write_string((g_has_balrog[id] ? "weapon_bethereal" : "weapon_ump45"))
    write_byte(6)
    write_byte(100)
    write_byte(-1)
    write_byte(-1)
    write_byte(0)
    write_byte(15)
    write_byte(CSW_UMP45)
    write_byte(0)
    message_end()
 
    return HAM_IGNORED;
}
 
public fw_Item_PostFrame(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    static cvar_clip; cvar_clip = get_pcvar_num(cvar_balrog_clip);
 
    new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
    new bpammo = cs_get_user_bpammo(id, CSW_UMP45);
 
    new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, OFFSET_LINUX);
    new fInReload = get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS);
 
    if (fInReload && flNextAttack <= 0.0)
    {
        new temp_clip = min(cvar_clip - clip, bpammo);
 
        set_pdata_int(ent, m_iClip, clip + temp_clip, OFFSET_LINUX_WEAPONS);
 
        cs_set_user_bpammo(id, CSW_UMP45, bpammo-temp_clip);
 
        set_pdata_int(ent, m_fInReload, 0, OFFSET_LINUX_WEAPONS);
 
        fInReload = 0;
    }
 
    return HAM_IGNORED;
}
 
public fw_PrimaryAttack(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (!cs_get_weapon_ammo(ent))
        return HAM_IGNORED;
 
    g_primary_attack = true;
 
    return HAM_IGNORED;
}
 
public fw_PrimaryAttack_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (!cs_get_weapon_ammo(ent))
        return HAM_IGNORED;
 
    g_primary_attack = false;
 
    play_weapon_anim(id, random_num(shoot1, shoot3));
 
    emit_sound(id, CHAN_WEAPON, BALROG_SOUNDS[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
 
    make_laser_beam(id, 7, 100, 0, 0);
 
    return HAM_IGNORED;
}
 
public fw_Reload(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    static cvar_clip;
 
    if (g_has_balrog[id])
        cvar_clip = get_pcvar_num(cvar_balrog_clip);
 
    g_balrog_reload_clip[id] = -1;
 
    new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
    new bpammo = cs_get_user_bpammo(id, CSW_UMP45);
 
    if (bpammo <= 0)
        return HAM_SUPERCEDE;
 
    if (clip >= cvar_clip)
        return HAM_SUPERCEDE;
   
    g_balrog_reload_clip[id] = clip;
 
    return HAM_IGNORED;
}
 
public fw_Reload_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (g_balrog_reload_clip[id] == -1)
        return HAM_IGNORED;
 
    set_pdata_int(ent, m_iClip, g_balrog_reload_clip[id], OFFSET_LINUX_WEAPONS);
    set_pdata_int(ent, m_fInReload, 1, OFFSET_LINUX_WEAPONS);
 
    play_weapon_anim(id, reload);
 
    return HAM_IGNORED;
}
 
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, dmg_bits)
{
    if (!is_user_alive(attacker))
        return HAM_IGNORED;
 
    if (!g_has_balrog[attacker])
        return HAM_IGNORED;
 
    if (get_user_weapon(attacker) != CSW_UMP45)
        return HAM_IGNORED;
 
    SetHamParamFloat(OFFSET_LINUX_WEAPONS, damage * get_pcvar_float(cvar_balrog_damage));
 
    make_explosion_effect(attacker);
 
    return HAM_IGNORED;
}
 
public fw_TraceAttack_Post(ent, attacker, Float:damage, Float:dir[3], ptr, dmg_bits)
{
    if (!is_user_alive(attacker))
        return HAM_IGNORED;
 
    if (get_user_weapon(attacker) != CSW_UMP45)
        return HAM_IGNORED;
 
    if (!g_has_balrog[attacker])
        return HAM_IGNORED;
 
    make_explosion_effect(attacker);
 
    return HAM_IGNORED;
}
 
give_balrog(id)
{
    drop_primary(id);
 
    g_has_balrog[id] = true;
 
    new weapon = fm_give_item(id, "weapon_ump45");
 
    cs_set_weapon_ammo(weapon, get_pcvar_num(cvar_balrog_clip));
    cs_set_user_bpammo(id, CSW_UMP45, get_pcvar_num(cvar_balrog_ammo));
}
 
play_weapon_anim(id, frame)
{
    set_pev(id, pev_weaponanim, frame);
 
    message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = id)
    write_byte(frame)
    write_byte(pev(id, pev_body))
    message_end()
}
 
make_laser_beam(id, Size, R, G, B)
{
    static End[3];
    get_user_origin(id, End, 3);
   
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte (TE_BEAMENTPOINT)
    write_short( id |0x1000 )
    write_coord(End[0])
    write_coord(End[1])
    write_coord(End[2])
    write_short(g_laser_sprite)
    write_byte(0)
    write_byte(1)
    write_byte(1)
    write_byte(Size)
    write_byte(4)
    write_byte(R)
    write_byte(G)
    write_byte(B)
    write_byte(255)
    write_byte(0)
    message_end()
}
 
make_explosion_effect(id)
{
    static end[3];
    get_user_origin(id, end, 3);
 
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte(3)
    write_coord(end[0])
    write_coord(end[1])
    write_coord(end[2])
    write_short(g_balrog_exp)
    write_byte(10)
    write_byte(15)
    write_byte(4)
    message_end()
}
 
drop_primary(id)
{
    static weapons[32], num;
    get_user_weapons(id, weapons, num);
 
    for (new i = 0; i < num; i++)
    {
        if (WEAPON_BITSUM & (1<<weapons[i]))
        {
            static wname[32];
            get_weaponname(weapons[i], wname, sizeof wname - 1);
 
            engclient_cmd(id, "drop", wname);
        }
    }
}
 
stock fm_give_item(index, const item[])
{
    if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
        return 0;
 
    new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item));
    if (!pev_valid(ent))
        return 0;
 
    new Float:origin[3];
    pev(index, pev_origin, origin);
    set_pev(ent, pev_origin, origin);
    set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
    dllfunc(DLLFunc_Spawn, ent);
 
    new save = pev(ent, pev_solid);
    dllfunc(DLLFunc_Touch, ent, index);
    if (pev(ent, pev_solid) != save)
        return ent;
 
    engfunc(EngFunc_RemoveEntity, ent);
 
    return -1;
}
 
stock fm_cs_get_current_weapon_ent(id)
{
    if (pev_valid(id) != 2)
        return -1;
   
    return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX);
}

public plugin_natives()
{
	register_native("give_balrog", "native_give_balrog", 1)
}

public native_give_balrog(id)
{
	if ((get_user_flags(id) & ADMIN_LEVEL_H))
	{
		g_has_balrog[id] = true
		
		rg_give_item(id, "weapon_ump45", GT_APPEND)
	}

}
Weapon menu >

Code: Select all

#include <zombie_escape>

native give_balrog(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_m4a1",
	"weapon_ak47",
	"weapon_aug",
	"weapon_galil",
	"weapon_famas",
	"weapon_mp5navy",
	"weapon_p90"
}

// Secondary Weapons Entities [Default Values]
new const szSecondaryWeaponEnt[][]=
{
	"weapon_usp",
	"weapon_deagle",
	"weapon_p228",
	"weapon_elite",
}

// Primary and Secondary Weapons Names [Default Values]
new const szWeaponNames[][] = 
{ 
	"", 
	"P228", 
	"",
	"Scout",
	"HE Grenade",
	"XM1014",
	"",
	"MAC-10",
	"AUG",
	"Smoke Grenade", 
	"elite",
	"Five Seven",
	"UMP 45",
	"SG-550",
	"Galil",
	"Famas",
	"Usp",
	"Glock",
	"AWP",
	"MP5",
	"M249",
	"M3",
	"M4A1",
	"TMP",
	"G3SG1",
	"Flashbang",
	"Deagle",
	"SG-552",
	"AK-47",
	"",
	"P90"
}

// Max Back Clip Ammo (Change it From here if you need)
new const szMaxBPAmmo[] =
{
	-1,
	200,
	-1,
	200,
	1,
	200,
	1,
	200,
	200,
	1,
	200,
	200,
	200,
	200,
	200,
	200,
	200,
	200,
	200,
	200,
	200,
	200,
	200,
	200,
	200,
	2,
	200,
	200,
        200,
	-1,
	200
}

// Menu selections
const MENU_KEY_AUTOSELECT = 7
const MENU_KEY_BACK = 7
const MENU_KEY_NEXT = 8
const MENU_KEY_EXIT = 9

// Variables
new Array:g_szPrimaryWeapons,
	Array:g_szSecondaryWeapons

new g_iMenuData[33][4], 
	Float:g_fBuyTimeStart[33], 
	bool:g_bBoughtPrimary[33], 
	bool:g_bBoughtSecondary[33]

// Define
#define WPN_STARTID g_iMenuData[id][0]
#define WPN_MAXIDS ArraySize(g_szPrimaryWeapons)
#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
	
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] Weapons Menu", ZE_VERSION, AUTHORS)
	
	// 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", "600")
	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")
	
	// Menus
	register_menu("Primary Weapons", KEYSMENU, "Menu_Buy_Primary")
	register_menu("Secondary Weapons", KEYSMENU, "Menu_Buy_Secondary")
}

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)
{
	// 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")
		
	if (WPN_AUTO_ON)
	{
		Buy_Primary_Weapon(id, WPN_AUTO_PRI)
	}

	if (WPN_AUTO_ON)
	{
		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)
	
	// Title
	iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L ^n^n", id, "MENU_PRIMARY_TITLE", WPN_STARTID+1, min(WPN_STARTID+7, WPN_MAXIDS))
	
	// 1-7. Weapon List
	for (iIndex = WPN_STARTID; iIndex < iMaxLoops; iIndex++)
	{
		ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r%d.\w %s^n", iIndex-WPN_STARTID+1, szWeaponNames[get_weaponid(szWeaponName)])
	}

	// 8. Auto Select
	iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r8.\w %L \r%L", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "SAVE_YES" : "SAVE_NO")
	
	// 0. Exit
	iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r0.\r %L", 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++)
	{
		ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r%d.\w %s", iIndex+1, szWeaponNames[get_weaponid(szWeaponName)])
	}
	
	// 8. Auto Select
	iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r8.\w %L \r%L", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "SAVE_YES" : "SAVE_NO")
	
	// 0. Exit
	iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r0.\r %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)
	{
		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)
					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)
{
	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])
	give_balrog(id)
	
	// Primary bought
	g_bBoughtPrimary[id] = 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)
{
	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
}

// 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
}
  1. #include <zombie_escape>
  2. #include <cstrike>
  3. #include <engine>
-->>

  1. #include <zombie_escape>
  2. #include <engine>
  3. #include <cstrike>

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

#3

Post by Raheem » 5 years ago

Explain what didn't work? Is it compiling? The problem in game?

More information will help.
He who fails to plan is planning to fail

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

#4

Post by Night Fury » 5 years ago

Code: Select all

public Buy_Primary_Weapon(id, selection)
{
	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])
	give_balrog(id)
	
	// Primary bought
	g_bBoughtPrimary[id] = true
}
-->

Code: Select all

public Buy_Primary_Weapon(id, selection)
{
	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])
	if (get_user_flags(id) & ADMIN_LEVEL_H)
	{
		give_balrog(id)
	}
	
	// Primary bought
	g_bBoughtPrimary[id] = true
}
Change VIP access from this line:

Code: Select all

	if (get_user_flags(id) & ADMIN_LEVEL_H)
Mark wrote:5 years ago
Arranging includes is not required.
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

Jack GamePlay wrote: 5 years ago Arranging includes is not required.
In some cases it's required, maybe poor compiler?
He who fails to plan is planning to fail

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

#6

Post by Mark » 5 years ago

Jack GamePlay wrote: 5 years ago

Code: Select all

public Buy_Primary_Weapon(id, selection)
{
	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])
	give_balrog(id)
	
	// Primary bought
	g_bBoughtPrimary[id] = true
}
-->

Code: Select all

public Buy_Primary_Weapon(id, selection)
{
	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])
	if (get_user_flags(id) & ADMIN_LEVEL_H)
	{
		give_balrog(id)
	}
	
	// Primary bought
	g_bBoughtPrimary[id] = true
}
Change VIP access from this line:

Code: Select all

	if (get_user_flags(id) & ADMIN_LEVEL_H)
Mark wrote:5 years ago
Arranging includes is not required.
i always put engine before cstrike :D

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

#7

Post by Raheem » 5 years ago

Mark wrote: 5 years ago i always put engine before cstrike :D
Another good idea is to drop engine and cstrike and use instead reapi, better, faster and powerful.
He who fails to plan is planning to fail

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 258
Joined: 7 years ago
Contact:

#8

Post by sPe3doN » 5 years ago

Raheem wrote: 5 years ago Explain what didn't work? Is it compiling? The problem in game?

More information will help.
its compiling fine but don't give vip balrog weapon
Jack GamePlay wrote: 5 years ago

Code: Select all

public Buy_Primary_Weapon(id, selection)
{
	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])
	give_balrog(id)
	
	// Primary bought
	g_bBoughtPrimary[id] = true
}
-->

Code: Select all

public Buy_Primary_Weapon(id, selection)
{
	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])
	if (get_user_flags(id) & ADMIN_LEVEL_H)
	{
		give_balrog(id)
	}
	
	// Primary bought
	g_bBoughtPrimary[id] = true}
Change VIP access from this line:

Code: Select all

	if (get_user_flags(id) & ADMIN_LEVEL_H)
Mark wrote:5 years ago
Arranging includes is not required.
Not working
Image

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

#9

Post by Raheem » 5 years ago

It gives any errors in console?
He who fails to plan is planning to fail

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 258
Joined: 7 years ago
Contact:

#10

Post by sPe3doN » 5 years ago

Raheem wrote: 5 years ago It gives any errors in console?

Code: Select all

 09/20/2018 - 17:10:55: Info (map "ze_jurassicpark4") (file "addons/amxmodx/logs/error_20180920.log")
L 09/20/2018 - 17:10:55: Function "native_give_balrog" was not found
L 09/20/2018 - 17:10:55: [AMXX] Run time error 19 (plugin "balrog_ethreal.amxx") - debug not enabled!
L 09/20/2018 - 17:10:55: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).
L 09/20/2018 - 17:10:55: [AMXX] Run time error -1 (plugin "balrog_ethreal.amxx") - debug not enabled!
Image

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

#11

Post by Raheem » 5 years ago

Barlog:
    1. /*================================================================================
    2.  
    3.             --------------------------------
    4.             [ZE] Extra Item: Balrog Ethereal
    5.             --------------------------------
    6.  
    7.         Balrog Ethereal
    8.         Copyright (C) 2017 by Crazy + ZE DEV TEAM
    9.  
    10.         -------------------
    11.         -*- Description -*-
    12.         -------------------
    13.  
    14.         This plugin add a new weapon into your zombie plague mod with
    15.         the name of Balrog Ethereal. That weapon launch a powerfull beams!
    16.         When the laser hit any object, a explosion effect with red color appers.
    17.  
    18.         ----------------
    19.         -*- Commands -*-
    20.         ----------------
    21.  
    22.         * zp_give_balrog_ethereal <target> - Give the item to target.
    23.  
    24.         -------------
    25.         -*- Cvars -*-
    26.         -------------
    27.  
    28.         * ze_balrog_ethereal_ammo <number> - Ammo amout.
    29.         * ze_balrog_ethereal_clip <number> - Clip amout. (Max: 100)
    30.         * ze_balrog_ethereal_one_round <0/1> - Only one round.
    31.         * ze_balrog_ethereal_damage <number> - Damage multiplier.
    32.         * ze_balrog_ethereal_unlimited <0/1> - Unlimited ammunition.
    33.  
    34.         ------------------
    35.         -*- Change Log -*-
    36.         ------------------
    37.  
    38.         * v1.5: (Mar 2017)
    39.             - Updated all the code, added explosion effect, added new cvars;
    40.  
    41.         * v1.6: (Mar 2017)
    42.             - Added custom weapon hud;
    43.  
    44.         ---------------
    45.         -*- Credits -*-
    46.         ---------------
    47.  
    48.         * MeRcyLeZZ: for the nice zombie plague mod.
    49.         * Crazy: created the extra item code.
    50.         * deanamx: for the nice weapon model.
    51.         * And all zombie-mod players that use this weapon.
    52.         * ZE DEV TEAM : For converting this Item
    53.  
    54.  
    55. =================================================================================*/
    56. #include <zombie_escape>
    57. #include <cstrike>
    58. #include <engine>
    59.  
    60. /*================================================================================
    61.  [Plugin Customization]
    62. =================================================================================*/
    63.  
    64. // Item Name
    65. #define ITEM_NAME "Balrog Ethereal"
    66.  
    67.  
    68. /*================================================================================
    69.  Customization ends here! Yes, that's it. Editing anything beyond
    70.  here is not officially supported. Proceed at your own risk...
    71. =================================================================================*/
    72.  
    73. new const PLUGIN_VERSION[] = "v1.6";
    74.  
    75. new const V_BALROG_MDL[64] = "models/zombie_escape/v_balrog_ethereal.mdl";
    76. new const P_BALROG_MDL[64] = "models/zombie_escape/p_balrog_ethereal.mdl";
    77. new const W_BALROG_MDL[64] = "models/zombie_escape/w_balrog_ethereal.mdl";
    78.  
    79. new const BALROG_SOUNDS[][] = { "weapons/ethereal_shoot.wav", "weapons/ethereal_reload.wav", "weapons/ethereal_idle1.wav", "weapons/ethereal_draw.wav" };
    80.  
    81. new g_has_balrog[33], g_laser_sprite, g_balrog_exp, g_balrog, g_event_balrog, g_playername[33][32], g_maxplayers, g_primary_attack, g_balrog_reload_clip[33], cvar_balrog_clip, cvar_balrog_ammo, cvar_balrog_damage, cvar_balrog_oneround, cvar_balrog_unlimited;
    82.  
    83. const BALROG_KEY = 0982478;
    84.  
    85. const m_iClip = 51;
    86. const m_flNextAttack = 83;
    87. const m_fInReload = 54;
    88.  
    89. const OFFSET_WEAPON_OWNER = 41;
    90. const OFFSET_LINUX_WEAPONS = 4;
    91. const OFFSET_LINUX = 5;
    92. const OFFSET_ACTIVE_ITEM = 373;
    93.  
    94. const WEAPON_BITSUM = ((1<<CSW_SCOUT) | (1<<CSW_XM1014) | (1<<CSW_MAC10) | (1<<CSW_AUG) | (1<<CSW_UMP45) | (1<<CSW_SG550) | (1<<CSW_P90) | (1<<CSW_FAMAS) | (1<<CSW_AWP) | (1<<CSW_MP5NAVY) | (1<<CSW_M249) | (1<<CSW_M3) | (1<<CSW_M4A1) | (1<<CSW_TMP) | (1<<CSW_G3SG1) | (1<<CSW_SG552) | (1<<CSW_AK47) | (1<<CSW_GALIL));
    95.  
    96. enum
    97. {
    98.     idle = 0,
    99.     reload,
    100.     draw,
    101.     shoot1,
    102.     shoot2,
    103.     shoot3
    104. }
    105.  
    106. public plugin_natives()
    107. {
    108.     register_native("ze_give_balrog", "native_give_balrog", 1)
    109. }
    110.  
    111. public plugin_init()
    112. {
    113.     /* Plugin register */
    114.     register_plugin("[ZE] Extra Item: Balrog Ethereal", PLUGIN_VERSION, "Crazy");
    115.  
    116.     /* Item register */
    117.     g_balrog = ze_register_item("Balrog Ethereal", 10, 0);
    118.  
    119.     /* Events */
    120.     register_event("HLTV", "event_round_start", "a", "1=0", "2=0");
    121.  
    122.     /* Messages */
    123.     register_message(get_user_msgid("CurWeapon"), "message_cur_weapon");
    124.  
    125.     /* Forwards */
    126.     register_forward(FM_UpdateClientData, "fw_UpdateData_Post", 1);
    127.     register_forward(FM_SetModel, "fw_SetModel");
    128.     register_forward(FM_PlaybackEvent, "fw_PlaybackEvent");
    129.  
    130.     /* Ham Forwards */
    131.     RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack_Post", 1);
    132.     RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack_Post", 1);
    133.     RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack_Post", 1);
    134.     RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack_Post", 1);
    135.     RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack_Post", 1);
    136.     RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack_Post", 1);
    137.     RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack_Post", 1);
    138.     RegisterHam(Ham_Item_Deploy, "weapon_ump45", "fw_Item_Deploy_Post", 1);
    139.     RegisterHam(Ham_Item_AddToPlayer, "weapon_ump45", "fw_Item_AddToPlayer_Post", 1);
    140.     RegisterHam(Ham_Item_PostFrame, "weapon_ump45", "fw_Item_PostFrame");
    141.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_PrimaryAttack");
    142.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_PrimaryAttack_Post", 1);
    143.     RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Reload");
    144.     RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Reload_Post", 1);
    145.     RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage");
    146.  
    147.     /* Cvars */
    148.     cvar_balrog_clip = register_cvar("ze_balrog_minigun_clip", "50");
    149.     cvar_balrog_ammo = register_cvar("ze_balrog_minigun_ammo", "200");
    150.     cvar_balrog_damage = register_cvar("ze_balrog_minigun_damage", "3.0");
    151.     cvar_balrog_oneround = register_cvar("ze_balrog_minigun_one_round", "0");
    152.     cvar_balrog_unlimited = register_cvar("ze_balrog_minigun_unlimited", "0");
    153.  
    154.     /* Max Players */
    155.     g_maxplayers = get_maxplayers()
    156. }
    157.  
    158. public plugin_precache()
    159. {
    160.     engfunc(EngFunc_PrecacheModel, V_BALROG_MDL);
    161.     engfunc(EngFunc_PrecacheModel, P_BALROG_MDL);
    162.     engfunc(EngFunc_PrecacheModel, W_BALROG_MDL);
    163.  
    164.     engfunc(EngFunc_PrecacheGeneric, "sprites/weapon_bethereal.txt");
    165.     engfunc(EngFunc_PrecacheGeneric, "sprites/640hud2_bethereal.spr");
    166.     engfunc(EngFunc_PrecacheGeneric, "sprites/640hud10_bethereal.spr");
    167.     engfunc(EngFunc_PrecacheGeneric, "sprites/640hud74_bethereal.spr");
    168.  
    169.     for (new i = 0; i < sizeof BALROG_SOUNDS; i++)
    170.     engfunc(EngFunc_PrecacheSound, BALROG_SOUNDS[i]);
    171.  
    172.     g_laser_sprite = precache_model("sprites/laserbeam.spr");
    173.     g_balrog_exp = precache_model("sprites/zombie_plague/balrog_ethereal_exp.spr");
    174.  
    175.     register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1);
    176.     register_clcmd("weapon_bethereal", "cmd_balrog_selected");
    177. }
    178.  
    179. public ze_user_infected(id)
    180. {
    181.     g_has_balrog[id] = false;
    182. }
    183.  
    184. public ze_user_humanized(id)
    185. {
    186.     g_has_balrog[id] = false;
    187. }
    188.  
    189. public client_putinserver(id)
    190. {
    191.     g_has_balrog[id] = false;
    192.  
    193.     get_user_name(id, g_playername[id], charsmax(g_playername[]));
    194. }
    195.  
    196. public event_round_start()
    197. {
    198.     for (new id = 0; id <= g_maxplayers; id++)
    199.     {
    200.         if (get_pcvar_num(cvar_balrog_oneround))
    201.         g_has_balrog[id] = false;
    202.     }
    203. }
    204.  
    205. public cmd_balrog_selected(client)
    206. {
    207.     engclient_cmd(client, "weapon_ump45");
    208.     return PLUGIN_HANDLED;
    209. }
    210.  
    211. public message_cur_weapon(msg_id, msg_dest, msg_entity)
    212. {
    213.     if (!is_user_alive(msg_entity))
    214.         return;
    215.  
    216.     if (!g_has_balrog[msg_entity])
    217.         return;
    218.  
    219.     if (get_user_weapon(msg_entity) != CSW_UMP45)
    220.         return;
    221.  
    222.     if (get_msg_arg_int(1) != 1)
    223.         return;
    224.  
    225.     if (get_pcvar_num(cvar_balrog_unlimited))
    226.     {
    227.         static ent;
    228.         ent = fm_cs_get_current_weapon_ent(msg_entity);
    229.  
    230.         if (!pev_valid(ent))
    231.             return;
    232.  
    233.         cs_set_weapon_ammo(ent, get_pcvar_num(cvar_balrog_clip));
    234.         set_msg_arg_int(3, get_msg_argtype(3), get_pcvar_num(cvar_balrog_clip));
    235.     }
    236. }
    237.  
    238. public ze_select_item_pre(id, itemid)
    239. {
    240.     // This not our item?
    241.     if (itemid != g_balrog)
    242.         return ZE_ITEM_AVAILABLE
    243.    
    244.     // Available for Humans only, So don't show it for zombies
    245.     if (ze_is_user_zombie(id))
    246.         return ZE_ITEM_DONT_SHOW
    247.    
    248.     // Finally return that it's available
    249.     return ZE_ITEM_AVAILABLE
    250. }
    251.  
    252. public ze_select_item_post(id, itemid)
    253. {
    254.     if (itemid != g_balrog)
    255.         return;
    256.  
    257.     if (g_has_balrog[id])
    258.     {
    259.         client_print(id, print_chat, "[ZE] You already have the %s.", ITEM_NAME);
    260.         return;
    261.     }
    262.  
    263.     give_balrog(id);
    264.  
    265.     client_print(id, print_chat, "[ZE] You bought the %s.", ITEM_NAME);
    266. }
    267.  
    268. public fw_UpdateData_Post(id, sendweapons, cd_handle)
    269. {
    270.     if (!is_user_alive(id))
    271.         return FMRES_IGNORED;
    272.  
    273.     if (!g_has_balrog[id])
    274.         return FMRES_IGNORED;
    275.  
    276.     if (get_user_weapon(id) != CSW_UMP45)
    277.         return FMRES_IGNORED;
    278.  
    279.     set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001);
    280.  
    281.     return FMRES_IGNORED;
    282. }
    283.  
    284. public fw_SetModel(ent, const model[])
    285. {
    286.     if (!pev_valid(ent))
    287.         return FMRES_IGNORED;
    288.  
    289.     if (!equal(model, "models/w_ump45.mdl"))
    290.         return HAM_IGNORED;
    291.  
    292.     static class_name[33];
    293.     pev(ent, pev_classname, class_name, charsmax(class_name));
    294.  
    295.     if (!equal(class_name, "weaponbox"))
    296.         return FMRES_IGNORED;
    297.  
    298.     static owner, weapon;
    299.     owner = pev(ent, pev_owner);
    300.     weapon = find_ent_by_owner(-1, "weapon_ump45", ent);
    301.  
    302.     if (!g_has_balrog[owner] || !pev_valid(weapon))
    303.         return FMRES_IGNORED;
    304.  
    305.     g_has_balrog[owner] = false;
    306.  
    307.     set_pev(weapon, pev_impulse, BALROG_KEY);
    308.  
    309.     engfunc(EngFunc_SetModel, ent, W_BALROG_MDL);
    310.  
    311.     return FMRES_SUPERCEDE;
    312. }
    313.  
    314. public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
    315. {
    316.     if ((eventid != g_event_balrog) || !g_primary_attack)
    317.         return FMRES_IGNORED;
    318.  
    319.     if (!(1 <= invoker <= g_maxplayers))
    320.         return FMRES_IGNORED;
    321.  
    322.     playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2);
    323.  
    324.     return FMRES_SUPERCEDE;
    325. }
    326.  
    327. public fw_PrecacheEvent_Post(type, const name[])
    328. {
    329.     if (!equal("events/ump45.sc", name))
    330.         return HAM_IGNORED;
    331.  
    332.     g_event_balrog = get_orig_retval()
    333.  
    334.     return FMRES_HANDLED;
    335. }
    336.  
    337. public fw_Item_Deploy_Post(ent)
    338. {
    339.     if (!pev_valid(ent))
    340.         return HAM_IGNORED;
    341.  
    342.     new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
    343.  
    344.     if (!is_user_alive(id))
    345.         return HAM_IGNORED;
    346.  
    347.     if (!g_has_balrog[id])
    348.         return HAM_IGNORED;
    349.  
    350.     set_pev(id, pev_viewmodel2, V_BALROG_MDL);
    351.     set_pev(id, pev_weaponmodel2, P_BALROG_MDL);
    352.  
    353.     play_weapon_anim(id, draw);
    354.  
    355.     return HAM_IGNORED;
    356. }
    357.  
    358. public fw_Item_AddToPlayer_Post(ent, id)
    359. {
    360.     if (!pev_valid(ent))
    361.         return HAM_IGNORED;
    362.  
    363.     if (!is_user_alive(id))
    364.         return HAM_IGNORED;
    365.  
    366.     if (pev(ent, pev_impulse) == BALROG_KEY)
    367.     {
    368.         g_has_balrog[id] = true;
    369.         set_pev(ent, pev_impulse, 0);
    370.     }
    371.  
    372.     message_begin(MSG_ONE, get_user_msgid("WeaponList"), _, id)
    373.     write_string((g_has_balrog[id] ? "weapon_bethereal" : "weapon_ump45"))
    374.     write_byte(6)
    375.     write_byte(100)
    376.     write_byte(-1)
    377.     write_byte(-1)
    378.     write_byte(0)
    379.     write_byte(15)
    380.     write_byte(CSW_UMP45)
    381.     write_byte(0)
    382.     message_end()
    383.  
    384.     return HAM_IGNORED;
    385. }
    386.  
    387. public fw_Item_PostFrame(ent)
    388. {
    389.     if (!pev_valid(ent))
    390.         return HAM_IGNORED;
    391.  
    392.     new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
    393.  
    394.     if (!is_user_alive(id))
    395.         return HAM_IGNORED;
    396.  
    397.     if (!g_has_balrog[id])
    398.         return HAM_IGNORED;
    399.  
    400.     static cvar_clip; cvar_clip = get_pcvar_num(cvar_balrog_clip);
    401.  
    402.     new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
    403.     new bpammo = cs_get_user_bpammo(id, CSW_UMP45);
    404.  
    405.     new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, OFFSET_LINUX);
    406.     new fInReload = get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS);
    407.  
    408.     if (fInReload && flNextAttack <= 0.0)
    409.     {
    410.         new temp_clip = min(cvar_clip - clip, bpammo);
    411.  
    412.         set_pdata_int(ent, m_iClip, clip + temp_clip, OFFSET_LINUX_WEAPONS);
    413.  
    414.         cs_set_user_bpammo(id, CSW_UMP45, bpammo-temp_clip);
    415.  
    416.         set_pdata_int(ent, m_fInReload, 0, OFFSET_LINUX_WEAPONS);
    417.  
    418.         fInReload = 0;
    419.     }
    420.  
    421.     return HAM_IGNORED;
    422. }
    423.  
    424. public fw_PrimaryAttack(ent)
    425. {
    426.     if (!pev_valid(ent))
    427.         return HAM_IGNORED;
    428.  
    429.     new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
    430.  
    431.     if (!is_user_alive(id))
    432.         return HAM_IGNORED;
    433.  
    434.     if (!g_has_balrog[id])
    435.         return HAM_IGNORED;
    436.  
    437.     if (!cs_get_weapon_ammo(ent))
    438.         return HAM_IGNORED;
    439.  
    440.     g_primary_attack = true;
    441.  
    442.     return HAM_IGNORED;
    443. }
    444.  
    445. public fw_PrimaryAttack_Post(ent)
    446. {
    447.     if (!pev_valid(ent))
    448.         return HAM_IGNORED;
    449.  
    450.     new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
    451.  
    452.     if (!is_user_alive(id))
    453.         return HAM_IGNORED;
    454.  
    455.     if (!g_has_balrog[id])
    456.         return HAM_IGNORED;
    457.  
    458.     if (!cs_get_weapon_ammo(ent))
    459.         return HAM_IGNORED;
    460.  
    461.     g_primary_attack = false;
    462.  
    463.     play_weapon_anim(id, random_num(shoot1, shoot3));
    464.  
    465.     emit_sound(id, CHAN_WEAPON, BALROG_SOUNDS[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
    466.  
    467.     make_laser_beam(id, 7, 100, 0, 0);
    468.  
    469.     return HAM_IGNORED;
    470. }
    471.  
    472. public fw_Reload(ent)
    473. {
    474.     if (!pev_valid(ent))
    475.         return HAM_IGNORED;
    476.  
    477.     new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
    478.  
    479.     if (!is_user_alive(id))
    480.         return HAM_IGNORED;
    481.  
    482.     if (!g_has_balrog[id])
    483.         return HAM_IGNORED;
    484.  
    485.     static cvar_clip;
    486.  
    487.     if (g_has_balrog[id])
    488.         cvar_clip = get_pcvar_num(cvar_balrog_clip);
    489.  
    490.     g_balrog_reload_clip[id] = -1;
    491.  
    492.     new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
    493.     new bpammo = cs_get_user_bpammo(id, CSW_UMP45);
    494.  
    495.     if (bpammo <= 0)
    496.         return HAM_SUPERCEDE;
    497.  
    498.     if (clip >= cvar_clip)
    499.         return HAM_SUPERCEDE;
    500.    
    501.     g_balrog_reload_clip[id] = clip;
    502.  
    503.     return HAM_IGNORED;
    504. }
    505.  
    506. public fw_Reload_Post(ent)
    507. {
    508.     if (!pev_valid(ent))
    509.         return HAM_IGNORED;
    510.  
    511.     new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
    512.  
    513.     if (!is_user_alive(id))
    514.         return HAM_IGNORED;
    515.  
    516.     if (!g_has_balrog[id])
    517.         return HAM_IGNORED;
    518.  
    519.     if (g_balrog_reload_clip[id] == -1)
    520.         return HAM_IGNORED;
    521.  
    522.     set_pdata_int(ent, m_iClip, g_balrog_reload_clip[id], OFFSET_LINUX_WEAPONS);
    523.     set_pdata_int(ent, m_fInReload, 1, OFFSET_LINUX_WEAPONS);
    524.  
    525.     play_weapon_anim(id, reload);
    526.  
    527.     return HAM_IGNORED;
    528. }
    529.  
    530. public fw_TakeDamage(victim, inflictor, attacker, Float:damage, dmg_bits)
    531. {
    532.     if (!is_user_alive(attacker))
    533.         return HAM_IGNORED;
    534.  
    535.     if (!g_has_balrog[attacker])
    536.         return HAM_IGNORED;
    537.  
    538.     if (get_user_weapon(attacker) != CSW_UMP45)
    539.         return HAM_IGNORED;
    540.  
    541.     SetHamParamFloat(OFFSET_LINUX_WEAPONS, damage * get_pcvar_float(cvar_balrog_damage));
    542.  
    543.     make_explosion_effect(attacker);
    544.  
    545.     return HAM_IGNORED;
    546. }
    547.  
    548. public fw_TraceAttack_Post(ent, attacker, Float:damage, Float:dir[3], ptr, dmg_bits)
    549. {
    550.     if (!is_user_alive(attacker))
    551.         return HAM_IGNORED;
    552.  
    553.     if (get_user_weapon(attacker) != CSW_UMP45)
    554.         return HAM_IGNORED;
    555.  
    556.     if (!g_has_balrog[attacker])
    557.         return HAM_IGNORED;
    558.  
    559.     make_explosion_effect(attacker);
    560.  
    561.     return HAM_IGNORED;
    562. }
    563.  
    564. give_balrog(id)
    565. {
    566.     drop_primary(id);
    567.  
    568.     g_has_balrog[id] = true;
    569.  
    570.     new weapon = fm_give_item(id, "weapon_ump45");
    571.  
    572.     cs_set_weapon_ammo(weapon, get_pcvar_num(cvar_balrog_clip));
    573.     cs_set_user_bpammo(id, CSW_UMP45, get_pcvar_num(cvar_balrog_ammo));
    574. }
    575.  
    576. play_weapon_anim(id, frame)
    577. {
    578.     set_pev(id, pev_weaponanim, frame);
    579.  
    580.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = id)
    581.     write_byte(frame)
    582.     write_byte(pev(id, pev_body))
    583.     message_end()
    584. }
    585.  
    586. make_laser_beam(id, Size, R, G, B)
    587. {
    588.     static End[3];
    589.     get_user_origin(id, End, 3);
    590.    
    591.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    592.     write_byte (TE_BEAMENTPOINT)
    593.     write_short( id |0x1000 )
    594.     write_coord(End[0])
    595.     write_coord(End[1])
    596.     write_coord(End[2])
    597.     write_short(g_laser_sprite)
    598.     write_byte(0)
    599.     write_byte(1)
    600.     write_byte(1)
    601.     write_byte(Size)
    602.     write_byte(4)
    603.     write_byte(R)
    604.     write_byte(G)
    605.     write_byte(B)
    606.     write_byte(255)
    607.     write_byte(0)
    608.     message_end()
    609. }
    610.  
    611. make_explosion_effect(id)
    612. {
    613.     static end[3];
    614.     get_user_origin(id, end, 3);
    615.  
    616.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    617.     write_byte(3)
    618.     write_coord(end[0])
    619.     write_coord(end[1])
    620.     write_coord(end[2])
    621.     write_short(g_balrog_exp)
    622.     write_byte(10)
    623.     write_byte(15)
    624.     write_byte(4)
    625.     message_end()
    626. }
    627.  
    628. drop_primary(id)
    629. {
    630.     static weapons[32], num;
    631.     get_user_weapons(id, weapons, num);
    632.  
    633.     for (new i = 0; i < num; i++)
    634.     {
    635.         if (WEAPON_BITSUM & (1<<weapons[i]))
    636.         {
    637.             static wname[32];
    638.             get_weaponname(weapons[i], wname, sizeof wname - 1);
    639.  
    640.             engclient_cmd(id, "drop", wname);
    641.         }
    642.     }
    643. }
    644.  
    645. stock fm_give_item(index, const item[])
    646. {
    647.     if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
    648.         return 0;
    649.  
    650.     new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item));
    651.     if (!pev_valid(ent))
    652.         return 0;
    653.  
    654.     new Float:origin[3];
    655.     pev(index, pev_origin, origin);
    656.     set_pev(ent, pev_origin, origin);
    657.     set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
    658.     dllfunc(DLLFunc_Spawn, ent);
    659.  
    660.     new save = pev(ent, pev_solid);
    661.     dllfunc(DLLFunc_Touch, ent, index);
    662.     if (pev(ent, pev_solid) != save)
    663.         return ent;
    664.  
    665.     engfunc(EngFunc_RemoveEntity, ent);
    666.  
    667.     return -1;
    668. }
    669.  
    670. stock fm_cs_get_current_weapon_ent(id)
    671. {
    672.     if (pev_valid(id) != 2)
    673.         return -1;
    674.    
    675.     return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX);
    676. }
    677.  
    678. public native_give_balrog(id)
    679. {
    680.     if ((get_user_flags(id) & ADMIN_LEVEL_H))
    681.     {
    682.         give_balrog(id);
    683.     }
    684. }
Weapons menu:
    1. #include <zombie_escape>
    2.  
    3. native ze_give_balrog(id)
    4.  
    5. // Setting File
    6. new const ZE_SETTING_RESOURCES[] = "zombie_escape.ini"
    7.  
    8. // Keys
    9. 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
    10. const OFFSET_CSMENUCODE = 205
    11.  
    12. // Primary Weapons Entities [Default Values]
    13. new const szPrimaryWeaponEnt[][]=
    14. {
    15.     "weapon_m4a1",
    16.     "weapon_ak47",
    17.     "weapon_aug",
    18.     "weapon_galil",
    19.     "weapon_famas",
    20.     "weapon_mp5navy",
    21.     "weapon_p90"
    22. }
    23.  
    24. // Secondary Weapons Entities [Default Values]
    25. new const szSecondaryWeaponEnt[][]=
    26. {
    27.     "weapon_usp",
    28.     "weapon_deagle",
    29.     "weapon_p228",
    30.     "weapon_elite",
    31. }
    32.  
    33. // Primary and Secondary Weapons Names [Default Values]
    34. new const szWeaponNames[][] =
    35. {
    36.     "",
    37.     "P228",
    38.     "",
    39.     "Scout",
    40.     "HE Grenade",
    41.     "XM1014",
    42.     "",
    43.     "MAC-10",
    44.     "AUG",
    45.     "Smoke Grenade",
    46.     "elite",
    47.     "Five Seven",
    48.     "UMP 45",
    49.     "SG-550",
    50.     "Galil",
    51.     "Famas",
    52.     "Usp",
    53.     "Glock",
    54.     "AWP",
    55.     "MP5",
    56.     "M249",
    57.     "M3",
    58.     "M4A1",
    59.     "TMP",
    60.     "G3SG1",
    61.     "Flashbang",
    62.     "Deagle",
    63.     "SG-552",
    64.     "AK-47",
    65.     "",
    66.     "P90"
    67. }
    68.  
    69. // Max Back Clip Ammo (Change it From here if you need)
    70. new const szMaxBPAmmo[] =
    71. {
    72.     -1,
    73.     200,
    74.     -1,
    75.     200,
    76.     1,
    77.     200,
    78.     1,
    79.     200,
    80.     200,
    81.     1,
    82.     200,
    83.     200,
    84.     200,
    85.     200,
    86.     200,
    87.     200,
    88.     200,
    89.     200,
    90.     200,
    91.     200,
    92.     200,
    93.     200,
    94.     200,
    95.     200,
    96.     200,
    97.     2,
    98.     200,
    99.     200,
    100.         200,
    101.     -1,
    102.     200
    103. }
    104.  
    105. // Menu selections
    106. const MENU_KEY_AUTOSELECT = 7
    107. const MENU_KEY_BACK = 7
    108. const MENU_KEY_NEXT = 8
    109. const MENU_KEY_EXIT = 9
    110.  
    111. // Variables
    112. new Array:g_szPrimaryWeapons,
    113.     Array:g_szSecondaryWeapons
    114.  
    115. new g_iMenuData[33][4],
    116.     Float:g_fBuyTimeStart[33],
    117.     bool:g_bBoughtPrimary[33],
    118.     bool:g_bBoughtSecondary[33]
    119.  
    120. // Define
    121. #define WPN_STARTID g_iMenuData[id][0]
    122. #define WPN_MAXIDS ArraySize(g_szPrimaryWeapons)
    123. #define WPN_SELECTION (g_iMenuData[id][0]+key)
    124. #define WPN_AUTO_ON g_iMenuData[id][1]
    125. #define WPN_AUTO_PRI g_iMenuData[id][2]
    126. #define WPN_AUTO_SEC g_iMenuData[id][3]
    127.  
    128. // Cvars
    129. new g_pCvarBuyTime,
    130.     g_pCvarHEGrenade,
    131.     g_pCvarSmokeGrenade,
    132.     g_pCvarFlashGrenade
    133.    
    134. public plugin_natives()
    135. {
    136.     register_native("ze_show_weapon_menu", "native_ze_show_weapon_menu", 1)
    137.     register_native("ze_is_auto_buy_enabled", "native_ze_is_auto_buy_enabled", 1)
    138.     register_native("ze_disable_auto_buy", "native_ze_disable_auto_buy", 1)
    139. }
    140.  
    141. public plugin_precache()
    142. {
    143.     // Initialize arrays (32 is the max length of Weapon Entity like: weapon_ak47)
    144.     g_szPrimaryWeapons = ArrayCreate(32, 1)
    145.     g_szSecondaryWeapons = ArrayCreate(32, 1)
    146.    
    147.     // Load from external file
    148.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
    149.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
    150.    
    151.     // If we couldn't load from file, use and save default ones
    152.    
    153.     new iIndex
    154.    
    155.     if (ArraySize(g_szPrimaryWeapons) == 0)
    156.     {
    157.         for (iIndex = 0; iIndex < sizeof szPrimaryWeaponEnt; iIndex++)
    158.             ArrayPushString(g_szPrimaryWeapons, szPrimaryWeaponEnt[iIndex])
    159.        
    160.         // If not found .ini File Create it and save default values in it
    161.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
    162.     }
    163.    
    164.     if (ArraySize(g_szSecondaryWeapons) == 0)
    165.     {
    166.         for (iIndex = 0; iIndex < sizeof szSecondaryWeaponEnt; iIndex++)
    167.             ArrayPushString(g_szSecondaryWeapons, szSecondaryWeaponEnt[iIndex])
    168.        
    169.         // If not found .ini File Create it and save default values in it
    170.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
    171.     }
    172. }
    173.  
    174. public plugin_init()
    175. {
    176.     register_plugin("[ZE] Weapons Menu", ZE_VERSION, AUTHORS)
    177.    
    178.     // Commands
    179.     register_clcmd("guns", "Cmd_Buy")
    180.     register_clcmd("say /enable", "Cmd_Enable")
    181.     register_clcmd("say_team /enable", "Cmd_Enable")
    182.    
    183.     // Cvars
    184.     g_pCvarBuyTime = register_cvar("ze_buy_time", "600")
    185.     g_pCvarHEGrenade = register_cvar("ze_give_HE_nade", "1") // 0 Nothing || 1 Give HE
    186.     g_pCvarSmokeGrenade = register_cvar("ze_give_SM_nade", "1")
    187.     g_pCvarFlashGrenade = register_cvar("ze_give_FB_nade", "1")
    188.    
    189.     // Menus
    190.     register_menu("Primary Weapons", KEYSMENU, "Menu_Buy_Primary")
    191.     register_menu("Secondary Weapons", KEYSMENU, "Menu_Buy_Secondary")
    192. }
    193.  
    194. public client_disconnected(id)
    195. {
    196.     WPN_AUTO_ON = 0
    197.     WPN_STARTID = 0
    198. }
    199.  
    200. public Cmd_Enable(id)
    201. {
    202.     if (WPN_AUTO_ON)
    203.     {
    204.         ze_colored_print(id, "%L", LANG_PLAYER, "BUY_ENABLED")
    205.         WPN_AUTO_ON = 0
    206.     }
    207. }
    208.  
    209. public Cmd_Buy(id)
    210. {
    211.     // Player Zombie
    212.     if (ze_is_user_zombie(id))
    213.     {
    214.         ze_colored_print(id, "%L", LANG_PLAYER, "NO_BUY_ZOMBIE")
    215.         return
    216.     }
    217.    
    218.     // Player Dead
    219.     if (!is_user_alive(id))
    220.     {
    221.         ze_colored_print(id, "%L", LANG_PLAYER, "DEAD_CANT_BUY_WEAPON")
    222.         return
    223.     }
    224.    
    225.     // Already bought
    226.     if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
    227.     {
    228.         ze_colored_print(id, "%L", LANG_PLAYER, "ALREADY_BOUGHT")
    229.     }
    230.    
    231.     Show_Available_Buy_Menus(id)
    232. }
    233.  
    234. public ze_user_humanized(id)
    235. {
    236.     // Buyzone time starts when player is set to human
    237.     g_fBuyTimeStart[id] = get_gametime()
    238.    
    239.     g_bBoughtPrimary[id] = false
    240.     g_bBoughtSecondary[id] = false
    241.    
    242.     // Player dead or zombie
    243.     if (!is_user_alive(id) || ze_is_user_zombie(id))
    244.         return
    245.    
    246.     if (WPN_AUTO_ON)
    247.         ze_colored_print(id, "%L", LANG_PLAYER, "RE_ENABLE_MENU")
    248.        
    249.     if (WPN_AUTO_ON)
    250.     {
    251.         Buy_Primary_Weapon(id, WPN_AUTO_PRI)
    252.     }
    253.  
    254.     if (WPN_AUTO_ON)
    255.     {
    256.         Buy_Secondary_Weapon(id, WPN_AUTO_SEC)
    257.     }
    258.    
    259.     // Open available buy menus
    260.     Show_Available_Buy_Menus(id)
    261.    
    262.     // Give HE Grenade
    263.     if (get_pcvar_num(g_pCvarHEGrenade) != 0)
    264.         rg_give_item(id, "weapon_hegrenade")
    265.    
    266.     // Give Smoke Grenade
    267.     if (get_pcvar_num(g_pCvarSmokeGrenade) != 0)
    268.         rg_give_item(id, "weapon_smokegrenade")
    269.    
    270.     // Give Flashbang Grenade
    271.     if (get_pcvar_num(g_pCvarFlashGrenade) != 0)
    272.         rg_give_item(id, "weapon_flashbang")
    273. }
    274.  
    275. public Show_Available_Buy_Menus(id)
    276. {
    277.     // Already Bought
    278.     if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
    279.         return
    280.    
    281.     // Here we use if and else if so we make sure that Primary weapon come first then secondary
    282.     if (!g_bBoughtPrimary[id])
    283.     {
    284.         // Primary     
    285.         Show_Menu_Buy_Primary(id)
    286.     }
    287.     else if (!g_bBoughtSecondary[id])
    288.     {
    289.         // Secondary
    290.         Show_Menu_Buy_Secondary(id)
    291.     }
    292. }
    293.  
    294. public Show_Menu_Buy_Primary(id)
    295. {
    296.     new iMenuTime = floatround(g_fBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
    297.    
    298.     if (iMenuTime <= 0)
    299.     {
    300.         ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
    301.         return
    302.     }
    303.    
    304.     static szMenu[300], szWeaponName[32]
    305.     new iLen, iIndex, iMaxLoops = min(WPN_STARTID+7, WPN_MAXIDS)
    306.    
    307.     // Title
    308.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L ^n^n", id, "MENU_PRIMARY_TITLE", WPN_STARTID+1, min(WPN_STARTID+7, WPN_MAXIDS))
    309.    
    310.     // 1-7. Weapon List
    311.     for (iIndex = WPN_STARTID; iIndex < iMaxLoops; iIndex++)
    312.     {
    313.         ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
    314.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r%d.\w %s^n", iIndex-WPN_STARTID+1, szWeaponNames[get_weaponid(szWeaponName)])
    315.     }
    316.  
    317.     // 8. Auto Select
    318.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r8.\w %L \r%L", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "SAVE_YES" : "SAVE_NO")
    319.    
    320.     // 0. Exit
    321.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r0.\r %L", id, "EXIT")
    322.    
    323.     // Fix for AMXX custom menus
    324.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    325.     show_menu(id, KEYSMENU, szMenu, iMenuTime, "Primary Weapons")
    326. }
    327.  
    328. public Show_Menu_Buy_Secondary(id)
    329. {
    330.     new iMenuTime = floatround(g_fBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
    331.    
    332.     if (iMenuTime <= 0)
    333.     {
    334.         ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
    335.         return
    336.     }
    337.    
    338.     static szMenu[250], szWeaponName[32]
    339.     new iLen, iIndex, iMaxLoops = ArraySize(g_szSecondaryWeapons)
    340.    
    341.     // Title
    342.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L^n", id, "MENU_SECONDARY_TITLE")
    343.    
    344.     // 1-6. Weapon List
    345.     for (iIndex = 0; iIndex < iMaxLoops; iIndex++)
    346.     {
    347.         ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
    348.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r%d.\w %s", iIndex+1, szWeaponNames[get_weaponid(szWeaponName)])
    349.     }
    350.    
    351.     // 8. Auto Select
    352.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r8.\w %L \r%L", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "SAVE_YES" : "SAVE_NO")
    353.    
    354.     // 0. Exit
    355.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r0.\r %L", id, "EXIT")
    356.    
    357.     // Fix for AMXX custom menus
    358.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    359.     show_menu(id, KEYSMENU, szMenu, iMenuTime, "Secondary Weapons")
    360. }
    361.  
    362. public Menu_Buy_Primary(id, key)
    363. {
    364.     // Player dead or zombie or already bought primary
    365.     if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtPrimary[id])
    366.         return PLUGIN_HANDLED
    367.    
    368.     // Special keys / weapon list exceeded
    369.     if (key >= MENU_KEY_AUTOSELECT || WPN_SELECTION >= WPN_MAXIDS)
    370.     {
    371.         switch (key)
    372.         {
    373.             case MENU_KEY_AUTOSELECT: // toggle auto select
    374.             {
    375.                 WPN_AUTO_ON = 1 - WPN_AUTO_ON
    376.             }
    377.             case MENU_KEY_NEXT: // next/back
    378.             {
    379.                 if (WPN_STARTID+7 < WPN_MAXIDS)
    380.                     WPN_STARTID += 7
    381.                 else
    382.                     WPN_STARTID = 0
    383.             }
    384.             case MENU_KEY_EXIT: // exit
    385.             {
    386.                 return PLUGIN_HANDLED
    387.             }
    388.         }
    389.        
    390.         // Show buy menu again
    391.         Show_Menu_Buy_Primary(id)
    392.         return PLUGIN_HANDLED
    393.     }
    394.    
    395.     // Store selected weapon id
    396.     WPN_AUTO_PRI = WPN_SELECTION
    397.    
    398.     // Buy primary weapon
    399.     Buy_Primary_Weapon(id, WPN_AUTO_PRI)
    400.    
    401.     // Show Secondary Weapons
    402.     Show_Available_Buy_Menus(id)
    403.    
    404.     return PLUGIN_HANDLED
    405. }
    406.  
    407. public Buy_Primary_Weapon(id, selection)
    408. {
    409.     static szWeaponName[32]
    410.     ArrayGetString(g_szPrimaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
    411.     new iWeaponId = get_weaponid(szWeaponName)
    412.    
    413.     // Strip and Give Full Weapon
    414.     rg_give_item(id, szWeaponName, GT_REPLACE)
    415.     rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
    416.    
    417.     if (get_user_flags(id) & ADMIN_LEVEL_H)
    418.     {
    419.         ze_give_balrog(id)
    420.     }
    421.    
    422.     // Primary bought
    423.     g_bBoughtPrimary[id] = true
    424. }
    425.  
    426. public Menu_Buy_Secondary(id, key)
    427. {
    428.     // Player dead or zombie or already bought secondary
    429.     if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtSecondary[id])
    430.         return PLUGIN_HANDLED
    431.    
    432.     // Special keys / weapon list exceeded
    433.     if (key >= ArraySize(g_szSecondaryWeapons))
    434.     {
    435.         // Toggle autoselect
    436.         if (key == MENU_KEY_AUTOSELECT)
    437.             WPN_AUTO_ON = 1 - WPN_AUTO_ON
    438.        
    439.         // Reshow menu unless user exited
    440.         if (key != MENU_KEY_EXIT)
    441.             Show_Menu_Buy_Secondary(id)
    442.        
    443.         return PLUGIN_HANDLED
    444.     }
    445.    
    446.     // Store selected weapon id
    447.     WPN_AUTO_SEC = key
    448.    
    449.     // Buy secondary weapon
    450.     Buy_Secondary_Weapon(id, key)
    451.    
    452.     return PLUGIN_HANDLED
    453. }
    454.  
    455. public Buy_Secondary_Weapon(id, selection)
    456. {
    457.     static szWeaponName[32]
    458.     ArrayGetString(g_szSecondaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
    459.     new iWeaponId = get_weaponid(szWeaponName)
    460.    
    461.     // Strip and Give Full Weapon
    462.     rg_give_item(id, szWeaponName, GT_REPLACE)
    463.     rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
    464.    
    465.     // Secondary bought
    466.     g_bBoughtSecondary[id] = true
    467. }
    468.  
    469. // Natives
    470. public native_ze_show_weapon_menu(id)
    471. {
    472.     if (!is_user_connected(id))
    473.     {
    474.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    475.         return false
    476.     }
    477.    
    478.     Cmd_Buy(id)
    479.     return true
    480. }
    481.  
    482. public native_ze_is_auto_buy_enabled(id)
    483. {
    484.     if (!is_user_connected(id))
    485.     {
    486.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    487.         return -1;
    488.     }
    489.    
    490.     return WPN_AUTO_ON;
    491. }
    492.  
    493. public native_ze_disable_auto_buy(id)
    494. {
    495.     if (!is_user_connected(id))
    496.     {
    497.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    498.         return false
    499.     }
    500.    
    501.     WPN_AUTO_ON = 0;
    502.     return true
    503. }
If found any error in console, post it.
He who fails to plan is planning to fail

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 258
Joined: 7 years ago
Contact:

#12

Post by sPe3doN » 5 years ago

Raheem wrote: 5 years ago Barlog:
    1. /*================================================================================
    2.  
    3.             --------------------------------
    4.             [ZE] Extra Item: Balrog Ethereal
    5.             --------------------------------
    6.  
    7.         Balrog Ethereal
    8.         Copyright (C) 2017 by Crazy + ZE DEV TEAM
    9.  
    10.         -------------------
    11.         -*- Description -*-
    12.         -------------------
    13.  
    14.         This plugin add a new weapon into your zombie plague mod with
    15.         the name of Balrog Ethereal. That weapon launch a powerfull beams!
    16.         When the laser hit any object, a explosion effect with red color appers.
    17.  
    18.         ----------------
    19.         -*- Commands -*-
    20.         ----------------
    21.  
    22.         * zp_give_balrog_ethereal <target> - Give the item to target.
    23.  
    24.         -------------
    25.         -*- Cvars -*-
    26.         -------------
    27.  
    28.         * ze_balrog_ethereal_ammo <number> - Ammo amout.
    29.         * ze_balrog_ethereal_clip <number> - Clip amout. (Max: 100)
    30.         * ze_balrog_ethereal_one_round <0/1> - Only one round.
    31.         * ze_balrog_ethereal_damage <number> - Damage multiplier.
    32.         * ze_balrog_ethereal_unlimited <0/1> - Unlimited ammunition.
    33.  
    34.         ------------------
    35.         -*- Change Log -*-
    36.         ------------------
    37.  
    38.         * v1.5: (Mar 2017)
    39.             - Updated all the code, added explosion effect, added new cvars;
    40.  
    41.         * v1.6: (Mar 2017)
    42.             - Added custom weapon hud;
    43.  
    44.         ---------------
    45.         -*- Credits -*-
    46.         ---------------
    47.  
    48.         * MeRcyLeZZ: for the nice zombie plague mod.
    49.         * Crazy: created the extra item code.
    50.         * deanamx: for the nice weapon model.
    51.         * And all zombie-mod players that use this weapon.
    52.         * ZE DEV TEAM : For converting this Item
    53.  
    54.  
    55. =================================================================================*/
    56. #include <zombie_escape>
    57. #include <cstrike>
    58. #include <engine>
    59.  
    60. /*================================================================================
    61.  [Plugin Customization]
    62. =================================================================================*/
    63.  
    64. // Item Name
    65. #define ITEM_NAME "Balrog Ethereal"
    66.  
    67.  
    68. /*================================================================================
    69.  Customization ends here! Yes, that's it. Editing anything beyond
    70.  here is not officially supported. Proceed at your own risk...
    71. =================================================================================*/
    72.  
    73. new const PLUGIN_VERSION[] = "v1.6";
    74.  
    75. new const V_BALROG_MDL[64] = "models/zombie_escape/v_balrog_ethereal.mdl";
    76. new const P_BALROG_MDL[64] = "models/zombie_escape/p_balrog_ethereal.mdl";
    77. new const W_BALROG_MDL[64] = "models/zombie_escape/w_balrog_ethereal.mdl";
    78.  
    79. new const BALROG_SOUNDS[][] = { "weapons/ethereal_shoot.wav", "weapons/ethereal_reload.wav", "weapons/ethereal_idle1.wav", "weapons/ethereal_draw.wav" };
    80.  
    81. new g_has_balrog[33], g_laser_sprite, g_balrog_exp, g_balrog, g_event_balrog, g_playername[33][32], g_maxplayers, g_primary_attack, g_balrog_reload_clip[33], cvar_balrog_clip, cvar_balrog_ammo, cvar_balrog_damage, cvar_balrog_oneround, cvar_balrog_unlimited;
    82.  
    83. const BALROG_KEY = 0982478;
    84.  
    85. const m_iClip = 51;
    86. const m_flNextAttack = 83;
    87. const m_fInReload = 54;
    88.  
    89. const OFFSET_WEAPON_OWNER = 41;
    90. const OFFSET_LINUX_WEAPONS = 4;
    91. const OFFSET_LINUX = 5;
    92. const OFFSET_ACTIVE_ITEM = 373;
    93.  
    94. const WEAPON_BITSUM = ((1<<CSW_SCOUT) | (1<<CSW_XM1014) | (1<<CSW_MAC10) | (1<<CSW_AUG) | (1<<CSW_UMP45) | (1<<CSW_SG550) | (1<<CSW_P90) | (1<<CSW_FAMAS) | (1<<CSW_AWP) | (1<<CSW_MP5NAVY) | (1<<CSW_M249) | (1<<CSW_M3) | (1<<CSW_M4A1) | (1<<CSW_TMP) | (1<<CSW_G3SG1) | (1<<CSW_SG552) | (1<<CSW_AK47) | (1<<CSW_GALIL));
    95.  
    96. enum
    97. {
    98.     idle = 0,
    99.     reload,
    100.     draw,
    101.     shoot1,
    102.     shoot2,
    103.     shoot3
    104. }
    105.  
    106. public plugin_natives()
    107. {
    108.     register_native("ze_give_balrog", "native_give_balrog", 1)
    109. }
    110.  
    111. public plugin_init()
    112. {
    113.     /* Plugin register */
    114.     register_plugin("[ZE] Extra Item: Balrog Ethereal", PLUGIN_VERSION, "Crazy");
    115.  
    116.     /* Item register */
    117.     g_balrog = ze_register_item("Balrog Ethereal", 10, 0);
    118.  
    119.     /* Events */
    120.     register_event("HLTV", "event_round_start", "a", "1=0", "2=0");
    121.  
    122.     /* Messages */
    123.     register_message(get_user_msgid("CurWeapon"), "message_cur_weapon");
    124.  
    125.     /* Forwards */
    126.     register_forward(FM_UpdateClientData, "fw_UpdateData_Post", 1);
    127.     register_forward(FM_SetModel, "fw_SetModel");
    128.     register_forward(FM_PlaybackEvent, "fw_PlaybackEvent");
    129.  
    130.     /* Ham Forwards */
    131.     RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack_Post", 1);
    132.     RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack_Post", 1);
    133.     RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack_Post", 1);
    134.     RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack_Post", 1);
    135.     RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack_Post", 1);
    136.     RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack_Post", 1);
    137.     RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack_Post", 1);
    138.     RegisterHam(Ham_Item_Deploy, "weapon_ump45", "fw_Item_Deploy_Post", 1);
    139.     RegisterHam(Ham_Item_AddToPlayer, "weapon_ump45", "fw_Item_AddToPlayer_Post", 1);
    140.     RegisterHam(Ham_Item_PostFrame, "weapon_ump45", "fw_Item_PostFrame");
    141.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_PrimaryAttack");
    142.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_PrimaryAttack_Post", 1);
    143.     RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Reload");
    144.     RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Reload_Post", 1);
    145.     RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage");
    146.  
    147.     /* Cvars */
    148.     cvar_balrog_clip = register_cvar("ze_balrog_minigun_clip", "50");
    149.     cvar_balrog_ammo = register_cvar("ze_balrog_minigun_ammo", "200");
    150.     cvar_balrog_damage = register_cvar("ze_balrog_minigun_damage", "3.0");
    151.     cvar_balrog_oneround = register_cvar("ze_balrog_minigun_one_round", "0");
    152.     cvar_balrog_unlimited = register_cvar("ze_balrog_minigun_unlimited", "0");
    153.  
    154.     /* Max Players */
    155.     g_maxplayers = get_maxplayers()
    156. }
    157.  
    158. public plugin_precache()
    159. {
    160.     engfunc(EngFunc_PrecacheModel, V_BALROG_MDL);
    161.     engfunc(EngFunc_PrecacheModel, P_BALROG_MDL);
    162.     engfunc(EngFunc_PrecacheModel, W_BALROG_MDL);
    163.  
    164.     engfunc(EngFunc_PrecacheGeneric, "sprites/weapon_bethereal.txt");
    165.     engfunc(EngFunc_PrecacheGeneric, "sprites/640hud2_bethereal.spr");
    166.     engfunc(EngFunc_PrecacheGeneric, "sprites/640hud10_bethereal.spr");
    167.     engfunc(EngFunc_PrecacheGeneric, "sprites/640hud74_bethereal.spr");
    168.  
    169.     for (new i = 0; i < sizeof BALROG_SOUNDS; i++)
    170.     engfunc(EngFunc_PrecacheSound, BALROG_SOUNDS[i]);
    171.  
    172.     g_laser_sprite = precache_model("sprites/laserbeam.spr");
    173.     g_balrog_exp = precache_model("sprites/zombie_plague/balrog_ethereal_exp.spr");
    174.  
    175.     register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1);
    176.     register_clcmd("weapon_bethereal", "cmd_balrog_selected");
    177. }
    178.  
    179. public ze_user_infected(id)
    180. {
    181.     g_has_balrog[id] = false;
    182. }
    183.  
    184. public ze_user_humanized(id)
    185. {
    186.     g_has_balrog[id] = false;
    187. }
    188.  
    189. public client_putinserver(id)
    190. {
    191.     g_has_balrog[id] = false;
    192.  
    193.     get_user_name(id, g_playername[id], charsmax(g_playername[]));
    194. }
    195.  
    196. public event_round_start()
    197. {
    198.     for (new id = 0; id <= g_maxplayers; id++)
    199.     {
    200.         if (get_pcvar_num(cvar_balrog_oneround))
    201.         g_has_balrog[id] = false;
    202.     }
    203. }
    204.  
    205. public cmd_balrog_selected(client)
    206. {
    207.     engclient_cmd(client, "weapon_ump45");
    208.     return PLUGIN_HANDLED;
    209. }
    210.  
    211. public message_cur_weapon(msg_id, msg_dest, msg_entity)
    212. {
    213.     if (!is_user_alive(msg_entity))
    214.         return;
    215.  
    216.     if (!g_has_balrog[msg_entity])
    217.         return;
    218.  
    219.     if (get_user_weapon(msg_entity) != CSW_UMP45)
    220.         return;
    221.  
    222.     if (get_msg_arg_int(1) != 1)
    223.         return;
    224.  
    225.     if (get_pcvar_num(cvar_balrog_unlimited))
    226.     {
    227.         static ent;
    228.         ent = fm_cs_get_current_weapon_ent(msg_entity);
    229.  
    230.         if (!pev_valid(ent))
    231.             return;
    232.  
    233.         cs_set_weapon_ammo(ent, get_pcvar_num(cvar_balrog_clip));
    234.         set_msg_arg_int(3, get_msg_argtype(3), get_pcvar_num(cvar_balrog_clip));
    235.     }
    236. }
    237.  
    238. public ze_select_item_pre(id, itemid)
    239. {
    240.     // This not our item?
    241.     if (itemid != g_balrog)
    242.         return ZE_ITEM_AVAILABLE
    243.    
    244.     // Available for Humans only, So don't show it for zombies
    245.     if (ze_is_user_zombie(id))
    246.         return ZE_ITEM_DONT_SHOW
    247.    
    248.     // Finally return that it's available
    249.     return ZE_ITEM_AVAILABLE
    250. }
    251.  
    252. public ze_select_item_post(id, itemid)
    253. {
    254.     if (itemid != g_balrog)
    255.         return;
    256.  
    257.     if (g_has_balrog[id])
    258.     {
    259.         client_print(id, print_chat, "[ZE] You already have the %s.", ITEM_NAME);
    260.         return;
    261.     }
    262.  
    263.     give_balrog(id);
    264.  
    265.     client_print(id, print_chat, "[ZE] You bought the %s.", ITEM_NAME);
    266. }
    267.  
    268. public fw_UpdateData_Post(id, sendweapons, cd_handle)
    269. {
    270.     if (!is_user_alive(id))
    271.         return FMRES_IGNORED;
    272.  
    273.     if (!g_has_balrog[id])
    274.         return FMRES_IGNORED;
    275.  
    276.     if (get_user_weapon(id) != CSW_UMP45)
    277.         return FMRES_IGNORED;
    278.  
    279.     set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001);
    280.  
    281.     return FMRES_IGNORED;
    282. }
    283.  
    284. public fw_SetModel(ent, const model[])
    285. {
    286.     if (!pev_valid(ent))
    287.         return FMRES_IGNORED;
    288.  
    289.     if (!equal(model, "models/w_ump45.mdl"))
    290.         return HAM_IGNORED;
    291.  
    292.     static class_name[33];
    293.     pev(ent, pev_classname, class_name, charsmax(class_name));
    294.  
    295.     if (!equal(class_name, "weaponbox"))
    296.         return FMRES_IGNORED;
    297.  
    298.     static owner, weapon;
    299.     owner = pev(ent, pev_owner);
    300.     weapon = find_ent_by_owner(-1, "weapon_ump45", ent);
    301.  
    302.     if (!g_has_balrog[owner] || !pev_valid(weapon))
    303.         return FMRES_IGNORED;
    304.  
    305.     g_has_balrog[owner] = false;
    306.  
    307.     set_pev(weapon, pev_impulse, BALROG_KEY);
    308.  
    309.     engfunc(EngFunc_SetModel, ent, W_BALROG_MDL);
    310.  
    311.     return FMRES_SUPERCEDE;
    312. }
    313.  
    314. public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
    315. {
    316.     if ((eventid != g_event_balrog) || !g_primary_attack)
    317.         return FMRES_IGNORED;
    318.  
    319.     if (!(1 <= invoker <= g_maxplayers))
    320.         return FMRES_IGNORED;
    321.  
    322.     playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2);
    323.  
    324.     return FMRES_SUPERCEDE;
    325. }
    326.  
    327. public fw_PrecacheEvent_Post(type, const name[])
    328. {
    329.     if (!equal("events/ump45.sc", name))
    330.         return HAM_IGNORED;
    331.  
    332.     g_event_balrog = get_orig_retval()
    333.  
    334.     return FMRES_HANDLED;
    335. }
    336.  
    337. public fw_Item_Deploy_Post(ent)
    338. {
    339.     if (!pev_valid(ent))
    340.         return HAM_IGNORED;
    341.  
    342.     new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
    343.  
    344.     if (!is_user_alive(id))
    345.         return HAM_IGNORED;
    346.  
    347.     if (!g_has_balrog[id])
    348.         return HAM_IGNORED;
    349.  
    350.     set_pev(id, pev_viewmodel2, V_BALROG_MDL);
    351.     set_pev(id, pev_weaponmodel2, P_BALROG_MDL);
    352.  
    353.     play_weapon_anim(id, draw);
    354.  
    355.     return HAM_IGNORED;
    356. }
    357.  
    358. public fw_Item_AddToPlayer_Post(ent, id)
    359. {
    360.     if (!pev_valid(ent))
    361.         return HAM_IGNORED;
    362.  
    363.     if (!is_user_alive(id))
    364.         return HAM_IGNORED;
    365.  
    366.     if (pev(ent, pev_impulse) == BALROG_KEY)
    367.     {
    368.         g_has_balrog[id] = true;
    369.         set_pev(ent, pev_impulse, 0);
    370.     }
    371.  
    372.     message_begin(MSG_ONE, get_user_msgid("WeaponList"), _, id)
    373.     write_string((g_has_balrog[id] ? "weapon_bethereal" : "weapon_ump45"))
    374.     write_byte(6)
    375.     write_byte(100)
    376.     write_byte(-1)
    377.     write_byte(-1)
    378.     write_byte(0)
    379.     write_byte(15)
    380.     write_byte(CSW_UMP45)
    381.     write_byte(0)
    382.     message_end()
    383.  
    384.     return HAM_IGNORED;
    385. }
    386.  
    387. public fw_Item_PostFrame(ent)
    388. {
    389.     if (!pev_valid(ent))
    390.         return HAM_IGNORED;
    391.  
    392.     new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
    393.  
    394.     if (!is_user_alive(id))
    395.         return HAM_IGNORED;
    396.  
    397.     if (!g_has_balrog[id])
    398.         return HAM_IGNORED;
    399.  
    400.     static cvar_clip; cvar_clip = get_pcvar_num(cvar_balrog_clip);
    401.  
    402.     new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
    403.     new bpammo = cs_get_user_bpammo(id, CSW_UMP45);
    404.  
    405.     new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, OFFSET_LINUX);
    406.     new fInReload = get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS);
    407.  
    408.     if (fInReload && flNextAttack <= 0.0)
    409.     {
    410.         new temp_clip = min(cvar_clip - clip, bpammo);
    411.  
    412.         set_pdata_int(ent, m_iClip, clip + temp_clip, OFFSET_LINUX_WEAPONS);
    413.  
    414.         cs_set_user_bpammo(id, CSW_UMP45, bpammo-temp_clip);
    415.  
    416.         set_pdata_int(ent, m_fInReload, 0, OFFSET_LINUX_WEAPONS);
    417.  
    418.         fInReload = 0;
    419.     }
    420.  
    421.     return HAM_IGNORED;
    422. }
    423.  
    424. public fw_PrimaryAttack(ent)
    425. {
    426.     if (!pev_valid(ent))
    427.         return HAM_IGNORED;
    428.  
    429.     new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
    430.  
    431.     if (!is_user_alive(id))
    432.         return HAM_IGNORED;
    433.  
    434.     if (!g_has_balrog[id])
    435.         return HAM_IGNORED;
    436.  
    437.     if (!cs_get_weapon_ammo(ent))
    438.         return HAM_IGNORED;
    439.  
    440.     g_primary_attack = true;
    441.  
    442.     return HAM_IGNORED;
    443. }
    444.  
    445. public fw_PrimaryAttack_Post(ent)
    446. {
    447.     if (!pev_valid(ent))
    448.         return HAM_IGNORED;
    449.  
    450.     new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
    451.  
    452.     if (!is_user_alive(id))
    453.         return HAM_IGNORED;
    454.  
    455.     if (!g_has_balrog[id])
    456.         return HAM_IGNORED;
    457.  
    458.     if (!cs_get_weapon_ammo(ent))
    459.         return HAM_IGNORED;
    460.  
    461.     g_primary_attack = false;
    462.  
    463.     play_weapon_anim(id, random_num(shoot1, shoot3));
    464.  
    465.     emit_sound(id, CHAN_WEAPON, BALROG_SOUNDS[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
    466.  
    467.     make_laser_beam(id, 7, 100, 0, 0);
    468.  
    469.     return HAM_IGNORED;
    470. }
    471.  
    472. public fw_Reload(ent)
    473. {
    474.     if (!pev_valid(ent))
    475.         return HAM_IGNORED;
    476.  
    477.     new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
    478.  
    479.     if (!is_user_alive(id))
    480.         return HAM_IGNORED;
    481.  
    482.     if (!g_has_balrog[id])
    483.         return HAM_IGNORED;
    484.  
    485.     static cvar_clip;
    486.  
    487.     if (g_has_balrog[id])
    488.         cvar_clip = get_pcvar_num(cvar_balrog_clip);
    489.  
    490.     g_balrog_reload_clip[id] = -1;
    491.  
    492.     new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
    493.     new bpammo = cs_get_user_bpammo(id, CSW_UMP45);
    494.  
    495.     if (bpammo <= 0)
    496.         return HAM_SUPERCEDE;
    497.  
    498.     if (clip >= cvar_clip)
    499.         return HAM_SUPERCEDE;
    500.    
    501.     g_balrog_reload_clip[id] = clip;
    502.  
    503.     return HAM_IGNORED;
    504. }
    505.  
    506. public fw_Reload_Post(ent)
    507. {
    508.     if (!pev_valid(ent))
    509.         return HAM_IGNORED;
    510.  
    511.     new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
    512.  
    513.     if (!is_user_alive(id))
    514.         return HAM_IGNORED;
    515.  
    516.     if (!g_has_balrog[id])
    517.         return HAM_IGNORED;
    518.  
    519.     if (g_balrog_reload_clip[id] == -1)
    520.         return HAM_IGNORED;
    521.  
    522.     set_pdata_int(ent, m_iClip, g_balrog_reload_clip[id], OFFSET_LINUX_WEAPONS);
    523.     set_pdata_int(ent, m_fInReload, 1, OFFSET_LINUX_WEAPONS);
    524.  
    525.     play_weapon_anim(id, reload);
    526.  
    527.     return HAM_IGNORED;
    528. }
    529.  
    530. public fw_TakeDamage(victim, inflictor, attacker, Float:damage, dmg_bits)
    531. {
    532.     if (!is_user_alive(attacker))
    533.         return HAM_IGNORED;
    534.  
    535.     if (!g_has_balrog[attacker])
    536.         return HAM_IGNORED;
    537.  
    538.     if (get_user_weapon(attacker) != CSW_UMP45)
    539.         return HAM_IGNORED;
    540.  
    541.     SetHamParamFloat(OFFSET_LINUX_WEAPONS, damage * get_pcvar_float(cvar_balrog_damage));
    542.  
    543.     make_explosion_effect(attacker);
    544.  
    545.     return HAM_IGNORED;
    546. }
    547.  
    548. public fw_TraceAttack_Post(ent, attacker, Float:damage, Float:dir[3], ptr, dmg_bits)
    549. {
    550.     if (!is_user_alive(attacker))
    551.         return HAM_IGNORED;
    552.  
    553.     if (get_user_weapon(attacker) != CSW_UMP45)
    554.         return HAM_IGNORED;
    555.  
    556.     if (!g_has_balrog[attacker])
    557.         return HAM_IGNORED;
    558.  
    559.     make_explosion_effect(attacker);
    560.  
    561.     return HAM_IGNORED;
    562. }
    563.  
    564. give_balrog(id)
    565. {
    566.     drop_primary(id);
    567.  
    568.     g_has_balrog[id] = true;
    569.  
    570.     new weapon = fm_give_item(id, "weapon_ump45");
    571.  
    572.     cs_set_weapon_ammo(weapon, get_pcvar_num(cvar_balrog_clip));
    573.     cs_set_user_bpammo(id, CSW_UMP45, get_pcvar_num(cvar_balrog_ammo));
    574. }
    575.  
    576. play_weapon_anim(id, frame)
    577. {
    578.     set_pev(id, pev_weaponanim, frame);
    579.  
    580.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = id)
    581.     write_byte(frame)
    582.     write_byte(pev(id, pev_body))
    583.     message_end()
    584. }
    585.  
    586. make_laser_beam(id, Size, R, G, B)
    587. {
    588.     static End[3];
    589.     get_user_origin(id, End, 3);
    590.    
    591.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    592.     write_byte (TE_BEAMENTPOINT)
    593.     write_short( id |0x1000 )
    594.     write_coord(End[0])
    595.     write_coord(End[1])
    596.     write_coord(End[2])
    597.     write_short(g_laser_sprite)
    598.     write_byte(0)
    599.     write_byte(1)
    600.     write_byte(1)
    601.     write_byte(Size)
    602.     write_byte(4)
    603.     write_byte(R)
    604.     write_byte(G)
    605.     write_byte(B)
    606.     write_byte(255)
    607.     write_byte(0)
    608.     message_end()
    609. }
    610.  
    611. make_explosion_effect(id)
    612. {
    613.     static end[3];
    614.     get_user_origin(id, end, 3);
    615.  
    616.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    617.     write_byte(3)
    618.     write_coord(end[0])
    619.     write_coord(end[1])
    620.     write_coord(end[2])
    621.     write_short(g_balrog_exp)
    622.     write_byte(10)
    623.     write_byte(15)
    624.     write_byte(4)
    625.     message_end()
    626. }
    627.  
    628. drop_primary(id)
    629. {
    630.     static weapons[32], num;
    631.     get_user_weapons(id, weapons, num);
    632.  
    633.     for (new i = 0; i < num; i++)
    634.     {
    635.         if (WEAPON_BITSUM & (1<<weapons[i]))
    636.         {
    637.             static wname[32];
    638.             get_weaponname(weapons[i], wname, sizeof wname - 1);
    639.  
    640.             engclient_cmd(id, "drop", wname);
    641.         }
    642.     }
    643. }
    644.  
    645. stock fm_give_item(index, const item[])
    646. {
    647.     if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
    648.         return 0;
    649.  
    650.     new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item));
    651.     if (!pev_valid(ent))
    652.         return 0;
    653.  
    654.     new Float:origin[3];
    655.     pev(index, pev_origin, origin);
    656.     set_pev(ent, pev_origin, origin);
    657.     set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
    658.     dllfunc(DLLFunc_Spawn, ent);
    659.  
    660.     new save = pev(ent, pev_solid);
    661.     dllfunc(DLLFunc_Touch, ent, index);
    662.     if (pev(ent, pev_solid) != save)
    663.         return ent;
    664.  
    665.     engfunc(EngFunc_RemoveEntity, ent);
    666.  
    667.     return -1;
    668. }
    669.  
    670. stock fm_cs_get_current_weapon_ent(id)
    671. {
    672.     if (pev_valid(id) != 2)
    673.         return -1;
    674.    
    675.     return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX);
    676. }
    677.  
    678. public native_give_balrog(id)
    679. {
    680.     if ((get_user_flags(id) & ADMIN_LEVEL_H))
    681.     {
    682.         give_balrog(id);
    683.     }
    684. }
Weapons menu:
    1. #include <zombie_escape>
    2.  
    3. native ze_give_balrog(id)
    4.  
    5. // Setting File
    6. new const ZE_SETTING_RESOURCES[] = "zombie_escape.ini"
    7.  
    8. // Keys
    9. 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
    10. const OFFSET_CSMENUCODE = 205
    11.  
    12. // Primary Weapons Entities [Default Values]
    13. new const szPrimaryWeaponEnt[][]=
    14. {
    15.     "weapon_m4a1",
    16.     "weapon_ak47",
    17.     "weapon_aug",
    18.     "weapon_galil",
    19.     "weapon_famas",
    20.     "weapon_mp5navy",
    21.     "weapon_p90"
    22. }
    23.  
    24. // Secondary Weapons Entities [Default Values]
    25. new const szSecondaryWeaponEnt[][]=
    26. {
    27.     "weapon_usp",
    28.     "weapon_deagle",
    29.     "weapon_p228",
    30.     "weapon_elite",
    31. }
    32.  
    33. // Primary and Secondary Weapons Names [Default Values]
    34. new const szWeaponNames[][] =
    35. {
    36.     "",
    37.     "P228",
    38.     "",
    39.     "Scout",
    40.     "HE Grenade",
    41.     "XM1014",
    42.     "",
    43.     "MAC-10",
    44.     "AUG",
    45.     "Smoke Grenade",
    46.     "elite",
    47.     "Five Seven",
    48.     "UMP 45",
    49.     "SG-550",
    50.     "Galil",
    51.     "Famas",
    52.     "Usp",
    53.     "Glock",
    54.     "AWP",
    55.     "MP5",
    56.     "M249",
    57.     "M3",
    58.     "M4A1",
    59.     "TMP",
    60.     "G3SG1",
    61.     "Flashbang",
    62.     "Deagle",
    63.     "SG-552",
    64.     "AK-47",
    65.     "",
    66.     "P90"
    67. }
    68.  
    69. // Max Back Clip Ammo (Change it From here if you need)
    70. new const szMaxBPAmmo[] =
    71. {
    72.     -1,
    73.     200,
    74.     -1,
    75.     200,
    76.     1,
    77.     200,
    78.     1,
    79.     200,
    80.     200,
    81.     1,
    82.     200,
    83.     200,
    84.     200,
    85.     200,
    86.     200,
    87.     200,
    88.     200,
    89.     200,
    90.     200,
    91.     200,
    92.     200,
    93.     200,
    94.     200,
    95.     200,
    96.     200,
    97.     2,
    98.     200,
    99.     200,
    100.         200,
    101.     -1,
    102.     200
    103. }
    104.  
    105. // Menu selections
    106. const MENU_KEY_AUTOSELECT = 7
    107. const MENU_KEY_BACK = 7
    108. const MENU_KEY_NEXT = 8
    109. const MENU_KEY_EXIT = 9
    110.  
    111. // Variables
    112. new Array:g_szPrimaryWeapons,
    113.     Array:g_szSecondaryWeapons
    114.  
    115. new g_iMenuData[33][4],
    116.     Float:g_fBuyTimeStart[33],
    117.     bool:g_bBoughtPrimary[33],
    118.     bool:g_bBoughtSecondary[33]
    119.  
    120. // Define
    121. #define WPN_STARTID g_iMenuData[id][0]
    122. #define WPN_MAXIDS ArraySize(g_szPrimaryWeapons)
    123. #define WPN_SELECTION (g_iMenuData[id][0]+key)
    124. #define WPN_AUTO_ON g_iMenuData[id][1]
    125. #define WPN_AUTO_PRI g_iMenuData[id][2]
    126. #define WPN_AUTO_SEC g_iMenuData[id][3]
    127.  
    128. // Cvars
    129. new g_pCvarBuyTime,
    130.     g_pCvarHEGrenade,
    131.     g_pCvarSmokeGrenade,
    132.     g_pCvarFlashGrenade
    133.    
    134. public plugin_natives()
    135. {
    136.     register_native("ze_show_weapon_menu", "native_ze_show_weapon_menu", 1)
    137.     register_native("ze_is_auto_buy_enabled", "native_ze_is_auto_buy_enabled", 1)
    138.     register_native("ze_disable_auto_buy", "native_ze_disable_auto_buy", 1)
    139. }
    140.  
    141. public plugin_precache()
    142. {
    143.     // Initialize arrays (32 is the max length of Weapon Entity like: weapon_ak47)
    144.     g_szPrimaryWeapons = ArrayCreate(32, 1)
    145.     g_szSecondaryWeapons = ArrayCreate(32, 1)
    146.    
    147.     // Load from external file
    148.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
    149.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
    150.    
    151.     // If we couldn't load from file, use and save default ones
    152.    
    153.     new iIndex
    154.    
    155.     if (ArraySize(g_szPrimaryWeapons) == 0)
    156.     {
    157.         for (iIndex = 0; iIndex < sizeof szPrimaryWeaponEnt; iIndex++)
    158.             ArrayPushString(g_szPrimaryWeapons, szPrimaryWeaponEnt[iIndex])
    159.        
    160.         // If not found .ini File Create it and save default values in it
    161.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
    162.     }
    163.    
    164.     if (ArraySize(g_szSecondaryWeapons) == 0)
    165.     {
    166.         for (iIndex = 0; iIndex < sizeof szSecondaryWeaponEnt; iIndex++)
    167.             ArrayPushString(g_szSecondaryWeapons, szSecondaryWeaponEnt[iIndex])
    168.        
    169.         // If not found .ini File Create it and save default values in it
    170.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
    171.     }
    172. }
    173.  
    174. public plugin_init()
    175. {
    176.     register_plugin("[ZE] Weapons Menu", ZE_VERSION, AUTHORS)
    177.    
    178.     // Commands
    179.     register_clcmd("guns", "Cmd_Buy")
    180.     register_clcmd("say /enable", "Cmd_Enable")
    181.     register_clcmd("say_team /enable", "Cmd_Enable")
    182.    
    183.     // Cvars
    184.     g_pCvarBuyTime = register_cvar("ze_buy_time", "600")
    185.     g_pCvarHEGrenade = register_cvar("ze_give_HE_nade", "1") // 0 Nothing || 1 Give HE
    186.     g_pCvarSmokeGrenade = register_cvar("ze_give_SM_nade", "1")
    187.     g_pCvarFlashGrenade = register_cvar("ze_give_FB_nade", "1")
    188.    
    189.     // Menus
    190.     register_menu("Primary Weapons", KEYSMENU, "Menu_Buy_Primary")
    191.     register_menu("Secondary Weapons", KEYSMENU, "Menu_Buy_Secondary")
    192. }
    193.  
    194. public client_disconnected(id)
    195. {
    196.     WPN_AUTO_ON = 0
    197.     WPN_STARTID = 0
    198. }
    199.  
    200. public Cmd_Enable(id)
    201. {
    202.     if (WPN_AUTO_ON)
    203.     {
    204.         ze_colored_print(id, "%L", LANG_PLAYER, "BUY_ENABLED")
    205.         WPN_AUTO_ON = 0
    206.     }
    207. }
    208.  
    209. public Cmd_Buy(id)
    210. {
    211.     // Player Zombie
    212.     if (ze_is_user_zombie(id))
    213.     {
    214.         ze_colored_print(id, "%L", LANG_PLAYER, "NO_BUY_ZOMBIE")
    215.         return
    216.     }
    217.    
    218.     // Player Dead
    219.     if (!is_user_alive(id))
    220.     {
    221.         ze_colored_print(id, "%L", LANG_PLAYER, "DEAD_CANT_BUY_WEAPON")
    222.         return
    223.     }
    224.    
    225.     // Already bought
    226.     if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
    227.     {
    228.         ze_colored_print(id, "%L", LANG_PLAYER, "ALREADY_BOUGHT")
    229.     }
    230.    
    231.     Show_Available_Buy_Menus(id)
    232. }
    233.  
    234. public ze_user_humanized(id)
    235. {
    236.     // Buyzone time starts when player is set to human
    237.     g_fBuyTimeStart[id] = get_gametime()
    238.    
    239.     g_bBoughtPrimary[id] = false
    240.     g_bBoughtSecondary[id] = false
    241.    
    242.     // Player dead or zombie
    243.     if (!is_user_alive(id) || ze_is_user_zombie(id))
    244.         return
    245.    
    246.     if (WPN_AUTO_ON)
    247.         ze_colored_print(id, "%L", LANG_PLAYER, "RE_ENABLE_MENU")
    248.        
    249.     if (WPN_AUTO_ON)
    250.     {
    251.         Buy_Primary_Weapon(id, WPN_AUTO_PRI)
    252.     }
    253.  
    254.     if (WPN_AUTO_ON)
    255.     {
    256.         Buy_Secondary_Weapon(id, WPN_AUTO_SEC)
    257.     }
    258.    
    259.     // Open available buy menus
    260.     Show_Available_Buy_Menus(id)
    261.    
    262.     // Give HE Grenade
    263.     if (get_pcvar_num(g_pCvarHEGrenade) != 0)
    264.         rg_give_item(id, "weapon_hegrenade")
    265.    
    266.     // Give Smoke Grenade
    267.     if (get_pcvar_num(g_pCvarSmokeGrenade) != 0)
    268.         rg_give_item(id, "weapon_smokegrenade")
    269.    
    270.     // Give Flashbang Grenade
    271.     if (get_pcvar_num(g_pCvarFlashGrenade) != 0)
    272.         rg_give_item(id, "weapon_flashbang")
    273. }
    274.  
    275. public Show_Available_Buy_Menus(id)
    276. {
    277.     // Already Bought
    278.     if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
    279.         return
    280.    
    281.     // Here we use if and else if so we make sure that Primary weapon come first then secondary
    282.     if (!g_bBoughtPrimary[id])
    283.     {
    284.         // Primary     
    285.         Show_Menu_Buy_Primary(id)
    286.     }
    287.     else if (!g_bBoughtSecondary[id])
    288.     {
    289.         // Secondary
    290.         Show_Menu_Buy_Secondary(id)
    291.     }
    292. }
    293.  
    294. public Show_Menu_Buy_Primary(id)
    295. {
    296.     new iMenuTime = floatround(g_fBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
    297.    
    298.     if (iMenuTime <= 0)
    299.     {
    300.         ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
    301.         return
    302.     }
    303.    
    304.     static szMenu[300], szWeaponName[32]
    305.     new iLen, iIndex, iMaxLoops = min(WPN_STARTID+7, WPN_MAXIDS)
    306.    
    307.     // Title
    308.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L ^n^n", id, "MENU_PRIMARY_TITLE", WPN_STARTID+1, min(WPN_STARTID+7, WPN_MAXIDS))
    309.    
    310.     // 1-7. Weapon List
    311.     for (iIndex = WPN_STARTID; iIndex < iMaxLoops; iIndex++)
    312.     {
    313.         ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
    314.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r%d.\w %s^n", iIndex-WPN_STARTID+1, szWeaponNames[get_weaponid(szWeaponName)])
    315.     }
    316.  
    317.     // 8. Auto Select
    318.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r8.\w %L \r%L", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "SAVE_YES" : "SAVE_NO")
    319.    
    320.     // 0. Exit
    321.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r0.\r %L", id, "EXIT")
    322.    
    323.     // Fix for AMXX custom menus
    324.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    325.     show_menu(id, KEYSMENU, szMenu, iMenuTime, "Primary Weapons")
    326. }
    327.  
    328. public Show_Menu_Buy_Secondary(id)
    329. {
    330.     new iMenuTime = floatround(g_fBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
    331.    
    332.     if (iMenuTime <= 0)
    333.     {
    334.         ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
    335.         return
    336.     }
    337.    
    338.     static szMenu[250], szWeaponName[32]
    339.     new iLen, iIndex, iMaxLoops = ArraySize(g_szSecondaryWeapons)
    340.    
    341.     // Title
    342.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L^n", id, "MENU_SECONDARY_TITLE")
    343.    
    344.     // 1-6. Weapon List
    345.     for (iIndex = 0; iIndex < iMaxLoops; iIndex++)
    346.     {
    347.         ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
    348.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r%d.\w %s", iIndex+1, szWeaponNames[get_weaponid(szWeaponName)])
    349.     }
    350.    
    351.     // 8. Auto Select
    352.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r8.\w %L \r%L", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "SAVE_YES" : "SAVE_NO")
    353.    
    354.     // 0. Exit
    355.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r0.\r %L", id, "EXIT")
    356.    
    357.     // Fix for AMXX custom menus
    358.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    359.     show_menu(id, KEYSMENU, szMenu, iMenuTime, "Secondary Weapons")
    360. }
    361.  
    362. public Menu_Buy_Primary(id, key)
    363. {
    364.     // Player dead or zombie or already bought primary
    365.     if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtPrimary[id])
    366.         return PLUGIN_HANDLED
    367.    
    368.     // Special keys / weapon list exceeded
    369.     if (key >= MENU_KEY_AUTOSELECT || WPN_SELECTION >= WPN_MAXIDS)
    370.     {
    371.         switch (key)
    372.         {
    373.             case MENU_KEY_AUTOSELECT: // toggle auto select
    374.             {
    375.                 WPN_AUTO_ON = 1 - WPN_AUTO_ON
    376.             }
    377.             case MENU_KEY_NEXT: // next/back
    378.             {
    379.                 if (WPN_STARTID+7 < WPN_MAXIDS)
    380.                     WPN_STARTID += 7
    381.                 else
    382.                     WPN_STARTID = 0
    383.             }
    384.             case MENU_KEY_EXIT: // exit
    385.             {
    386.                 return PLUGIN_HANDLED
    387.             }
    388.         }
    389.        
    390.         // Show buy menu again
    391.         Show_Menu_Buy_Primary(id)
    392.         return PLUGIN_HANDLED
    393.     }
    394.    
    395.     // Store selected weapon id
    396.     WPN_AUTO_PRI = WPN_SELECTION
    397.    
    398.     // Buy primary weapon
    399.     Buy_Primary_Weapon(id, WPN_AUTO_PRI)
    400.    
    401.     // Show Secondary Weapons
    402.     Show_Available_Buy_Menus(id)
    403.    
    404.     return PLUGIN_HANDLED
    405. }
    406.  
    407. public Buy_Primary_Weapon(id, selection)
    408. {
    409.     static szWeaponName[32]
    410.     ArrayGetString(g_szPrimaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
    411.     new iWeaponId = get_weaponid(szWeaponName)
    412.    
    413.     // Strip and Give Full Weapon
    414.     rg_give_item(id, szWeaponName, GT_REPLACE)
    415.     rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
    416.    
    417.     if (get_user_flags(id) & ADMIN_LEVEL_H)
    418.     {
    419.         ze_give_balrog(id)
    420.     }
    421.    
    422.     // Primary bought
    423.     g_bBoughtPrimary[id] = true
    424. }
    425.  
    426. public Menu_Buy_Secondary(id, key)
    427. {
    428.     // Player dead or zombie or already bought secondary
    429.     if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtSecondary[id])
    430.         return PLUGIN_HANDLED
    431.    
    432.     // Special keys / weapon list exceeded
    433.     if (key >= ArraySize(g_szSecondaryWeapons))
    434.     {
    435.         // Toggle autoselect
    436.         if (key == MENU_KEY_AUTOSELECT)
    437.             WPN_AUTO_ON = 1 - WPN_AUTO_ON
    438.        
    439.         // Reshow menu unless user exited
    440.         if (key != MENU_KEY_EXIT)
    441.             Show_Menu_Buy_Secondary(id)
    442.        
    443.         return PLUGIN_HANDLED
    444.     }
    445.    
    446.     // Store selected weapon id
    447.     WPN_AUTO_SEC = key
    448.    
    449.     // Buy secondary weapon
    450.     Buy_Secondary_Weapon(id, key)
    451.    
    452.     return PLUGIN_HANDLED
    453. }
    454.  
    455. public Buy_Secondary_Weapon(id, selection)
    456. {
    457.     static szWeaponName[32]
    458.     ArrayGetString(g_szSecondaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
    459.     new iWeaponId = get_weaponid(szWeaponName)
    460.    
    461.     // Strip and Give Full Weapon
    462.     rg_give_item(id, szWeaponName, GT_REPLACE)
    463.     rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
    464.    
    465.     // Secondary bought
    466.     g_bBoughtSecondary[id] = true
    467. }
    468.  
    469. // Natives
    470. public native_ze_show_weapon_menu(id)
    471. {
    472.     if (!is_user_connected(id))
    473.     {
    474.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    475.         return false
    476.     }
    477.    
    478.     Cmd_Buy(id)
    479.     return true
    480. }
    481.  
    482. public native_ze_is_auto_buy_enabled(id)
    483. {
    484.     if (!is_user_connected(id))
    485.     {
    486.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    487.         return -1;
    488.     }
    489.    
    490.     return WPN_AUTO_ON;
    491. }
    492.  
    493. public native_ze_disable_auto_buy(id)
    494. {
    495.     if (!is_user_connected(id))
    496.     {
    497.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    498.         return false
    499.     }
    500.    
    501.     WPN_AUTO_ON = 0;
    502.     return true
    503. }
If found any error in console, post it.
dont work raheem

Code: Select all

L 09/24/2018 - 21:12:22: [AMXX] Run time error 10 (plugin "ze_weapon_menu.amxx") (native "ze_give_balrog") - debug not enabled!
Image

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

#13

Post by Raheem » 5 years ago

Add debug and post results.
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 5 guests