Post by ShaunCraft15 on Dec 19, 2022 17:18:38 GMT
This plugin is not same 100% but it has same special shoot system
Sorry for my bad english
Credits:
CrazY: For Violingun code
You Can use this plugin for your server
The Plugin has violingun experiences (cmd give to any player)
Again it's not 100% Like gc but still good
enjoy :-)
#include < amxmodx >
#include < amxmisc >
#include < engine >
#include < cstrike >
#include < fakemeta >
#include < hamsandwich >
#include < zp50_items >
#include < zp50_colorchat >
#include < zp50_grenade_fire >
#define ITEM_NAME "[GC] Balrog XI"
#define ITEM_COST 35
//Note: I use violingun code to do the plugin (Credits: CrazY)
new const VERSION[] = "1.0";
new g_clipammo[33], g_has_balrog[33], g_itemid, g_hamczbots, g_event_balrog11, g_primaryattack, cvar_balrog11_damage_x, cvar_balrog11_oneround, cvar_burn_time, cvar_delay, cvar_botquota;
new g_has_special_shoot[33], g_special_shoot_access[33], g_reload[33]
// Special Shoot Cvars
new cvar_special_damage, cvar_special_access, cvar_special_stop, cvar_special_speed
new g_sModelIndexLaser
// Tasks
const BALROG_FIRE_TASK = 5312;
new const SHOT_SOUND[][] = { "weapons/xm1014-1.wav" }
new const SPECIAL_SHOOT_SOUND[][] = { "weapons/m3-1.wav" }
new const V_BALROG_MDL[64] = "models/zombie_plague/v_balrog11.mdl";
new const P_BALROG_MDL[64] = "models/zombie_plague/p_balrog11.mdl";
new const W_BALROG_MDL[64] = "models/zombie_plague/w_balrog11.mdl";
const m_pActiveItem = 373;
new const GUNSHOT_DECALS[] = {41, 42, 43, 44, 45}
public plugin_init()
{
// Plugin Register
register_plugin("[GC] Balrog11", VERSION, "ShaunCraft");
// Extra Item Register
g_itemid = zp_items_register(ITEM_NAME, ITEM_COST);
// Cvars Register
cvar_balrog11_damage_x = register_cvar("zp_balrog11_damage_x", "1.35");
cvar_balrog11_oneround = register_cvar("zp_balrog11_oneround", "1");
cvar_burn_time = register_cvar("zp_balrog11_burn_time", "1.2")
cvar_delay = register_cvar("zp_balrog11_burn_delay", "7")
cvar_special_damage = register_cvar("zp_balrog11_special_dmg_x", "3.2")
cvar_special_access = register_cvar("zp_balrog11_return_access", "30.0")
cvar_special_stop = register_cvar("zp_balrog11_special_stop", "8.0")
cvar_special_speed = register_cvar("zp_balrog11_special_speed", "0.95")
// Cvar Pointer
cvar_botquota = get_cvar_pointer("bot_quota");
// Admin command
register_concmd("amx_give_balrog11", "cmd_give_balrog11", 0);
/* Messages */
register_message(get_user_msgid("CurWeapon"), "message_cur_weapon");
// Events
register_event("HLTV", "event_round_start", "a", "1=0", "2=0");
// Forwards
register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1);
register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1)
register_forward(FM_PlaybackEvent, "fw_PlaybackEvent");
register_forward(FM_SetModel, "Fakemeta_SetModel_Pre");
register_forward(FM_CmdStart, "fw_CmdStart");
// HAM Forwards
RegisterHam(Ham_Item_PostFrame, "weapon_galil", "fw_ItemPostFrame");
RegisterHam(Ham_TraceAttack, "player", "CBaseEntity_TraceAttack_Post", 1);
RegisterHam(Ham_TraceAttack, "worldspawn", "CBaseEntity_TraceAttack_Post", 1);
RegisterHam(Ham_TraceAttack, "func_wall", "CBaseEntity_TraceAttack_Post", 1);
RegisterHam(Ham_TraceAttack, "func_breakable", "CBaseEntity_TraceAttack_Post", 1);
RegisterHam(Ham_TraceAttack, "func_door", "CBaseEntity_TraceAttack_Post", 1);
RegisterHam(Ham_TraceAttack, "func_door_rotating", "CBaseEntity_TraceAttack_Post", 1);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_xm1014", "fw_PrimaryAttack");
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_xm1014", "fw_PrimaryAttack_Post", 1);
RegisterHam(Ham_Weapon_Reload, "weapon_xm1014", "fw_Reload_Post", 1)
RegisterHam(Ham_Weapon_Reload, "weapon_xm1014", "fw_Reload")
RegisterHam(Ham_Item_Deploy, "weapon_xm1014", "fw_ItemDeploy_Post", 1);
RegisterHam(Ham_TakeDamage, "player", "CBasePlayer_TakeDamage_Pre");
RegisterHam(Ham_TakeDamage, "player", "CBasePlayer_TakeDamage_Post", 1);
RegisterHam(Ham_Item_AddToPlayer, "weapon_xm1014", "fw_AddToPlayer");
}
public plugin_precache()
{
precache_model(V_BALROG_MDL);
precache_model(P_BALROG_MDL);
precache_model(W_BALROG_MDL);
g_sModelIndexLaser = precache_model("sprites/dot.spr");
for(new i = 0; i < sizeof SHOT_SOUND; i++) precache_sound(SHOT_SOUND[i]);
for(new i = 0; i < sizeof SPECIAL_SHOOT_SOUND; i++) precache_sound(SPECIAL_SHOOT_SOUND[i]);
}
public client_disconnect(id)
{
g_has_balrog[id] = false;
}
public client_connect(id)
{
g_has_balrog[id] = false;
}
public zp_fw_core_infect_post(id)
{
g_has_balrog[id] = false;
}
public zp_fw_core_cure_post(id)
{
g_has_balrog[id] = false;
}
public client_putinserver(id)
{
g_has_balrog[id] = false;
if (is_user_bot(id) && !g_hamczbots && cvar_botquota)
{
set_task(0.1, "register_ham_czbots", id);
}
}
public fw_CmdStart(id, uc_handle, seed)
{
if(!is_user_alive(id))
return
if(get_user_weapon(id) != CSW_XM1014 || !g_has_balrog[id])
return
static NewButton; NewButton = get_uc(uc_handle, UC_Buttons)
if(g_reload[id])
return
if(NewButton & IN_ATTACK2)
{
if(!g_special_shoot_access[id])
{
if(!g_has_special_shoot[id])
{
g_has_special_shoot[id] = true
zp_colored_print(id, "You Activated Special Shoot")
set_task(get_pcvar_float(cvar_special_stop), "StopSpecialShoot", id)
}
g_special_shoot_access[id] = true
set_task(get_pcvar_float(cvar_special_access), "ReturnSpecialShootAccess", id)
}
}
}
public StopSpecialShoot(id)
{
g_has_special_shoot[id] = false
zp_colored_print(id, "Special Shoot Stopped")
}
public ReturnSpecialShootAccess(id)
{
zp_colored_print(id, "Special Shoot ability return tap ^4Right Click ^1To Activate it")
g_special_shoot_access[id] = false
}
public event_round_start()
{
if(!get_pcvar_num(cvar_balrog11_oneround))
return
new rgPlayers[32], iPlayersCount, pPlayer, pActiveItem;
get_players(rgPlayers, iPlayersCount);
for (new i = 0; i < iPlayersCount; i++)
{
pPlayer = rgPlayers[i];
if (!g_has_balrog[pPlayer])
continue;
g_has_balrog[pPlayer] = false
pActiveItem = get_pdata_cbase(pPlayer, m_pActiveItem);
if (pActiveItem == -1)
continue;
if (cs_get_weapon_id(pActiveItem) != CSW_M4A1)
continue;
entity_set_string(pPlayer, EV_SZ_viewmodel, "models/v_m4a1.mdl");
entity_set_string(pPlayer, EV_SZ_weaponmodel, "models/p_m4a1.mdl");
}
}
public register_ham_czbots(id)
{
if (g_hamczbots || !is_user_bot(id) || !get_pcvar_num(cvar_botquota))
return;
RegisterHamFromEntity(Ham_TakeDamage, id, "fw_TakeDamage");
g_hamczbots = true;
}
public zp_fw_items_select_pre(id, itemid)
{
if(itemid != g_itemid) return ZP_ITEM_AVAILABLE;
if(zp_core_is_zombie(id)) return ZP_ITEM_DONT_SHOW;
if(g_has_balrog[id])
{
zp_items_menu_text_add("\r[Buyed]")
return ZP_ITEM_NOT_AVAILABLE;
}
return ZP_ITEM_AVAILABLE;
}
public zp_fw_items_select_post(player, itemid)
{
if(itemid != g_itemid)
return;
command_give_balrog11(player);
}
public cmd_give_balrog11(id, level, cid)
{
if((get_user_flags(id) & level) != level)
{
return PLUGIN_HANDLED;
}
static arg[32], player;
read_argv(1, arg, charsmax(arg));
player = cmd_target(id, arg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF));
if (!player) return PLUGIN_HANDLED;
client_print(player, print_chat, "[ZP] You won a %s.", ITEM_NAME);
command_give_balrog11(player);
return PLUGIN_HANDLED;
}
public command_give_balrog11(player)
{
g_has_balrog[player] = true;
give_item(player, "weapon_xm1014");
cs_set_user_bpammo(player, CSW_XM1014, 32);
}
public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
{
if (is_user_alive(id) && get_user_weapon(id) == CSW_XM1014 && g_has_balrog[id])
{
set_cd(cd_handle, CD_flNextAttack, halflife_time () + 0.001);
}
}
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_XM1014)
return;
if (get_msg_arg_int(1) != 1)
return;
if (g_has_special_shoot[msg_entity])
{
static ent;
ent = fm_cs_get_current_weapon_ent(msg_entity);
if (!pev_valid(ent))
return;
cs_set_weapon_ammo(ent, 7);
set_msg_arg_int(3, get_msg_argtype(3), 7);
}
}
public fw_PrecacheEvent_Post(type, const name[])
{
if (equal("events/galil.sc", name))
{
g_event_balrog11 = get_orig_retval()
return FMRES_HANDLED;
}
return FMRES_IGNORED;
}
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_balrog11) || !g_primaryattack)
return FMRES_IGNORED;
if (!(1 <= invoker <= get_maxplayers()))
return FMRES_IGNORED;
playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2);
return FMRES_SUPERCEDE;
}
public Fakemeta_SetModel_Pre(this, const szModel[])
{
if(!pev_valid(this) || !equal(szModel, "models/w_xm1014.mdl")) return FMRES_IGNORED;
new pevWeapon = find_ent_by_owner(-1, "weapon_xm1014", this);
if (pevWeapon == 0)
return FMRES_IGNORED;
new pevOwner = entity_get_edict(this, EV_ENT_owner);
if (!g_has_balrog[pevOwner])
return FMRES_IGNORED;
entity_set_int(pevWeapon, EV_INT_impulse, 394);
entity_set_model(this, W_BALROG_MDL);
g_has_balrog[pevOwner] = false;
return FMRES_SUPERCEDE;
}
public fw_AddToPlayer(this, pevPlayer)
{
if (entity_get_int(this, EV_INT_impulse) != 394)
return HAM_IGNORED;
entity_set_int(this, EV_INT_impulse, 0);
g_has_balrog[pevPlayer] = true;
return HAM_IGNORED;
}
public fw_ItemPostFrame(weapon_entity)
{
new id = pev(weapon_entity, pev_owner);
if(!g_has_balrog[id] || !is_user_connected(id) || !pev_valid(weapon_entity))
return HAM_IGNORED;
static iClipExtra; iClipExtra = 7;
new Float:flNextAttack = get_pdata_float(id, 83, 5);
new iBpAmmo = cs_get_user_bpammo(id, CSW_XM1014);
new iClip = get_pdata_int(weapon_entity, 51, 4);
new fInReload = get_pdata_int(weapon_entity, 54, 4);
if(fInReload && flNextAttack <= 0.0)
{
new Clp = min(iClipExtra - iClip, iBpAmmo);
set_pdata_int(weapon_entity, 51, iClip + Clp, 4);
cs_set_user_bpammo(id, CSW_XM1014, iBpAmmo-Clp);
set_pdata_int(weapon_entity, 54, 0, 4);
fInReload = 0;
return HAM_SUPERCEDE;
}
return HAM_IGNORED;
}
public CBaseEntity_TraceAttack_Post(this, pevAttacker, Float:flDamage, Float:vecDir[3], tr)
{
if (this == pevAttacker)
return;
if (!is_user_alive(pevAttacker))
return;
if (get_user_weapon(pevAttacker) != CSW_XM1014)
return;
if (!g_has_balrog[pevAttacker])
return;
new Float:vecEndPos[3];
get_tr2(tr, TR_vecEndPos, vecEndPos);
new r, g, b, width, idk
if(g_has_special_shoot[pevAttacker])
{
r = 220
g = 88
b = 0
width = 30
idk = 6
}
else
{
r = 255
g = 10
b = 10
width = 5
idk = 0
}
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
{
write_byte(TE_BEAMENTPOINT);
write_short(pevAttacker | 0x1000);
engfunc(EngFunc_WriteCoord, vecEndPos[0]);
engfunc(EngFunc_WriteCoord, vecEndPos[1]);
engfunc(EngFunc_WriteCoord, vecEndPos[2]);
write_short(g_sModelIndexLaser);
write_byte(0);
write_byte(0);
write_byte(1);
write_byte(width);
write_byte(idk);
write_byte(r)
write_byte(g)
write_byte(b)
write_byte(200);
write_byte(0);
}
message_end();
if (is_user_alive(pevAttacker) && get_user_weapon(pevAttacker) == CSW_XM1014 && g_has_balrog[pevAttacker])
{
static Float:flEnd[3]
get_tr2(tr, TR_vecEndPos, flEnd)
if(this)
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_DECAL)
engfunc(EngFunc_WriteCoord, flEnd[0])
engfunc(EngFunc_WriteCoord, flEnd[1])
engfunc(EngFunc_WriteCoord, flEnd[2])
write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
write_short(this)
message_end()
} else {
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_WORLDDECAL)
engfunc(EngFunc_WriteCoord, flEnd[0])
engfunc(EngFunc_WriteCoord, flEnd[1])
engfunc(EngFunc_WriteCoord, flEnd[2])
write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
message_end()
}
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_GUNSHOTDECAL)
engfunc(EngFunc_WriteCoord, flEnd[0])
engfunc(EngFunc_WriteCoord, flEnd[1])
engfunc(EngFunc_WriteCoord, flEnd[2])
write_short(pevAttacker)
write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
message_end()
}
}
public fw_PrimaryAttack(weapon_entity)
{
new id = get_pdata_cbase(weapon_entity, 41, 4);
if (g_has_balrog[id])
{
g_clipammo[id] = cs_get_weapon_ammo(weapon_entity);
g_primaryattack = 1;
}
}
public fw_Reload(ent)
{
new id = get_pdata_cbase(ent, 41, 4);
g_reload[id] = true
}
public fw_Reload_Post(ent)
{
new id = get_pdata_cbase(ent, 41, 4);
g_reload[id] = false
}
public fw_PrimaryAttack_Post(weapon_entity)
{
new id = get_pdata_cbase(weapon_entity, 41, 4);
if (g_has_balrog[id] && g_clipammo[id])
{
g_primaryattack = 0;
if(g_has_special_shoot[id])
{
set_pdata_float(weapon_entity, 46, get_pcvar_float(cvar_special_speed), 4);
emit_sound(id, CHAN_WEAPON, SPECIAL_SHOOT_SOUND[random_num(0, sizeof SHOT_SOUND - 1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
UTIL_PlayWeaponAnimation(id, 6);
}
else
{
emit_sound(id, CHAN_WEAPON, SHOT_SOUND[random_num(0, sizeof SHOT_SOUND - 1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
UTIL_PlayWeaponAnimation(id, random_num(1, 2));
}
}
}
public fw_ItemDeploy_Post(weapon_entity)
{
static id; id = get_weapon_ent_owner(weapon_entity);
if (pev_valid(id) && g_has_balrog[id])
{
set_pev(id, pev_viewmodel2, V_BALROG_MDL);
set_pev(id, pev_weaponmodel2, P_BALROG_MDL);
}
}
public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
{
if(is_user_alive(attacker) && get_user_weapon(attacker) == CSW_XM1014 && g_has_balrog[attacker])
{
if(g_has_special_shoot[attacker])
{
SetHamParamFloat(4, damage * get_pcvar_float(cvar_special_damage));
}
else SetHamParamFloat(4, damage * get_pcvar_float(cvar_balrog11_damage_x));
}
}
public CBasePlayer_TakeDamage_Pre(this, pevInflictor, pevAttacker, Float:flDamage)
{
if (this == pevAttacker)
return HAM_IGNORED;
if (!is_user_alive(pevAttacker))
return HAM_IGNORED;
new iWeaponId;
get_user_attacker(this, iWeaponId);
if (iWeaponId != CSW_XM1014)
return HAM_IGNORED;
if (!g_has_balrog[pevAttacker])
return HAM_IGNORED;
if(g_has_special_shoot[pevAttacker])
{
SetHamParamFloat(4, flDamage * get_pcvar_float(cvar_special_damage));
}
else SetHamParamFloat(4, flDamage * get_pcvar_float(cvar_balrog11_damage_x));
return HAM_IGNORED;
}
public CBasePlayer_TakeDamage_Post(this, pevInflictor, pevAttacker)
{
if (this == pevAttacker)
return;
if (!is_user_alive(this) || !zp_core_is_zombie(this))
return;
if (!is_user_alive(pevAttacker))
return;
new iWeaponId;
get_user_attacker(this, iWeaponId);
if (iWeaponId != CSW_XM1014)
return;
if (!g_has_balrog[pevAttacker])
return;
if (task_exists(this+BALROG_FIRE_TASK))
return;
if(zp_grenade_fire_get(this))
return;
set_task(get_pcvar_float(cvar_delay), "TaskBurn", this+BALROG_FIRE_TASK);
zp_grenade_fire_set(this, true)
set_task(get_pcvar_float(cvar_burn_time), "StopFire", this)
}
public TaskBurn(taskid)
{
/* There is nothing to do here */
}
public StopFire(this) zp_grenade_fire_set(this, false)
stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
{
set_pev(Player, pev_weaponanim, Sequence)
message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
write_byte(Sequence)
write_byte(pev(Player, pev_body))
message_end()
}
stock get_weapon_ent_owner(ent)
{
return get_pdata_cbase(ent, 41, 4);
}
stock 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, 373, 5);
}