This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Detecting a Weapon Drop


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 01-30-2010 , 14:46   Detecting a Weapon Drop
Reply With Quote #1

As the title stated, I'd like to know how I would detect if a player had dropped a weapon.

Furthermore, when this happens, would I be able to set a Pre-Think to this event, to detect the origin of the entity ( weapon )?
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
OptimizeR
BANNED
Join Date: Jan 2010
Old 01-30-2010 , 14:52   Re: Detecting a Weapon Drop
Reply With Quote #2

PHP Code:
register_clcmd("drop""cmddrop")

public 
cmddrop(id)
{
      
client_print(idprint_center"You have dropped weapon")

or fw_setmodel
OptimizeR is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-30-2010 , 14:56   Re: Detecting a Weapon Drop
Reply With Quote #3

You can cache the entity id of each weapon when acquired so it can be used when dropped.
__________________
Bugsy is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 01-30-2010 , 14:57   Re: Detecting a Weapon Drop
Reply With Quote #4

No, that's not even close to what I was looking for.

I want to set up a forward to detect if a player has dropped a weapon. For example, HAM has a forward to detect when a player is killed, takes damage, spawns, etc. I was wondering if there is a forward to detect that with an entity (weapon), and a way to set-up a prethink to find the origin before it is dropped.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 01-30-2010 , 14:58   Re: Detecting a Weapon Drop
Reply With Quote #5

Quote:
Originally Posted by Bugsy View Post
You can cache the entity id of each weapon when acquired so it can be used when dropped.
Could you provide a quick example, please?
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-30-2010 , 17:06   Re: Detecting a Weapon Drop
Reply With Quote #6

Ham_Item_Drop

You may use Ham_CS_Item_CanDrop inside Ham_Item_Drop callback.


Both have to be registered/used with weapons classnames/indexes
And to retrieve player, use m_pPlayer weapon offset.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 01-30-2010 , 17:40   Re: Detecting a Weapon Drop
Reply With Quote #7

Quote:
Originally Posted by ConnorMcLeod View Post
Ham_Item_Drop

You may use Ham_CS_Item_CanDrop inside Ham_Item_Drop callback.


Both have to be registered/used with weapons classnames/indexes
And to retrieve player, use m_pPlayer weapon offset.
Thank you.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-30-2010 , 20:51   Re: Detecting a Weapon Drop
Reply With Quote #8

g_Weapons holds the weapons that you want to monitor being dropped. Remove whichever you don't want or you can eliminate the check all together.
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <cstrike>

new g_Weapons = ( << CSW_P228 ) | 
        ( 
<< CSW_SCOUT ) | 
        ( 
<< CSW_XM1014 ) | 
        ( 
<< CSW_C4 ) | 
        ( 
<< CSW_MAC10 ) | 
        ( 
<< CSW_AUG ) | 
        ( 
<< CSW_ELITE ) | 
        ( 
<< CSW_FIVESEVEN ) | 
        ( 
<< CSW_UMP45 ) | 
        ( 
<< CSW_SG550 ) | 
        ( 
<< CSW_GALI ) | 
        ( 
<< CSW_GALIL ) | 
        ( 
<< CSW_FAMAS ) | 
        ( 
<< CSW_USP ) | 
        ( 
<< CSW_GLOCK18 ) | 
        ( 
<< CSW_AWP ) | 
        ( 
<< CSW_MP5NAVY ) | 
        ( 
<< CSW_M249 ) | 
        ( 
<< CSW_M3 ) | 
        ( 
<< CSW_M4A1 ) | 
        ( 
<< CSW_TMP ) | 
        ( 
<< CSW_G3SG1 ) | 
        ( 
<< CSW_DEAGLE ) | 
        ( 
<< CSW_SG552 ) | 
        ( 
<< CSW_AK47 ) | 
        ( 
<< CSW_P90 )
  
public 
plugin_init() 
{
    
register_plugin"Item Drop Hook" "0.1" "bugsy" );
        
    
RegisterHamHam_RemovePlayerItem "player" "fw_HamRemovePlayerItem" );
}

public 
fw_HamRemovePlayerItemid iEnt )
{
    if ( !
is_user_aliveid ) )
        return 
HAM_IGNORED;
    
    new 
iWeapon cs_get_weapon_idiEnt );
    
    if ( !( 
g_Weapons & ( << iWeapon ) ) )
        return 
HAM_IGNORED;
        
    
//Your code here
    // id = player id
    // iEnt = entity index
    // iWeapon = weapon index [CSW_*]
    
    
return HAM_IGNORED;

__________________

Last edited by Bugsy; 01-30-2010 at 20:54.
Bugsy is offline
Old 05-04-2011, 05:17
2reason2kill
This message has been deleted by 2reason2kill.
2reason2kill
Senior Member
Join Date: Feb 2011
Old 05-04-2011 , 05:19   Re: Detecting a Weapon Drop
Reply With Quote #9

Quote:
Originally Posted by Bugsy View Post
g_Weapons holds the weapons that you want to monitor being dropped. Remove whichever you don't want or you can eliminate the check all together.
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
 
new g_Weapons = ( << CSW_P228 ) | 
        ( 
<< CSW_SCOUT ) | 
        ( 
<< CSW_XM1014 ) | 
        ( 
<< CSW_C4 ) | 
        ( 
<< CSW_MAC10 ) | 
        ( 
<< CSW_AUG ) | 
        ( 
<< CSW_ELITE ) | 
        ( 
<< CSW_FIVESEVEN ) | 
        ( 
<< CSW_UMP45 ) | 
        ( 
<< CSW_SG550 ) | 
        ( 
<< CSW_GALI ) | 
        ( 
<< CSW_GALIL ) | 
        ( 
<< CSW_FAMAS ) | 
        ( 
<< CSW_USP ) | 
        ( 
<< CSW_GLOCK18 ) | 
        ( 
<< CSW_AWP ) | 
        ( 
<< CSW_MP5NAVY ) | 
        ( 
<< CSW_M249 ) | 
        ( 
<< CSW_M3 ) | 
        ( 
<< CSW_M4A1 ) | 
        ( 
<< CSW_TMP ) | 
        ( 
<< CSW_G3SG1 ) | 
        ( 
<< CSW_DEAGLE ) | 
        ( 
<< CSW_SG552 ) | 
        ( 
<< CSW_AK47 ) | 
        ( 
<< CSW_P90 )
 
public 
plugin_init() 
{
    
register_plugin"Item Drop Hook" "0.1" "bugsy" );
 
    
RegisterHamHam_RemovePlayerItem "player" "fw_HamRemovePlayerItem" );
}
 
public 
fw_HamRemovePlayerItemid iEnt )
{
    if ( !
is_user_aliveid ) )
        return 
HAM_IGNORED;
 
    new 
iWeapon cs_get_weapon_idiEnt );
 
    if ( !( 
g_Weapons & ( << iWeapon ) ) )
        return 
HAM_IGNORED;
 
    
//Your code here
    // id = player id
    // iEnt = entity index
    // iWeapon = weapon index [CSW_*]
 
    
return HAM_IGNORED;

can i do it like when a ct kill a t it says a msg??? plz help
2reason2kill is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-04-2011 , 21:38   Re: Detecting a Weapon Drop
Reply With Quote #10

Quote:
Originally Posted by 2reason2kill View Post
can i do it like when a ct kill a t it says a msg??? plz help
That code is for dropping weapons, not hooking when player is dead.
You already have a topic for when player is dead so stick to that topic.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 21:55.


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