I am trying to strip the AWP when a user picks it up, buys it, etc and then give them a scout...
The code compiles but it does not do anything. I am using stocks provided by Avalanche for use with the ham sandwich module.
Code:
/* Script generated by Pawn Studio */
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN "awp2scout"
#define AUTHOR "[c4a]Haze"
#define VERSION "1.0"
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("WeapPickup", "strip_awp", "b","1=18");
}
// gives a player a weapon efficiently
stock ham_give_weapon(id,weapon[])
{
if(!equal(weapon,"weapon_",7)) return 0;
new wEnt = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,weapon));
if(!pev_valid(wEnt)) return 0;
set_pev(wEnt,pev_spawnflags,SF_NORESPAWN);
dllfunc(DLLFunc_Spawn,wEnt);
if(!ExecuteHamB(Ham_AddPlayerItem,id,wEnt))
{
if(pev_valid(wEnt)) set_pev(wEnt,pev_flags,pev(wEnt,pev_flags) | FL_KILLME);
return 0;
}
ExecuteHamB(Ham_Item_AttachToPlayer,wEnt,id)
return 1;
}
// takes a weapon from a player efficiently
stock ham_strip_weapon(id,weapon[])
{
if(!equal(weapon,"weapon_",7)) return 0;
new wId = get_weaponid(weapon);
if(!wId) return 0;
new wEnt;
while((wEnt = engfunc(EngFunc_FindEntityByString,wEnt,"classname",weapon)) && pev(wEnt,pev_owner) != id) {}
if(!wEnt) return 0;
if(get_user_weapon(id) == wId) ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt);
if(!ExecuteHamB(Ham_RemovePlayerItem,id,wEnt)) return 0;
ExecuteHamB(Ham_Item_Kill,wEnt);
set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<wId));
return 1;
}
public strip_awp(id)
{
ham_strip_weapon(id, "weapon_awp");
set_task(0.2,"give_scout",id);
return PLUGIN_CONTINUE
}
public give_scout(id)
{
ham_give_weapon(id, "weapon_scout");
return PLUGIN_CONTINUE
}