jlbsky
|
分享:
▼
x0
|
[1.6][插件] ZP仿CSO喋血插件問題
小弟有個喋血插件,有個問題,就是按E換雙槍動作有問題,雙槍形態射擊動作也有問題,能否請哪位大神幫小弟解決下,源碼如下
#include <amxmodx> #include <engine> #include <fakemeta> #include <cstrike> #include <hamsandwich> #include <fun> #include <zombieplague>
#define WEAP_LINUX_XTRA_OFF 4 #define m_fKnown 44 #define m_flNextPrimaryAttack 46 #define m_flTimeWeaponIdle 48 #define m_iClip 51 #define m_fInReload 54 #define PLAYER_LINUX_XTRA_OFF 5 #define m_flNextAttack 83 #define m_flTimeweaponIdle 48 const PRIMARY_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) new const v_model[] = "models/ZB5/v_skull3.mdl" new const p_model[] = "models/ZB5/p_skull3.mdl" new const p_model_2[] = "models/ZB5/p_skull3_dual.mdl" new const w_model[] = "models/ZB5/w_skull3.mdl"
new const sk3_sound[5][] = { "weapons/skull3-1.wav", "weapons/skull3_boltpull.wav", "weapons/skull3_clipin.wav", "weapons/skull3_clipout.wav", "weapons/skull3_idle.wav" }
#define CSW_SK3 CSW_UMP45 #define MAX_PLAYERS 32 new g_clip_ammo[33], g_IsInPrimaryAttack, Float:cl_pushangle[MAX_PLAYERS + 1][3], g_TmpClip[33], Float:g_zoom_time[33], g_zoomed[33], g_mode[33], g_change[33], Float:g_change_time[33], g_reload[33], g_oldweap[33], Float:g_lastshoot[33] new g_had_sk3[33], g_sk3, g_orig_event_sk3, g_MaxPlayers new cvar_dmg_mode1, cvar_dmg_mode2, cvar_speed_mode1, cvar_speed_mode2, cvar_clip_mode1, cvar_clip_mode2, cvar_ammo, cvar_speed_zoom, cvar_reload_time_mode1, cvar_reload_time_mode2 public plugin_init() { register_plugin("[ZP50] Extra Weapon: Skull3", "1.0", "MiXeP or @BlauPUnkT BaSS") register_event("CurWeapon", "event_curweapon", "be", "1=1") register_forward(FM_CmdStart, "fw_cmdstart") register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1) register_forward(FM_SetModel, "fw_SetModel") RegisterHam(Ham_TakeDamage, "player", "fw_takedmg") RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "ham_priattack", 1) RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "ham_priattack2", 1) RegisterHam(Ham_Item_AddToPlayer, "weapon_ump45", "fw_item_addtoplayer", 1) register_forward(FM_PlaybackEvent, "fwPlaybackEvent") RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "Reload") RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "Reload_Post", 1) RegisterHam(Ham_Item_PostFrame, "weapon_ump45", "fw_skull3_itempostframe"); RegisterHam(Ham_Weapon_WeaponIdle,"weapon_ump45","fw_knifeidleanim") cvar_dmg_mode1 = register_cvar("zp_sk3_dmg1", "1.600") // Damage mode1 cvar_dmg_mode2 = register_cvar("zp_sk3_dmg2", "2.200") // Damage mode2 cvar_speed_mode1 = register_cvar("zp_sk3_speed1", "1.0") // Speed mode1 cvar_speed_mode2 = register_cvar("zp_sk3_speed2", "0.8") // Speed mode2 cvar_speed_zoom = register_cvar("zp_sk3_speed_zoom", "1.4") // Speed Zoom Mode cvar_clip_mode1 = register_cvar("zp_sk3_clip", "35") // Clip Ammo mode1 cvar_clip_mode2 = register_cvar("zp_sk3_clip2", "70") // Clip Ammo mode2 cvar_ammo = register_cvar("zp_sk3_ammo", "120") // BP Ammo cvar_reload_time_mode1 = register_cvar("zp_sk3_reload1", "2.4") // Reload Time mode1 cvar_reload_time_mode2 = register_cvar("zp_sk3_reload2", "3.0") // Reload Time mode2 g_sk3 = zp_register_extra_item("喋血Skull3强化版", 70, ZP_TEAM_HUMAN) g_MaxPlayers = get_maxplayers() }
public plugin_precache() { precache_model(v_model) precache_model(p_model) precache_model(p_model_2) precache_model(w_model) for(new i = 0; i < sizeof(sk3_sound); i++) precache_sound(sk3_sound) register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1) }
public zp_extra_item_selected(id, itemid) { if(itemid != g_sk3) return PLUGIN_HANDLED drop_weapons(id, 1); g_had_sk3[id] = 1 new ent = give_item(id, "weapon_ump45") cs_set_weapon_ammo(ent, get_pcvar_num(cvar_clip_mode1)) cs_set_user_bpammo(id, CSW_SK3, get_pcvar_num(cvar_ammo)) remove_task(id) g_reload[id] = 0 g_change[id] = 0 g_mode[id] = 0
if(g_zoomed[id]) { cs_set_user_zoom(id, CS_RESET_ZOOM, 1) g_zoomed[id] = 0 } if(g_oldweap[id] == CSW_UMP45) { replace_weapon_models(id, CSW_UMP45) if(g_mode[id]) set_weapon_anim(id, 15) else set_weapon_anim(id, 2) set_pdata_float(id, m_flNextAttack, 1.0 , PLAYER_LINUX_XTRA_OFF) } return PLUGIN_CONTINUE }
public event_curweapon(id) { replace_weapon_models(id, read_data(2))
if(read_data(2) != CSW_SK3 || !g_had_sk3[id]) return
static Float:iSpeed if(g_mode[id]) iSpeed = get_pcvar_float(cvar_speed_mode2) else iSpeed = get_pcvar_float(cvar_speed_mode1) if(g_zoomed[id]) { iSpeed = get_pcvar_float(cvar_speed_zoom) } static weapon[32],Ent get_weaponname(read_data(2),weapon,31) Ent = find_ent_by_owner(-1,weapon,id) if(Ent) { static Float:Delay, Float:M_Delay Delay = get_pdata_float( Ent, 46, 4) * iSpeed M_Delay = get_pdata_float( Ent, 47, 4) * iSpeed if (Delay > 0.0) { set_pdata_float(Ent, 46, Delay, 4) set_pdata_float(Ent, 47, M_Delay, 4) } } }
public replace_weapon_models(id, weaponid) { if(!is_user_alive(id)) return;
if(zp_get_user_zombie(id)) return;
if(!g_had_sk3[id]) return;
if(weaponid == CSW_UMP45) { set_pev(id, pev_viewmodel2, v_model) set_pev(id, pev_weaponmodel2, g_mode[id] ? p_model_2:p_model)
if(g_oldweap[id] != CSW_UMP45) { if(!g_mode[id]) set_weapon_anim(id, 2) else set_weapon_anim(id, 15) set_pdata_float(id, m_flNextAttack, 1.0 , PLAYER_LINUX_XTRA_OFF) } }
if(weaponid != CSW_UMP45) { remove_task(id) g_reload[id] = 0 g_change[id] = 0 }
g_oldweap[id] = weaponid }
public fw_UpdateClientData_Post(id, sendweapons, cd_handle) { if(!is_user_alive(id) || !is_user_connected(id)) return FMRES_IGNORED if(zp_get_user_zombie(id)) return FMRES_IGNORED if(get_user_weapon(id) != CSW_SK3 || !g_had_sk3[id]) return FMRES_IGNORED
set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001)
return FMRES_HANDLED } public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2) { if (eventid != g_orig_event_sk3 || !g_IsInPrimaryAttack) 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 fwPrecacheEvent_Post(type, const name[]) { if (equal("events/ump45.sc", name)) { g_orig_event_sk3 = get_orig_retval() return FMRES_HANDLED }
return FMRES_IGNORED } public fw_takedmg(victim, inflictor, attacker, Float:damage, damagebits) { if(!is_user_alive(victim) || !is_user_alive(attacker)) return HAM_IGNORED if(zp_get_user_zombie(attacker) || !zp_get_user_zombie(victim)) return HAM_IGNORED
if(get_user_weapon(attacker) == CSW_SK3 && g_had_sk3[attacker]) { static Float:Damage if(g_mode[attacker]) Damage = get_pcvar_float(cvar_dmg_mode2) else Damage = get_pcvar_float(cvar_dmg_mode1)
SetHamParamFloat(4, damage * Damage) }
return HAM_HANDLED } public fw_SetModel(entity, model[]) { if(!is_valid_ent(entity)) return FMRES_IGNORED;
static szClassName[33] entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
if(!equal(szClassName, "weaponbox")) return FMRES_IGNORED;
static iOwner iOwner = entity_get_edict(entity, EV_ENT_owner)
if(equal(model, "models/w_ump45.mdl")) { static weapon weapon = find_ent_by_owner(-1, "weapon_ump45", entity)
if(!is_valid_ent(weapon)) return FMRES_IGNORED;
if(g_had_sk3[iOwner]) { entity_set_int(weapon, EV_INT_impulse, 90) g_had_sk3[iOwner] = 0 remove_task(iOwner) g_reload[iOwner] = 0 g_mode[iOwner] = 0 set_pev(weapon, pev_iuser3, cs_get_weapon_ammo(weapon)) entity_set_model(entity, w_model)
return FMRES_SUPERCEDE } }
return FMRES_IGNORED; }
public fw_item_addtoplayer(ent, id) { if(!is_valid_ent(ent)) return HAM_IGNORED
if(zp_get_user_zombie(id)) return HAM_IGNORED
if(entity_get_int(ent, EV_INT_impulse) == 90) { g_had_sk3[id] = 1 cs_set_weapon_ammo(ent, pev(ent, pev_iuser3)) g_zoomed[id] = 0 remove_task(id) g_mode[id] = 0 g_reload[id] = 0 entity_set_int(id, EV_INT_impulse, 0)
return HAM_HANDLED }
return HAM_HANDLED }
public ham_priattack(Weapon) { new Player = get_pdata_cbase(Weapon, 41, 5)
if (!is_user_alive(Player) || zp_get_user_zombie(Player) || !g_had_sk3[Player]) return; g_IsInPrimaryAttack = 1 pev(Player,pev_punchangle,cl_pushangle[Player]) g_clip_ammo[Player] = cs_get_weapon_ammo(Weapon) }
stock set_weapon_anim(id, anim) { set_pev(id, pev_weaponanim, anim)
message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, _, id) write_byte(anim) write_byte(pev(id,pev_body)) message_end() }
stock drop_weapons(id, dropwhat) { static weapons[32], num, i, weaponid num = 0 get_user_weapons(id, weapons, num)
for (i = 0; i < num; i++) { weaponid = weapons
if (dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)) { static wname[32] get_weaponname(weaponid, wname, sizeof wname - 1) engclient_cmd(id, "drop", wname) } } } public reload_task(id) { if(!is_user_alive(id) || zp_get_user_zombie(id)) return;
if(get_user_weapon(id) != CSW_UMP45) return;
if(!g_had_sk3[id] || g_change[id]) return; new d if(!g_mode[id]) d = get_pcvar_num(cvar_clip_mode1) else d = get_pcvar_num(cvar_clip_mode2)
new weapon = find_ent_by_owner ( -1, "weapon_ump45", id)
new iBpAmmo = cs_get_user_bpammo(id, CSW_UMP45); new iClip = get_pdata_int(weapon, m_iClip, WEAP_LINUX_XTRA_OFF)
new j = min(d - iClip, iBpAmmo)
set_pdata_int(weapon, m_iClip, iClip + j, WEAP_LINUX_XTRA_OFF) cs_set_user_bpammo(id, CSW_UMP45, iBpAmmo-j);
g_reload[id] = 0 }
public Reload(weapon) { if(!is_valid_ent(weapon)) return HAM_IGNORED;
new id = get_pdata_cbase(weapon, 41, 4)
if (!is_user_alive(id) || !g_had_sk3[id] || g_change[id]) return HAM_IGNORED;
g_TmpClip[id] = -1
new iBpAmmo = cs_get_user_bpammo(id, CSW_UMP45) new iClip = get_pdata_int(weapon, m_iClip, WEAP_LINUX_XTRA_OFF) new d;
if(!g_mode[id]) d = get_pcvar_num(cvar_clip_mode1) else d = get_pcvar_num(cvar_clip_mode2)
if (iBpAmmo <= 0) return HAM_SUPERCEDE;
if (iClip >= d) return HAM_SUPERCEDE;
g_TmpClip[id] = iClip;
if(g_zoomed[id]) { cs_set_user_zoom(id, CS_RESET_ZOOM, 1) g_zoomed[id] = 0 }
return HAM_IGNORED; }
public Reload_Post(weapon) { if(!is_valid_ent(weapon)) return HAM_IGNORED;
new id = get_pdata_cbase(weapon, 41, 4)
if (!is_user_alive(id) || !g_had_sk3[id] || g_change[id]) return HAM_IGNORED;
if (g_TmpClip[id] == -1) return HAM_IGNORED;
new iBpAmmo = cs_get_user_bpammo(id, CSW_UMP45)
if (iBpAmmo <= 0) return HAM_IGNORED;
if(g_change[id]) return HAM_IGNORED;
new Float:reload_time; if(!g_mode[id]) reload_time = get_pcvar_float(cvar_reload_time_mode1) else reload_time = get_pcvar_float(cvar_reload_time_mode2)
set_pdata_int(weapon, m_iClip, g_TmpClip[id], WEAP_LINUX_XTRA_OFF)
set_pdata_float(weapon, m_flTimeweaponIdle, reload_time, WEAP_LINUX_XTRA_OFF)
set_pdata_float(id, m_flNextAttack, reload_time, PLAYER_LINUX_XTRA_OFF)
set_pdata_int(weapon, m_fInReload, 1, WEAP_LINUX_XTRA_OFF)
if(g_mode[id]) set_weapon_anim(id, 14) else set_weapon_anim(id, 1)
remove_task(id) g_reload[id] = 1 set_task(reload_time, "reload_task", id)
return HAM_IGNORED; }
public fw_cmdstart(id, uc_handle, seed) { if(!is_user_alive(id) || !is_user_connected(id)) return FMRES_IGNORED
if(zp_get_user_zombie(id)) return FMRES_IGNORED
if(get_user_weapon(id) != CSW_UMP45) return FMRES_IGNORED
if(!g_had_sk3[id]) return FMRES_IGNORED
if(g_reload[id] || g_change[id]) return FMRES_IGNORED
if((get_uc(uc_handle, UC_Buttons) & IN_USE) && !(pev(id, pev_oldbuttons) & IN_USE)) { if(get_gametime() - 2.0 > g_change_time[id]) { if(!g_mode[id]) make_mode_2(id) else make_mode_1(id)
g_change_time[id] = get_gametime() } } if((get_uc(uc_handle, UC_Buttons) & IN_ATTACK2) && !(pev(id, pev_oldbuttons) & IN_ATTACK2)) { if(g_mode[id]) return FMRES_IGNORED
if(get_gametime() - 0.5 > g_zoom_time[id]) { if(!g_zoomed[id]) { cs_set_user_zoom(id, CS_SET_AUGSG552_ZOOM, 1) g_zoomed[id] = 1 } else { cs_set_user_zoom(id, CS_RESET_ZOOM, 1) g_zoomed[id] = 0 } g_zoom_time[id] = get_gametime() } } return HAM_SUPERCEDE; } public zero_values(id) { remove_task(id) g_reload[id] = 0 g_mode[id] = 0 g_change[id] = 0 } public make_mode_1(id) { g_change[id] = 1 set_task(2.9, "set_mode_1", id) ExecuteHam(Ham_Weapon_Reload, find_ent_by_owner ( -1, "weapon_ump45", id )) set_weapon_anim(id, 17) set_pdata_float(id, m_flNextAttack, 2.9, PLAYER_LINUX_XTRA_OFF) }
public make_mode_2(id) { if(g_zoomed[id]) { cs_set_user_zoom(id, CS_RESET_ZOOM, 1) g_zoomed[id] = 0 }
g_change[id] = 1 set_task(3.2, "set_mode_2", id) ExecuteHam(Ham_Weapon_Reload, find_ent_by_owner ( -1, "weapon_ump45", id )) set_weapon_anim(id, 16) set_pdata_float(id, m_flNextAttack, 3.2, PLAYER_LINUX_XTRA_OFF) }
public set_mode_1(id) { if(!is_user_alive(id)) return;
if(get_user_weapon(id) != CSW_UMP45) return;
if(g_change[id]) { g_change[id] = 0 g_mode[id] = 0 replace_weapon_models(id, CSW_UMP45) } }
public set_mode_2(id) { if(!is_user_alive(id)) return;
if(get_user_weapon(id) != CSW_UMP45) return;
if(g_change[id]) { g_change[id] = 0 g_mode[id] = 1 replace_weapon_models(id, CSW_UMP45) } } public ham_priattack2(Weapon) { g_IsInPrimaryAttack = 0 new Player = get_pdata_cbase(Weapon, 41, 5)
if(get_user_weapon(Player) != CSW_UMP45) return;
new szClip get_user_weapon(Player, szClip) if(g_had_sk3[Player]) { if (!g_clip_ammo[Player]) return remove_task(Player) new b if(!g_mode[Player]) b = 3 else b = 1
if(szClip >= b) { if(!g_mode[Player]) set_weapon_anim(Player, random_num(3, 5)) else set_weapon_anim(Player, random_num(8, 12))
} if(g_mode[Player] && szClip == 2) { set_weapon_anim(Player, 10) } if(g_mode[Player] && szClip == 1) { set_weapon_anim(Player, 13) } emit_sound(Player, CHAN_WEAPON, sk3_sound[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM) static Float:punchAngle[3]; punchAngle[0] = float(random_num(-1 * 100, 100)) / 100.0; punchAngle[1] = float(random_num(-1 * 100, 100)) / 50.0; punchAngle[2] = 0.0; set_pev(Player, pev_punchangle, punchAngle); g_lastshoot[Player] = get_gametime() } } public fw_knifeidleanim(weapon) { new id = get_pdata_cbase(weapon, 41, 4) new iClip = get_pdata_int(weapon, m_iClip, 4)
if(!is_user_alive(id) || zp_get_user_zombie(id) || !g_had_sk3[id] || get_user_weapon(id) != CSW_UMP45) return HAM_IGNORED;
if(g_mode[id]) { if(iClip > 2) set_weapon_anim(id, 6) if(iClip < 2) set_weapon_anim(id, 7) return HAM_SUPERCEDE; }
return HAM_IGNORED; } public fw_skull3_itempostframe(weapon) { new player = get_pdata_cbase(weapon, 41, 4)
if(!is_user_alive(player) || zp_get_user_zombie(player) || !g_had_sk3[player]) return HAM_IGNORED;
new Float:flNextAttack = get_pdata_float(player, m_flNextAttack, PLAYER_LINUX_XTRA_OFF)
new iBpAmmo = cs_get_user_bpammo(player, CSW_UMP45) new iClip = get_pdata_int(weapon, m_iClip, WEAP_LINUX_XTRA_OFF)
new fInReload = get_pdata_int(weapon, m_fInReload, WEAP_LINUX_XTRA_OFF)
if( fInReload && flNextAttack <= 0.0 ) { new d, j
if(!g_mode[player]) d = get_pcvar_num(cvar_clip_mode1) else d = get_pcvar_num(cvar_clip_mode2) j = min(d - iClip, iBpAmmo)
set_pdata_int(weapon, m_iClip, iClip + j, WEAP_LINUX_XTRA_OFF) cs_set_user_bpammo(player, CSW_UMP45, iBpAmmo - j);
set_pdata_int(weapon, m_fInReload, 0, WEAP_LINUX_XTRA_OFF) fInReload = 0 }
return HAM_IGNORED; }
public zp_user_infected_post(id) zero_values(id) public client_connect(id) zero_values(id) public client_disconnect(id) zero_values(id) /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1026\\ f0\\ fs16 \n\\ par } */
|