Raised This Month: $32 Target: $400
 8% 

Dropped Weapons Remover


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 09-10-2011 , 10:56   Dropped Weapons Remover
Reply With Quote #1

I found a new way to remove the dropped weapons and I think it's usefully.

PHP Code:
#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >

public plugin_init( )
{
  
RegisterHamHam_Think"weaponbox""OnThink");
  
RegisterHamHam_Think"weapon_shield""OnThink");

  
register_forwardFM_SetModel"OnSetModel");
}

public 
OnThinkiEntity )
  
engfuncEngFunc_RemoveEntityiEntity );

public 
OnSetModeliEntity )
{
  if( 
pev_validiEntity ) )
  {
    static 
szClass32 ];
    
peviEntitypev_classnameszClass31 );

    if( 
equalszClass"weaponbox" ) || equalszClass"weapon_shield" ) )
      
set_peviEntitypev_nextthinkget_gametime( ) + 0.1 );
  }

__________________
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-10-2011 , 11:04   Re: Dropped weapons remover
Reply With Quote #2

Sorry, but that's not new thinking the weaponbox to remove it. You can see such code anyway in the HLSDK.

https://forums.alliedmods.net/showth...move+weaponbox
https://forums.alliedmods.net/showth...move+weaponbox
etc..
__________________
Arkshine is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 09-12-2011 , 00:57   Re: Dropped weapons remover
Reply With Quote #3

best way is to patch mem using orpheu
packPlayerItem set think with CWeaponBox::Kill and set nextthink time to gametime + 300.0, you just need to change 300.0 to 0.1, then let ::Kill function remove it soon.
another place is PlayerDrop
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-12-2011 , 04:58   Re: Dropped weapons remover
Reply With Quote #4

Yes, it would be more efficient though not sure it would be worth and best way because you would need to patch in 3 locations : packPlayerItem(), CBasePlayer::DropPlayerItem() and CBasePlayer::DropShield(). You can't just trying replacing some value through all the library, you would need to base from the start of the functions. But none are virtual functions thus you would need to make signatures (at least for windows) and that vs SetModel (for example), the latter would be recommended because much more simple, signatures are not that reliable and the difference in efficiently is trivial.

EDIT : For the fun, here an example :

Code:
#include <amxmodx> #include <orpheu> #include <orpheu_memory> #include <orpheu_advanced> enum Function { packPlayerItem, DropPlayerItem, DropShield }; public plugin_init() {     register_plugin( "Dropped Weapons Killer", "1.0.0", "Arkshine" );         patch( packPlayerItem, OrpheuGetFunctionAddress( OrpheuGetFunction( "packPlayerItem" ) ) );     patch( DropPlayerItem, OrpheuGetFunctionAddress( OrpheuGetFunction( "DropPlayerItem", "CBasePlayer" ) ) );     patch( DropShield    , OrpheuGetFunctionAddress( OrpheuGetFunction( "DropShield"    , "CBasePlayer" ) ) ); } public plugin_end() {     patch( packPlayerItem, .undo = true );     patch( DropPlayerItem, .undo = true );     patch( DropShield    , .undo = true ); } patch( const Function:currentFunction, startAddress = 0, const bool:undo = false ) {     const Float:originalValue = 300.0;     const Float:newValue      = 0.1;         static SavedAddress[ Function ];         undo ? OrpheuMemorySetAtAddress( SavedAddress[ currentFunction ], "float", 1, originalValue ) :            OrpheuMemoryReplaceAtAddress( startAddress, "float", 1, originalValue, newValue, SavedAddress[ currentFunction ] ); }

Note: Unzip the content in ./amxmodx/ directory.
Attached Files
File Type: zip [signatures]dropped_weapons_killer.zip (3.1 KB, 266 views)
__________________

Last edited by Arkshine; 09-12-2011 at 06:10.
Arkshine is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 09-13-2011 , 03:55   Re: Dropped weapons remover
Reply With Quote #5

PHP Code:

    RegisterHam
(Ham_Spawn"weaponbox""fwdWeaponDrop"1); //Weapon box spawn
    
RegisterHam(Ham_Spawn"armoury_entity""fwdWeaponDrop"1); //Armor entity Spawn

public fwdWeaponDrop(iEnt)
{    
    if(
pev_valid(iEnt))
    {
        
set_task(0.5"RemoveWeapons"iEnt);
    }
}

public 
RemoveWeapons(iEnt)
{
    if(
pev_valid(iEnt))
    {
        new 
szModelName[32];
        
pev(iEntpev_modelszModelNamecharsmax(szModelName));
        
        if(
containi(szModelName"backpack") == -1)
        {
            
set_pev(iEntpev_flagsFL_KILLME);
            
ExecuteHam(Ham_ThinkiEnt);
        }
    }

This is how i do it in my battlefield plugin it doesnt remove thighpacks ofc.
Doc-Holiday is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 09-13-2011 , 13:24   Re: Dropped weapons remover
Reply With Quote #6

I don't think that a task is required.
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 09-13-2011 , 14:58   Re: Dropped weapons remover
Reply With Quote #7

Quote:
Originally Posted by bibu View Post
I don't think that a task is required.
yup... tested both ways... i guess the mdl isnt set by the time the weapon drops there for it still removes the backpack.. but that task... allows you to also leave weapons on the floor for x amount of time before they are removed.. also tested.. but requires more code. (weapon pickup to remove the task on that specific weapon)
Doc-Holiday is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 09-21-2011 , 01:15   Re: Dropped weapons remover
Reply With Quote #8

The above code of mine tweaked a bit to work for thighpack also
The above code of mine tweaked a bit to work for thighpack also

PHP Code:
RegisterHam(Ham_Touch"item_thighpack""RemoveWeapons"1);//Rmoves Thighpack
    
RegisterHam(Ham_Touch"weaponbox""RemoveWeapons"1); //Weapon box spawn
    
RegisterHam(Ham_Touch"armoury_entity""RemoveWeapons"1); //Armor entity Spawn

public RemoveWeapons(iEnt)
{
    if(
pev_valid(iEnt))
    {
        new 
szModelName[32];
        
pev(iEntpev_modelszModelNamecharsmax(szModelName));
        
        if(
containi(szModelName"backpack") == -1)
        {
            
set_pev(iEntpev_flagsFL_KILLME);
            
ExecuteHam(Ham_ThinkiEnt);
        }
    }

Doc-Holiday is offline
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 00:56.


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