PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <cstrike>
#include <fun>
new cv_deagle_clip, gmsgCurWeapon, weapon[33], deagle_clip[33], deagle_bpammo[33];
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_deagle_clip = register_cvar("deagle_clip","1");
register_forward(FM_CmdStart,"fw_cmdstart",1);
register_clcmd("say /deagle", "Reglas")
register_clcmd("say /usp", "usp")
register_clcmd("say /glock", "glock")
}
public deagle(id)
{
cs_set_weapon_ammo( give_item( id, "weapon_deagle" ), 1 )
cs_set_user_bpammo( id, CSW_DEAGLE, 10 )
}
public usp(id)
{
cs_set_weapon_ammo( give_item( id, "weapon_usp" ), 1 )
cs_set_user_bpammo( id, CSW_USP, 10 )
}
public glock(id)
{
cs_set_weapon_ammo( give_item( id, "weapon_glock18" ), 1 )
cs_set_user_bpammo( id, CSW_GLOCK18, 10 )
}
// reset values
public client_putinserver(id)
{
weapon[id] = 0;
deagle_clip[id] = 0;
deagle_bpammo[id] = 0;
}
// restrict clip ammo
public event_curweapon(id)
{
new status = read_data(1);
if(status) weapon[id] = read_data(2);
// using AWP
if(read_data(2) == CSW_DEAGLE)
{
// current weapon
if(status)
{
// save clip information
new old_deagle_clip = deagle_clip[id];
deagle_clip[id] = read_data(3);
new max_clip = get_pcvar_num(cv_deagle_clip);
// plugin enabled and must restrict ammo
if(max_clip && deagle_clip[id] > max_clip)
{
new wEnt = get_weapon_ent(id,CSW_DEAGLE);
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_DEAGLE);
write_byte(max_clip);
message_end();
// don't steal ammo from the player
if(deagle_bpammo[id] && deagle_clip[id] > old_deagle_clip)
cs_set_user_bpammo(id,CSW_DEAGLE,deagle_bpammo[id]-max_clip+old_deagle_clip);
deagle_clip[id] = max_clip;
}
}
else deagle_clip[id] = 999;
}
else if(status) deagle_clip[id] = 999;
}
// delayed record bpammo information
public event_ammox(id)
{
// awp ammo type is 1
if(read_data(1) == 1)
{
static parms[2];
parms[0] = id;
parms[1] = read_data(2);
set_task(0.1,"record_ammo",id,parms,2);
}
}
// delay, because ammox is called right before curweapon
public record_ammo(parms[])
{
deagle_bpammo[parms[0]] = parms[1];
}
// block reload based on new clip size
public fw_cmdstart(player,uc_handle,random_seed)
{
new max_clip = get_pcvar_num(cv_deagle_clip);
if(weapon[player] == CSW_DEAGLE && max_clip && deagle_clip[player] >= 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[32];
// 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;
}
HELP
1. help to add usp and glock in the Function
2. activates the function(plugin reload) after giving me the weapon
3. in the next round desactivate the function(plugin reload)
PD:
2) i can use bool but... i dont khow use the bool in this plugin :S
3) i use the ham spawn but... need te variable or bool for desactivating..
help me pls
i Give Double Karma
+Karma +Karma