será que alguém ai conseguiria arrumar esse plugin aqui para mim :)
Código:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <cstrike>
#include <zombieplague>
#include < xs >
#define SUPPORT_CZBOT
#if defined SUPPORT_CZBOT
new cvar_botquota
new bool:BotHasDebug = false
#endif
#define TASK_RESET_WEAPON 12345
const OFFSET_FlNextPrimaryAttack = 46
const OFFSET_LINUX_WEAPONS = 4
const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_DEAGLE)
new const Catapult_V_Model[] = { "models/v_ak.mdl" }
new const Catapult_P_Model[] = { "models/p_ak.mdl" }
new const Catapult_W_Model[] = { "models/w_ak.mdl" }
new const g_item_name[] = { "Catapult" }
new g_itemid_Catapult
new cvar_Catapult_cost, cvar_dmg_multiplier, cvar_knock_power, cvar_fire_rate, cvar_bullet_tracer
new g_beamSpr
new g_maxplayers
new bool:has_Catapult[33] = { false, ... }
new user_clip[33] = { 0, ... }, user_bpammo[33] = { 0, ... }
new user_drop[33] = { -1, ... }, Float:drop_time[33] = { 0.0, ... }
new bool:user_shoot[33] = { false, ... }
public plugin_init()
{
register_plugin("Catapult", "4.0", "DZ_MTv")
cvar_Catapult_cost = register_cvar("zp_lahumshi_cost", "12")
cvar_dmg_multiplier = register_cvar("zp_lahumshi_dmgmultiplier", "50")
cvar_knock_power = register_cvar("zp_lahumshi_knockpower", "50")
cvar_fire_rate = register_cvar("zp_lahumshi_firerate", "1")
g_itemid_Catapult = zp_register_extra_item(g_item_name, get_pcvar_num(cvar_Catapult_cost), ZP_TEAM_HUMAN)
RegisterHam(Ham_TakeDamage, "player", "fw_Player_TakeDamage")
RegisterHam(Ham_TraceAttack, "player", "fw_Player_TraceAttack")
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_deagle", "fw_deagle_PriAttack")
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_deagle", "fw_deagle_PriAttack_Post", 1)
register_forward(FM_SetModel, "fw_SetModel")
register_forward(FM_Touch, "fw_Touch")
register_event("CurWeapon", "event_cur_weapon", "be", "1=1")
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
g_maxplayers = get_maxplayers()
#if defined SUPPORT_CZBOT
cvar_botquota = get_cvar_pointer("bot_quota")
#endif
}
public plugin_precache()
{
precache_model(Catapult_V_Model)
precache_model(Catapult_P_Model)
precache_model(Catapult_W_Model)
g_beamSpr = precache_model("sprites/zbeam4.spr")
}
public zp_extra_item_selected (id, itemid)
{
if (itemid == g_itemid_Catapult)
{
if (has_Catapult[id] && user_has_weapon(id, CSW_DEAGLE))
{
zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + get_pcvar_num(cvar_Catapult_cost))
client_print(id, print_chat, "[rAz] Você Já tem")
return PLUGIN_CONTINUE;
}
user_drop_deagle(id)
has_Catapult[id] = true
fm_give_item(id, "weapon_deagle")
cs_set_user_bpammo(id, CSW_DEAGLE, 10)
engclient_cmd(id, "weapon_deagle")
client_print(id, print_chat, "[rAz] Você já Tem");
}
return PLUGIN_CONTINUE;
}
user_drop_deagle(id)
{
if (user_has_weapon(id, CSW_DEAGLE))
{
engclient_cmd(id, "drop", "weapon_deagle")
}
}
public fw_Player_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{
static Float:damage_multiplier
damage_multiplier = get_pcvar_float(cvar_dmg_multiplier)
if (damage_multiplier <= 0.0)
return HAM_IGNORED;
if (victim == attacker || !is_user_connected(attacker))
return HAM_IGNORED;
if (zp_get_user_zombie(victim) == zp_get_user_zombie(attacker))
return HAM_IGNORED;
if (!(damage_type & DMG_BULLET))
return HAM_IGNORED;
if (!has_Catapult[attacker] || (get_user_weapon(attacker) != CSW_DEAGLE))
return HAM_IGNORED;
SetHamParamFloat(4, damage * damage_multiplier)
return HAM_IGNORED;
}
public fw_Player_TraceAttack(victim, attacker, Float:damage, Float:direction[3], tracehandle, damage_type)
{
static Float:knockpower
knockpower = get_pcvar_float(cvar_knock_power)
if (knockpower <= 0.0)
return HAM_IGNORED;
if (victim == attacker || !is_user_connected(attacker))
return HAM_IGNORED;
if (zp_get_user_zombie(attacker) == zp_get_user_zombie(victim))
return HAM_IGNORED;
if (!zp_get_user_zombie(victim) || zp_get_user_nemesis(victim))
return HAM_IGNORED;
if (!(damage_type & DMG_BULLET) || !get_cvar_num("zp_knockback"))
return HAM_IGNORED;
if (!has_Catapult[attacker] || (get_user_weapon(attacker) != CSW_DEAGLE))
return HAM_IGNORED;
static victimflags, Float:knockduck
victimflags = pev(victim, pev_flags)
knockduck = get_cvar_float("zp_knockback_ducking")
if (knockduck == 0.0 && (victimflags & FL_DUCKING) && (victimflags & FL_ONGROUND))
return HAM_IGNORED;
static Float:origin1F[3], Float:origin2F[3]
pev(victim, pev_origin, origin1F)
pev(attacker, pev_origin, origin2F)
if (get_distance_f(origin1F, origin2F) > get_cvar_float("zp_knockback_distance"))
return HAM_IGNORED;
static Float:velocity[3]
pev(victim, pev_velocity, velocity)
if (get_cvar_num("zp_knockback_damage"))
xs_vec_mul_scalar(direction, damage, direction)
if (knockpower > 0.0 && get_cvar_num("zp_knockback_power"))
xs_vec_mul_scalar(direction, knockpower, direction)
if ((victimflags & FL_DUCKING) && (victimflags & FL_ONGROUND))
xs_vec_mul_scalar(direction, knockduck, direction)
xs_vec_add(velocity, direction, direction)
if (!get_cvar_num("zp_knockback_zvel"))
direction[2] = velocity[2]
set_pev(victim, pev_velocity, direction)
SetHamParamVector(4, Float:{0.0, 0.0, 0.0})
return HAM_IGNORED;
}
public fw_deagle_PriAttack(weapon)
{
if (!pev_valid(weapon))
return HAM_IGNORED;
static owner
owner = pev(weapon, pev_owner)
if (has_Catapult[owner])
{
if (cs_get_weapon_ammo(weapon) > 0)
{
user_shoot[owner] = true
}
}
return HAM_IGNORED;
}
public fw_deagle_PriAttack_Post(weapon)
{
if (!pev_valid(weapon))
return HAM_IGNORED;
static owner
owner = pev(weapon, pev_owner)
if (has_Catapult[owner])
{
if (user_shoot[owner])
{
static Float:fire_rate
fire_rate = get_pcvar_float(cvar_fire_rate)
if (fire_rate > 0.0)
{
static Float:next_pri_attack_time
next_pri_attack_time = get_weapon_next_pri_attack(weapon) * fire_rate
set_weapon_next_pri_attack(weapon, next_pri_attack_time)
}
if (get_pcvar_num(cvar_bullet_tracer))
{
static Float:origin1[3], Float:origin2[3] //, iOrigin[3]
fm_get_aim_vector(owner, 40, origin1, origin2)
origin1[2] += (pev(owner, pev_flags) & FL_DUCKING) ? 3.0 : -7.0
show_tracer_effect(origin1, origin2)
}
user_shoot[owner] = false
}
}
return HAM_IGNORED;
}
show_tracer_effect(const Float:start_point[3], const Float:end_point[3])
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_BEAMPOINTS) // TE id: 0
engfunc(EngFunc_WriteCoord, start_point[0]) // x
engfunc(EngFunc_WriteCoord, start_point[1]) // y
engfunc(EngFunc_WriteCoord, start_point[2]) // z
engfunc(EngFunc_WriteCoord, end_point[0]) // x
engfunc(EngFunc_WriteCoord, end_point[1]) // y
engfunc(EngFunc_WriteCoord, end_point[2]) // z
write_short(g_beamSpr) // sprite index
write_byte(0) // starting frame
write_byte(1) // frame rate in 0.1's
write_byte(1) // life in 0.1's
write_byte(30) // line width in 0.1's
write_byte(0) // noise amplitude in 0.01's
write_byte(0) // red (R.G.B)
write_byte(245) // green (R.G.B)
write_byte(255) // blue (R.G.B)
write_byte(255) // brightness
write_byte(0) // scroll speed in 0.1's
message_end()
}
public fw_SetModel(entity, const model[])
{
if (!pev_valid(entity))
return FMRES_IGNORED;
new owner
owner = pev(entity, pev_owner)
if (equal(model[7], "w_weaponbox.mdl"))
{
user_drop[owner] = entity;
return FMRES_IGNORED;
}
if (user_drop[owner] == entity)
{
if (has_Catapult[owner] && equal(model[7], "w_deagle.mdl"))
{
fm_kill_entity(entity)
if (!is_user_alive(owner) || zp_get_user_zombie(owner))
drop_Catapult(owner, 1, 0)
else
drop_Catapult(owner, 0, 1)
drop_time[owner] = get_gametime()
has_Catapult[owner] = false
}
}
user_drop[owner] = -1
return FMRES_IGNORED;
}
public fw_Touch(ptr, ptd)
{
if (!pev_valid(ptr) || !pev_valid(ptd))
return FMRES_IGNORED;
new classname[32]
pev(ptr, pev_classname, classname, charsmax(classname))
if (!equal(classname, "ZP_Catapult"))
return FMRES_IGNORED;
if (!(1 <= ptd <= 32) || !is_user_alive(ptd) || zp_get_user_zombie(ptd) || zp_get_user_survivor(ptd))
return FMRES_IGNORED;
if (has_custom_weapons(ptd, PRIMARY_WEAPONS_BIT_SUM))
return FMRES_IGNORED;
if (get_gametime() - drop_time[ptd] < 0.5)
return FMRES_IGNORED;
has_Catapult[ptd] = true
fm_give_item(ptd, "weapon_deagle")
static weap_clip, user_bpammo, weap_ent
weap_clip = pev(ptr, pev_iuser3)
user_bpammo = min(cs_get_user_bpammo(ptd, CSW_DEAGLE) + pev(ptr, pev_iuser4), 30)
weap_ent = fm_find_ent_by_owner(-1, "weapon_deagle", ptd)
cs_set_weapon_ammo(weap_ent, weap_clip)
cs_set_user_bpammo(ptd, CSW_DEAGLE, user_bpammo)
engfunc(EngFunc_RemoveEntity, ptr)
client_print(ptd, print_chat, "[rAz] Você Pegou")
return FMRES_IGNORED;
}
public event_cur_weapon(id)
{
if (!has_Catapult[id])
return;
new weap_id, weap_clip, weap_bpammo
weap_id = get_user_weapon(id, weap_clip, weap_bpammo)
if (weap_id != CSW_DEAGLE)
return;
set_Catapult_model(id)
user_clip[id] = weap_clip
user_bpammo[id] = weap_bpammo
user_shoot[id] = false
}
public set_Catapult_model(id)
{
set_pev(id, pev_viewmodel2, Catapult_V_Model)
set_pev(id, pev_weaponmodel2, Catapult_P_Model)
}
public drop_Catapult(id, store_bpammo, drop_type)
{
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
if (!pev_valid(ent))return 0;
set_pev(ent, pev_classname, "ZP_Catapult")
set_pev(ent, pev_iuser1, 0) // hasn't bounced yet
set_pev(ent, pev_solid, SOLID_TRIGGER)
set_pev(ent, pev_movetype, MOVETYPE_TOSS)
new Float:mins[3] = { -16.0, -16.0, -16.0 }
new Float:maxs[3] = { 16.0, 16.0, 16.0 }
engfunc(EngFunc_SetSize, ent, mins, maxs)
set_pev(ent, pev_iuser3, user_clip[id])
if (store_bpammo)
{
set_pev(ent, pev_iuser4, user_bpammo[id])
cs_set_user_bpammo(id, CSW_DEAGLE, 0)
}
else
{
set_pev(ent, pev_iuser4, 0)
}
new Float:angles[3]
pev(id, pev_angles, angles)
angles[0] = angles[2] = 0.0
set_pev(ent, pev_angles, angles)
engfunc(EngFunc_SetModel, ent, Catapult_W_Model)
new Float:origin[3]
pev(id, pev_origin, origin)
if (drop_type)
{
new Float:velocity[3]
velocity_by_aim(id, 15, velocity)
origin[0] += velocity[0]
origin[1] += velocity[1]
origin[2] += velocity[2]
set_pev(ent, pev_origin, origin)
velocity_by_aim(id, 400, velocity)
set_pev(ent, pev_velocity, velocity)
}
else
{
new Float:drop_angle = random_float(0.0, 360.0)
origin[0] += 15.0 * floatcos(drop_angle, degrees)
origin[1] += 15.0 * floatsin(drop_angle, degrees)
set_pev(ent, pev_origin, origin)
}
return 1;
}
public client_connect(id)
{
has_Catapult[id] = false
}
public client_disconnect(id)
{
has_Catapult[id] = false
}
public reset_Catapult()
{
for (new id = 1; id <= g_maxplayers; id++)
{
if (is_user_connected(id) && is_user_alive(id) && has_Catapult[id] && !user_has_weapon(id, CSW_DEAGLE))
{
has_Catapult[id] = false
}
}
}
stock drop_primary_weapons(id)
{
static weapons[32], num, i, weaponid
num = 0
get_user_weapons(id, weapons, num)
for (i = 0; i < num; i++)
{
weaponid = weapons[i]
if ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)
{
static wname[32]
get_weaponname(weaponid, 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 bool:has_custom_weapons(id, const bitsum)
{
static weapons[32], num, i, weaponid
num = 0
get_user_weapons(id, weapons, num)
for (i = 0; i < num; i++)
{
weaponid = weapons[i]
if ((1<<weaponid) & bitsum)
return true;
}
return false;
}
stock fm_find_ent_by_owner(entity, const classname[], owner)
{
while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && (pev(entity, pev_owner) != owner)) {}
return entity;
}
stock fm_find_ent_by_class(index, const classname[])
{
return engfunc(EngFunc_FindEntityByString, index, "classname", classname)
}
stock fm_kill_entity(index)
{
set_pev(index, pev_flags, pev(index, pev_flags) | FL_KILLME);
return 1;
}
stock Float:get_weapon_next_pri_attack(entity)
{
return get_pdata_float(entity, OFFSET_FlNextPrimaryAttack, OFFSET_LINUX_WEAPONS)
}
stock set_weapon_next_pri_attack(entity, Float:time)
{
set_pdata_float(entity, OFFSET_FlNextPrimaryAttack, time, OFFSET_LINUX_WEAPONS)
}
stock fm_get_aim_vector(index, forward_distance, Float:forward_origin[3], Float:view_end_origin[3])
{
new Float:start[3], Float:view_ofs[3]
pev(index, pev_origin, start);
pev(index, pev_view_ofs, view_ofs);
xs_vec_add(start, view_ofs, start);
new Float:vector[3], Float:temp[3];
pev(index, pev_v_angle, vector);
engfunc(EngFunc_MakeVectors, vector);
global_get(glb_v_forward, vector);
xs_vec_mul_scalar(vector, float(forward_distance), temp);
xs_vec_add(start, temp, forward_origin);
new Float:dest[3]
xs_vec_mul_scalar(vector, 9999.0, temp);
xs_vec_add(start, temp, dest);
engfunc(EngFunc_TraceLine, start, dest, 0, index, 0);
get_tr2(0, TR_vecEndPos, view_end_origin);
return 1;
}
#if defined SUPPORT_CZBOT
// CZBot support
public client_putinserver(id)
{
if (!cvar_botquota || !is_user_bot(id) || BotHasDebug)
return;
new classname[32]
pev(id, pev_classname, classname, 31)
if (!equal(classname, "player"))
set_task(0.1, "_Debug", id)
}
public _Debug(id)
{
// Make sure it's a CZ bot and it's still connected
if (!get_pcvar_num(cvar_botquota) || !is_user_connected(id))
return;
BotHasDebug = true
RegisterHamFromEntity(Ham_TakeDamage, id, "fw_Player_TakeDamage")
RegisterHamFromEntity(Ham_TraceAttack, id, "fw_Player_TraceAttack")
}
#endif