peter1513
|
分享:
▼
x0
|
[1.6][插件] SMA那裏錯?
#include <amxmodx> #include <fakemeta> #include <hamsandwich> #include <cstrike> #include <function>
#define PLUGIN "[CS]ExtraM249Veteran" #define VERSION "1.4" #define AUTHOR "Arwel"
#define OFFSET_LINUX_WEAPONS 4 #define OFFSET_LINUX 5
#define cv_num(%1) get_pcvar_num(%1) #define cv_fl(%1) get_pcvar_float(%1) #define get_money(%1) cs_get_user_money(%1) #define set_money(%1,%2) cs_set_user_money(%1,%2) #define pev_clip pev_iuser1 #define pev_bpammo pev_iuser2 #define pev_initialclip pev_iuser3 #define pev_finalclip pev_iuser4
#define pev_weaponkey pev_impulse #define weaponkey_value 2131241019
#define CSW_M249EP CSW_M249
#define KNIFE_DEATH_SPR //knife death sprite(comment for disable) #define BLOOD_SPRAY //enable/disable blood(comment for disable) #define KNOCKBAK 320.0 //knockback power(comment for disable)
#define DISTANCE 50.0 //distance #define NEXT_ATATCK 1.0 //next attack secondary attack #define ATTACK_DELAY 1.8 //attack delay
new const g_weapon_weaponbox_model[]="models/w_m249.mdl"
new const weapon_list_txt[]="weapon_m249ep_zp_cso"
new const weapon_list_sprites[][]= { "sprites/zp_cso/640hud81.spr", "sprites/zp_cso/640hud7.spr" }
new const ViewModel[]="models/zp_cso/v_m249ep.mdl" new const PlayerModel[]="models/zp_cso/p_m249ep.mdl" new const WorldModel[]="models/zp_cso/w_m249ep.mdl"
new const Sounds[][]= { "weapons/m249ep_hit1.wav", "weapons/m249ep_hit2.wav", "weapons/m249ep_shoot3.wav", "weapons/m249ep_shoot4.wav" }
new g_HasM249ep[33], Float:g_player_next_attack[33]
new g_itemid
new pcvar_bpammo
new pcvar_normal_damage_head, pcvar_normal_damage_chest, pcvar_normal_damage_stomach, pcvar_normal_damage_arms, pcvar_normal_damage_legs new pcvar_normal_damage
const WEAPONS_BIT_SUM=(1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(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_P90)
#if defined BLOOD_SPRAY
new Blood[2]
#endif
public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) register_clcmd("buy_M249Veteran", "weapon_buy") cvar_clip = register_cvar("M249Veteran_clip", "125") cvar_bpammo = register_cvar("M249Veteran_bpammo", "180") cvar_damage = register_cvar("M249Veteran_damage_multi", "50") cvar_firerate = register_cvar("M249Veteran_firerate", "1") cvar_reloadtime = register_cvar("M249Veteran_reloadtime", "4") cvar_cost = register_cvar("M249Veteran_cost", "5000") cvar_buyzone = register_cvar("M249Veteran_buyzone", "0") RegisterHam(Ham_TakeDamage, "player", "fw_takedamage") RegisterHam(Ham_Weapon_PrimaryAttack, wpn_class[CHANGE_WEAPON], "fw_priattack") RegisterHam(Ham_Weapon_PrimaryAttack, wpn_class[CHANGE_WEAPON], "fw_priattack_post", 1) RegisterHam(Ham_Weapon_Reload, wpn_class[CHANGE_WEAPON], "fw_weapon_reload_post", 1) if ((1<<CHANGE_WEAPON) & SHOTGUNS_BS) { RegisterHam(Ham_Weapon_WeaponIdle, wpn_class[CHANGE_WEAPON], "Shotgun_WeaponIdle") RegisterHam(Ham_Item_PostFrame, wpn_class[CHANGE_WEAPON], "Shotgun_PostFrame") } else RegisterHam(Ham_Item_PostFrame, wpn_class[CHANGE_WEAPON], "Item_PostFrame") register_forward(FM_SetModel, "fw_setmodel") register_forward(FM_Touch, "fw_touch") register_event("HLTV", "event_round_start", "a", "1=0", "2=0") register_event("CurWeapon","event_cur_weapon","be","1=1") register_message(get_user_msgid("DeathMsg"), "message_DeathMsg") }
public plugin_precache() { precache_model(ViewModel) precache_model(PlayerModel) precache_model(WorldModel) for(new i; i<=charsmax(Sounds); i++) precache_sound(Sounds)
new tmp[128] formatex(tmp, charsmax(tmp), "sprites/%s.txt", weapon_list_txt) precache_generic(tmp) for(new i; i<=charsmax(weapon_list_sprites); i++) precache_generic(weapon_list_sprites) #if defined BLOOD_SPRAY Blood[0]=precache_model("sprites/bloodspray.spr") Blood[1]=precache_model("sprites/blood.spr") #endif }
public CS_item_selected(id, itemid) { if(itemid!=g_itemid) return give_m249(id) }
public Redirect(id) client_cmd(id, "weapon_m249")
public client_disconnect(id) g_HasM249ep[id]=false
public zp_user_infected_post(id) g_HasM249ep[id]=false
public give_m249(id) { drop_weapons(id) g_HasM249ep[id]=true fm_give_item(id, "weapon_m249") cs_set_user_bpammo(id, CSW_M249EP, get_pcvar_num(pcvar_bpammo))
WeapList(id, weapon_list_txt) }
public fwCmdStart(id, uc) { if(!is_valid_player(id)) return if(get_user_weapon(id)!=CSW_M249EP) return if(g_player_next_attack[id]>get_gametime()) return if((get_uc(uc, UC_Buttons)&IN_ATTACK2)) { if(get_pdata_float(id, m_flNextAttack, 5)>=0.0) return g_player_next_attack[id]=get_gametime()+NEXT_ATATCK //next secondary attack new Float:Origin[3], Float:End[3], Float:Vec[3], Float:fraction, tr new bool:is_hul=false pev(id, pev_v_angle, Vec) pev(id, pev_origin, Origin) Origin[2]+=(pev(id, pev_flags) & FL_DUCKING)?12.0 : 17.0//weapon origin
angle_vector(Vec, ANGLEVECTOR_FORWARD, Vec)
xs_vec_mul_scalar(Vec, DISTANCE, End)//distance #if defined KNOCKBAK xs_vec_mul_scalar(Vec, KNOCKBAK, Vec)//knockback #endif xs_vec_add(Origin, End, End) engfunc(EngFunc_TraceLine, Origin, End, DONT_IGNORE_MONSTERS, id, tr) get_tr2(tr, TR_flFraction, fraction) if(fraction>=1.0)//if enemy is not found with TraceLine - make TraceHull { engfunc(EngFunc_TraceHull, Origin, End, DONT_IGNORE_MONSTERS, HULL_HEAD, id, tr) get_tr2(tr, TR_flFraction, fraction) is_hul=true } new ent=get_pdata_cbase(id, 373) //weapon ent if(fraction<1.0) { emit_sound(id, CHAN_WEAPON, Sounds[random_num(0, 1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM) playanim(id, 5) new victim=get_tr2(tr, TR_pHit) if(victim>0&&pev(victim, pev_takedamage)!=DAMAGE_NO&&pev(victim, pev_solid)!=SOLID_NOT) { new Float:Damage if(1<=victim<=32) { if(zp_get_user_zombie(victim)) { #if defined BLOOD_SPRAY get_tr2(tr, TR_vecEndPos, End) message_begin(MSG_BROADCAST, SVC_TEMPENTITY) write_byte(TE_BLOODSPRITE) engfunc(EngFunc_WriteCoord, End[0]) engfunc(EngFunc_WriteCoord, End[1]) engfunc(EngFunc_WriteCoord, End[2]) write_short(Blood[0]) write_short(Blood[1]) write_byte(76) write_byte(random_num(4,6)) message_end() #endif #if defined KNOCKBAK Vec[2]+=KNOCKBAK set_pev(victim, pev_velocity, Vec) #endif set_pdata_int(victim, m_LastHitGroup, HIT_GENERIC) //fix damage bug if(is_hul)//if TraceHull result, that does not work Hitgroup { Damage=get_pcvar_float(pcvar_normal_damage_stomach) } else { switch(get_tr2(tr, TR_iHitgroup)) { case HIT_HEAD: Damage=get_pcvar_float(pcvar_normal_damage_head) case HIT_CHEST: Damage=get_pcvar_float(pcvar_normal_damage_chest) case HIT_STOMACH: Damage=get_pcvar_float(pcvar_normal_damage_stomach) case HIT_LEFTARM: Damage=get_pcvar_float(pcvar_normal_damage_arms) case HIT_RIGHTARM: Damage=get_pcvar_float(pcvar_normal_damage_arms) case HIT_LEFTLEG: Damage=get_pcvar_float(pcvar_normal_damage_legs) case HIT_RIGHTLEG: Damage=get_pcvar_float(pcvar_normal_damage_legs) } } } } else { Damage=get_pcvar_float(pcvar_normal_damage) } ExecuteHamB(Ham_TakeDamage, victim, ent, id, Damage, DMG_BULLET|DMG_NEVERGIB) } } else { emit_sound(id, CHAN_WEAPON, Sounds[random_num(2, 3)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM) playanim(id, 6) } //attack delay(block reload, primary attack) set_pdata_float(ent, m_flNextPrimaryAttack, ATTACK_DELAY, OFFSET_LINUX_WEAPONS) set_pdata_float(ent, m_flTimeWeaponIdle, ATTACK_DELAY, OFFSET_LINUX_WEAPONS) } }
public fwSetModel(ent, model[]) { if(!pev_valid(ent)) return FMRES_IGNORED;
if(!equal(model, g_weapon_weaponbox_model)) return FMRES_IGNORED;
static classname[33] pev(ent, pev_classname, classname, charsmax(classname)) if(!equal(classname, "weaponbox")) return FMRES_IGNORED
static owner; owner=pev(ent, pev_owner) static weap;weap=fm_find_ent_by_owner(-1, "weapon_m249", ent) if(g_HasM249ep[owner]&&pev_valid(weap)) { set_pev(weap, pev_weaponkey, weaponkey_value) g_HasM249ep[owner]=false fm_entity_set_model(ent, WorldModel) return FMRES_SUPERCEDE } return FMRES_IGNORED }
public fwAddToPlayer(ent, id) { if(pev_valid(ent)) { if(pev(ent, pev_weaponkey)==weaponkey_value) { g_HasM249ep[id] = true set_pev(ent, pev_weaponkey, 0) WeapList(id, weapon_list_txt) return HAM_HANDLED } else WeapList(id, "weapon_m249") } return HAM_IGNORED }
public fwDeployPost(ent) { new id=fm_get_weapon_owner(ent)
if(!is_valid_player(id)) return set_pev(id, pev_viewmodel2, ViewModel) set_pev(id, pev_weaponmodel2, PlayerModel) g_player_next_attack[id]=get_gametime()+NEXT_ATATCK }
#if defined KNIFE_DEATH_SPR
public Message_DeathMsg(msg_id, msg_dest, id) { static weapon[33], attacker get_msg_arg_string(4, weapon, 32) attacker=get_msg_arg_int(1) if(!is_valid_player(attacker)||attacker ==get_msg_arg_int(2))//attacker==victim return
if(equal(weapon, "m249")) { if(g_player_next_attack[attacker]>get_gametime()) set_msg_arg_string(4, "knife") } }
#endif
public WeapList(id, const weapon[]) { message_begin( MSG_ONE, get_user_msgid("WeaponList"), .player=id ) write_string(weapon) write_byte(3) write_byte(200) write_byte(-1) write_byte(-1) write_byte(0) write_byte(4) write_byte(CSW_M249EP) write_byte(0) message_end() }
public is_valid_player(id) { if(!is_user_alive(id)) return false if(!g_HasM249ep[id]) return false
return true }
stock drop_weapons(id) { static weapons[32], num, i static wname[32] num=0 get_user_weapons(id, weapons, num) for(i = 0; i < num; i++) { if(((1<<weapons) & WEAPONS_BIT_SUM)) { get_weaponname(weapons, wname, wname - 1) engclient_cmd(id, "drop", wname) } } }
stock playanim(player,anim) { set_pev(player, pev_weaponanim, anim) message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, player) write_byte(anim) write_byte(pev(player, pev_body)) message_end() }
stock fm_get_weapon_owner(weapon) return get_pdata_cbase(weapon, 41, 4)
|