Raised This Month: $ Target: $400
 0% 

strip weapon then give weapon


Post New Thread Reply   
 
Thread Tools Display Modes
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
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 07-25-2008 , 13:17   Re: strip weapon then give weapon
Reply With Quote #2

Try this (not tested):
PHP Code:
#include <amxmodx>
#include <fun>
 
public plugin_init()
{
        
register_plugin("AWP Strip""1.0""hleV"// Credits for SuicideDog/MattOG/DaSoul
 
        
register_clcmd("awp""BuyWeapon"
        
register_clcmd("magnum""BuyWeapon")
 
        
register_menucmd(-31, (1<<4), "MenuChoose")
        
register_menucmd(-31, (1<<5), "MenuChoose")
        
register_menucmd(register_menuid("BuyRifle"1), (1<<4), "MenuChoose")
        
register_menucmd(register_menuid("BuyRifle"1), (1<<5), "MenuChoose")
 
        
register_event("WeapPickup""WeapPickup""b""1=18")
}
 
public 
DropAndGive(id)
{
        
engclient_cmd(id"drop""awp")
        
give_item(id"weapon_scout")
}
 
public 
MenuChoose(id)
        
set_task(0.5"DropAndGive"id)
 
public 
WeapPickup(id)
        
set_task(0.5"DropAndGive"id
__________________
hleV is offline
jsterling
SourceMod Donor
Join Date: Mar 2004
Location: Denver, CO, USA
Old 07-28-2008 , 01:15   Re: strip weapon then give weapon
Reply With Quote #3

Although your solution would work at replacing the AWP with a Scout it just drops the AWP.

I want the AWP to be removed when it is picked up and the replace with the Scout.
jsterling is offline
Send a message via AIM to jsterling
Reply



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