求老大们帮帮忙啊.我这个插件.发生个奇怪问题
此插件可限制你的awp子弹比如你买一把awp有30发子弹.那你开了2发.然后就会换子弹的.到了开第4发子弹的时侯.他就会退会卓面呀.我想问下是为什么..求老大们帮忙.重申改一下这个插件.然后发上来.我在此先行谢过啦:confused:
amxx.cfg
//每把awp只能6枪
awp_clip 6 //最高只能设为10
下面是插件源码;awp_oneshot.sma
----------------------------------------------------------
#include <amxmodx>
#include <fakemeta>
#include <cstrike>
new cv_awp_clip, gmsgCurWeapon, weapon, awp_clip, awp_bpammo;
public plugin_init()
{
register_plugin("AWP One Shot","0.11","Avalanche");
register_event("CurWeapon","event_curweapon","b");
register_event("AmmoX","event_ammox","b");
gmsgCurWeapon = get_user_msgid("CurWeapon");
cv_awp_clip = register_cvar("awp_clip","1");
register_forward(FM_CmdStart,"fw_cmdstart",1);
}
// reset values
public client_putinserver(id)
{
weapon = 0;
awp_clip = 0;
awp_bpammo = 0;
}
// restrict clip ammo
public event_curweapon(id)
{
new status = read_data(1);
if(status) weapon = read_data(2);
// using AWP
if(read_data(2) == CSW_AWP)
{
// current weapon
if(status)
{
// save clip information
new old_awp_clip = awp_clip;
awp_clip = read_data(3);
new max_clip = get_pcvar_num(cv_awp_clip);
// plugin enabled and must restrict ammo
if(max_clip && awp_clip > max_clip)
{
new wEnt = get_weapon_ent(id,CSW_AWP);
if(pev_valid(wEnt)) cs_set_weapon_ammo(wEnt,max_clip);
// update HUD
message_begin(MSG_ONE,gmsgCurWeapon,_,id);
write_byte(1);
write_byte(CSW_AWP);
write_byte(max_clip);
message_end();
// don't steal ammo from the player
if(awp_bpammo && awp_clip > old_awp_clip)
cs_set_user_bpammo(id,CSW_AWP,awp_bpammo-max_clip+old_awp_clip);
awp_clip = max_clip;
}
}
else awp_clip = 999;
}
else if(status) awp_clip = 999;
}
// delayed record bpammo information
public event_ammox(id)
{
// awp ammo type is 1
if(read_data(1) == 1)
{
static parms;
parms = id;
parms = read_data(2);
set_task(0.1,"record_ammo",id,parms,2);
}
}
// delay, because ammox is called right before curweapon
public record_ammo(parms[])
{
awp_bpammo] = parms;
}
// block reload based on new clip size
public fw_cmdstart(player,uc_handle,random_seed)
{
new max_clip = get_pcvar_num(cv_awp_clip);
if(weapon == CSW_AWP && max_clip && awp_clip >= max_clip)
{
set_uc(uc_handle,UC_Buttons,get_uc(uc_handle,UC_Buttons) & ~IN_RELOAD);
return FMRES_HANDLED;
}
return FMRES_IGNORED;
}
// find a player's weapon entity
stock get_weapon_ent(id,wpnid=0,wpnName[]="")
{
// who knows what wpnName will be
static newName;
// need to find the name
if(wpnid) get_weaponname(wpnid,newName,31);
// go with what we were told
else formatex(newName,31,"%s",wpnName);
// prefix it if we need to
if(!equal(newName,"weapon_",7))
format(newName,31,"weapon_%s",newName);
new ent;
while((ent = engfunc(EngFunc_FindEntityByString,ent,"classname",newName)) && pev(ent,pev_owner) != id) {}
return ent;
}
页:
[1]