Raised This Month: $ Target: $400
 0% 

strip weapon then give weapon


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
jsterling
SourceMod Donor
Join Date: Mar 2004
Location: Denver, CO, USA
Old 07-25-2008 , 03:25   strip weapon then give weapon
Reply With Quote #1

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.

The code compiles but does nothing in-game.

Any help would be greatly appreciated.

Thanks!

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 }

Last edited by jsterling; 07-25-2008 at 03:39.
jsterling is offline
Send a message via AIM to jsterling
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:30.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode