Raised This Month: $ Target: $400
 0% 

Problem plugin


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
SuperrioR
Junior Member
Join Date: Sep 2019
Location: Republic of Moldova
Old 01-11-2020 , 15:07   Problem plugin
Reply With Quote #1

Hi, I have a problem compiling with a plugin.
I have added the necessary lines to be able to work with OciXCrom's cshop plugin and I have the problem.

{
if(itemid != ITEM_BALROG_ETHEREAL)
return

remove_balrog(id)
}

The problem on:
remove_balrog(id)

I tried with remove_item(id) but it doesn't work.


PHP Code:
/*================================================================================
 
            --------------------------------
            [ZP] Extra Item: Balrog Ethereal
            --------------------------------

        Balrog Ethereal
        Copyright (C) 2017 by Crazy

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

        * zp_balrog_ethereal_ammo <number> - Ammo amout.
        * zp_balrog_ethereal_clip <number> - Clip amout. (Max: 100)
        * zp_balrog_ethereal_one_round <0/1> - Only one round.
        * zp_balrog_ethereal_damage <number> - Damage multiplier.
        * zp_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.


=================================================================================*/

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>
#include <cs_ham_bots_api>
#include <customshop>

/*================================================================================
 [Plugin Customization]
=================================================================================*/

// Item Name
#define ITEM_NAME "Balrog Ethereal"

// Item Cost
#define ITEM_COST 70

additem ITEM_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_plague/v_balrog_ethereal.mdl";
new const 
P_BALROG_MDL[64] = "models/zombie_plague/p_balrog_ethereal.mdl";
new const 
W_BALROG_MDL[64] = "models/zombie_plague/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_spriteg_balrog_expg_balrogg_event_balrogg_playername[33][32], g_maxplayersg_primary_attackg_balrog_reload_clip[33], cvar_balrog_clipcvar_balrog_ammocvar_balrog_damagecvar_balrog_oneroundcvar_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("[ZP] Extra Item: Balrog Ethereal"PLUGIN_VERSION"Crazy");

    
/* Item register */
    
g_balrog zp_register_extra_item(ITEM_NAMEITEM_COSTZP_TEAM_HUMAN);

    
/* Events */
    
register_event("HLTV""event_round_start""a""1=0""2=0");

    
/* Messages */
    
register_message(get_user_msgid("CurWeapon"), "message_cur_weapon");

    
/* Admin command */
    
register_concmd("zp_give_balrog_ethereal""cmd_give_balrog"0);

    
/* 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");
    
RegisterHamBots(Ham_TakeDamage"fw_TakeDamage");

    
/* Cvars */
    
cvar_balrog_clip register_cvar("zp_balrog_minigun_clip""50");
    
cvar_balrog_ammo register_cvar("zp_balrog_minigun_ammo""200");
    
cvar_balrog_damage register_cvar("zp_balrog_minigun_damage""3.0");
    
cvar_balrog_oneround register_cvar("zp_balrog_minigun_one_round""0");
    
cvar_balrog_unlimited register_cvar("zp_balrog_minigun_unlimited""0");

    
/* Max Players */
    
g_maxplayers get_maxplayers()
}

public 
plugin_precache()
{
    
engfunc(EngFunc_PrecacheModelV_BALROG_MDL);
    
engfunc(EngFunc_PrecacheModelP_BALROG_MDL);
    
engfunc(EngFunc_PrecacheModelW_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 
0sizeof BALROG_SOUNDSi++)
    
engfunc(EngFunc_PrecacheSoundBALROG_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");
    
    
ITEM_BALROG_ETHEREAL cshop_register_item("balrog_ethereal""Balrog Ethereal"12000)
}

public 
cshop_item_selected(iditemid)
{
    if(
itemid != ITEM_BALROG_ETHEREAL)
        return
 
    
give_balrog(id)
}
 
public 
cshop_item_removed(iditemid)
{
    if(
itemid != ITEM_BALROG_ETHEREAL)
        return
 
    
remove_balrog(id)
}

public 
zp_user_infected_post(id)
{
    
g_has_balrog[id] = false;
}

public 
zp_user_humanized_post(id)
{
    
g_has_balrog[id] = false;
}

public 
client_putinserver(id)
{
    
g_has_balrog[id] = false;

    
get_user_name(idg_playername[id], charsmax(g_playername[]));
}

public 
event_round_start()
{
    for (new 
id 0id <= g_maxplayersid++)
    {
        if (
get_pcvar_num(cvar_balrog_oneround))
        
g_has_balrog[id] = false;
    }
}

public 
cmd_give_balrog(idlevelcid)
{
    if ((
get_user_flags(id) & level) != level)
        return 
PLUGIN_HANDLED;

    static 
arg[32], player;
    
read_argv(1argcharsmax(arg));
    
player cmd_target(idarg, (CMDTARGET_ONLY_ALIVE CMDTARGET_ALLOW_SELF));
    
    if (!
player)
        return 
PLUGIN_HANDLED;

    if (
g_has_balrog[player])
    {
        
client_print(idprint_chat"[ZP] The %s already have the %s."g_playername[player], ITEM_NAME);
        return 
PLUGIN_HANDLED;
    }

    
give_balrog(player);
    
    
client_print(playerprint_chat"[ZP] You won a %s from %s!"ITEM_NAMEg_playername[id]);

    return 
PLUGIN_HANDLED;
}

public 
cmd_balrog_selected(client)
{
    
engclient_cmd(client"weapon_ump45");
    return 
PLUGIN_HANDLED;
}

public 
message_cur_weapon(msg_idmsg_destmsg_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(entget_pcvar_num(cvar_balrog_clip));
        
set_msg_arg_int(3get_msg_argtype(3), get_pcvar_num(cvar_balrog_clip));
    }
}

public 
zp_extra_item_selected(iditemid)
{
    if (
itemid != g_balrog)
        return;

    if (
g_has_balrog[id])
    {
        
client_print(idprint_chat"[ZP] You already have the %s."ITEM_NAME);
        return;
    }

    
give_balrog(id);

    
client_print(idprint_chat"[ZP] You bought the %s."ITEM_NAME);
}

public 
fw_UpdateData_Post(idsendweaponscd_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_handleCD_flNextAttackhalflife_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(entpev_classnameclass_namecharsmax(class_name));

    if (!
equal(class_name"weaponbox"))
        return 
FMRES_IGNORED;

    static 
ownerweapon;
    
owner pev(entpev_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(weaponpev_impulseBALROG_KEY);

    
engfunc(EngFunc_SetModelentW_BALROG_MDL);

    return 
FMRES_SUPERCEDE;
}

public 
fw_PlaybackEvent(flagsinvokereventidFloat:delayFloat:origin[3], Float:angles[3], Float:fparam1Float:fparam2iParam1iParam2bParam1bParam2)
{
    if ((
eventid != g_event_balrog) || !g_primary_attack)
        return 
FMRES_IGNORED;

    if (!(
<= invoker <= g_maxplayers))
        return 
FMRES_IGNORED;

    
playback_event(flags FEV_HOSTONLYinvokereventiddelayoriginanglesfparam1fparam2iParam1iParam2bParam1bParam2);

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

    if (!
is_user_alive(id))
        return 
HAM_IGNORED;

    if (!
g_has_balrog[id])
        return 
HAM_IGNORED;

    
set_pev(idpev_viewmodel2V_BALROG_MDL);
    
set_pev(idpev_weaponmodel2P_BALROG_MDL);

    
play_weapon_anim(iddraw);

    return 
HAM_IGNORED;
}

public 
fw_Item_AddToPlayer_Post(entid)
{
    if (!
pev_valid(ent))
        return 
HAM_IGNORED;

    if (!
is_user_alive(id))
        return 
HAM_IGNORED;

    if (
pev(entpev_impulse) == BALROG_KEY)
    {
        
g_has_balrog[id] = true;
        
set_pev(entpev_impulse0);
    }

    
message_begin(MSG_ONEget_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(entOFFSET_WEAPON_OWNEROFFSET_LINUX_WEAPONS);

    if (!
is_user_alive(id))
        return 
HAM_IGNORED;

    if (!
g_has_balrog[id])
        return 
HAM_IGNORED;

    static 
cvar_clipcvar_clip get_pcvar_num(cvar_balrog_clip);

    new 
clip get_pdata_int(entm_iClipOFFSET_LINUX_WEAPONS);
    new 
bpammo cs_get_user_bpammo(idCSW_UMP45);

    new 
Float:flNextAttack get_pdata_float(idm_flNextAttackOFFSET_LINUX);
    new 
fInReload get_pdata_int(entm_fInReloadOFFSET_LINUX_WEAPONS);

    if (
fInReload && flNextAttack <= 0.0)
    {
        new 
temp_clip min(cvar_clip clipbpammo);

        
set_pdata_int(entm_iClipclip temp_clipOFFSET_LINUX_WEAPONS);

        
cs_set_user_bpammo(idCSW_UMP45bpammo-temp_clip);

        
set_pdata_int(entm_fInReload0OFFSET_LINUX_WEAPONS);

        
fInReload 0;
    }

    return 
HAM_IGNORED;
}

public 
fw_PrimaryAttack(ent)
{
    if (!
pev_valid(ent))
        return 
HAM_IGNORED;

    new 
id get_pdata_cbase(entOFFSET_WEAPON_OWNEROFFSET_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(entOFFSET_WEAPON_OWNEROFFSET_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(idrandom_num(shoot1shoot3));

    
emit_sound(idCHAN_WEAPONBALROG_SOUNDS[0], VOL_NORMATTN_NORM0PITCH_NORM);

    
make_laser_beam(id710000);

    return 
HAM_IGNORED;
}

public 
fw_Reload(ent)
{
    if (!
pev_valid(ent))
        return 
HAM_IGNORED;

    new 
id get_pdata_cbase(entOFFSET_WEAPON_OWNEROFFSET_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(entm_iClipOFFSET_LINUX_WEAPONS);
    new 
bpammo cs_get_user_bpammo(idCSW_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(entOFFSET_WEAPON_OWNEROFFSET_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(entm_iClipg_balrog_reload_clip[id], OFFSET_LINUX_WEAPONS);
    
set_pdata_int(entm_fInReload1OFFSET_LINUX_WEAPONS);

    
play_weapon_anim(idreload);

    return 
HAM_IGNORED;
}

public 
fw_TakeDamage(victiminflictorattackerFloat:damagedmg_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_WEAPONSdamage get_pcvar_float(cvar_balrog_damage));

    
make_explosion_effect(attacker);

    return 
HAM_IGNORED;
}

public 
fw_TraceAttack_Post(entattackerFloat:damageFloat:dir[3], ptrdmg_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(weaponget_pcvar_num(cvar_balrog_clip));
    
cs_set_user_bpammo(idCSW_UMP45get_pcvar_num(cvar_balrog_ammo));
}

play_weapon_anim(idframe)
{
    
set_pev(idpev_weaponanimframe);

    
message_begin(MSG_ONE_UNRELIABLESVC_WEAPONANIM, .player id)
    
write_byte(frame)
    
write_byte(pev(idpev_body))
    
message_end()
}

make_laser_beam(idSizeRGB
{
    static 
End[3];
    
get_user_origin(idEnd3);
    
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byte (TE_BEAMENTPOINT)
    
write_shortid |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(idend3);

    
message_begin(MSG_BROADCASTSVC_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(idweaponsnum);

    for (new 
0numi++)
    {
        if (
WEAPON_BITSUM & (1<<weapons[i]))
        {
            static 
wname[32];
            
get_weaponname(weapons[i], wnamesizeof 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_CreateNamedEntityengfunc(EngFunc_AllocStringitem));
    if (!
pev_valid(ent))
        return 
0;

    new 
Float:origin[3];
    
pev(indexpev_originorigin);
    
set_pev(entpev_originorigin);
    
set_pev(entpev_spawnflagspev(entpev_spawnflags) | SF_NORESPAWN);
    
dllfunc(DLLFunc_Spawnent);

    new 
save pev(entpev_solid);
    
dllfunc(DLLFunc_Touchentindex);
    if (
pev(entpev_solid) != save)
        return 
ent;

    
engfunc(EngFunc_RemoveEntityent);

    return -
1;
}

stock fm_cs_get_current_weapon_ent(id)
{
    if (
pev_valid(id) != 2)
        return -
1;
    
    return 
get_pdata_cbase(idOFFSET_ACTIVE_ITEMOFFSET_LINUX);


Last edited by SuperrioR; 01-11-2020 at 15:08.
SuperrioR is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:44.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode