Raised This Month: $ Target: $400
 0% 

Get weapon drop on death


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dFF
sıɹɹoɥɔ ʞɔnu
Join Date: Oct 2009
Old 09-05-2012 , 13:50   Get weapon drop on death
Reply With Quote #1

I want to check when weapon is dropped on death event without FM_SetModel forward.
I tried with Ham_Item_Drop and doesn't seem to call this event when weapon is dropped on death event.

I need best method to check weapons dropped on death event, can be with Orpheu or Rage is not a problem.
dFF is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 09-05-2012 , 14:07   Re: Get weapon drop on death
Reply With Quote #2

Its in the HLSDK.
dlls/player.cpp CBasePlayer:: PackDeadPlayerItems( void )
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 09-05-2012 at 14:07.
Liverwiz is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-06-2012 , 00:47   Re: Get weapon drop on death
Reply With Quote #3

What do you want to do exactly ?

C4 is dropped during CBasePlayer :: Killed.
Defuser is dropped (in fact new defuser is given but player can't receive it so it's falling on ground) during CBasePlayer :: Killed.
Weapon(s) are packed during CBasePlayer :: PreThink that is on the frame after CBasePlayer :: Killed.

So depending on what you exactly want to do, you need to choose the proper method.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 09-06-2012 at 00:55.
ConnorMcLeod is offline
dFF
sıɹɹoɥɔ ʞɔnu
Join Date: Oct 2009
Old 09-06-2012 , 03:29   Re: Get weapon drop on death
Reply With Quote #4

Quote:
Originally Posted by ConnorMcLeod View Post
What do you want to do exactly ?
I want to remove instant specific weapon after player death.
FM_SetModel is call every time, need a better method to hook specific weapon after player death and remove then on the floor/earth.
dFF is offline
matsi
Thinkosaur
Join Date: Sep 2006
Old 09-06-2012 , 06:27   Re: Get weapon drop on death
Reply With Quote #5

Quote:
Originally Posted by dFF View Post
I want to remove instant specific weapon after player death.
FM_SetModel is call every time, need a better method to hook specific weapon after player death and remove then on the floor/earth.
Search for 'remove weaponbox' and limit you search to 'Scripting help' section.
__________________

Accepting all kinds of requests via private message.
matsi is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-06-2012 , 12:35   Re: Get weapon drop on death
Reply With Quote #6

Something like this could work, not sure it is better than only hook SetModel though.
SetModel is not called so often.

PHP Code:
#include <amxmodx>

#include <fakemeta>
#include <hamsandwich>

#include "cstrike_pdatas"

#define PLUGIN ""
#define VERSION "0.0.1"

new g_iMaxPlayers
#define IsPlayer(%0)    ( 1 <= %0 <= g_iMaxPlayers )

#define MaskEnt(%0)    ( 1<<(%0 & 31) )
new g_bitPreThinkPlayers
#define EnablePlayerDeathDrop(%0)        g_bitPreThinkPlayers |= MaskEnt(%0)
#define DisablePlayerDeathDrop(%0)        g_bitPreThinkPlayers &= ~MaskEnt(%0)
#define IsPlayerDeathDropEnabled(%0)    g_bitPreThinkPlayers & MaskEnt(%0)

new HamHook:g_iCBasePlayerPreThinkPreHamHook:g_iCBasePlayerPreThinkPostHamHook:g_iCItemThighPackMyTouchPost

public plugin_init()
{
    
register_pluginPLUGINVERSION"ConnorMcLeod" )

    
g_iMaxPlayers get_maxplayers()

    
RegisterHam(Ham_Killed"player""OnCBasePlayer_Killed"false)
    
RegisterHam(Ham_Killed"player""OnCBasePlayer_Killed_Post"true)
    
DisableHamForwardg_iCBasePlayerPreThinkPre RegisterHam(Ham_Player_PreThink"player""OnCBasePlayer_PreThink"false) )
    
DisableHamForwardg_iCBasePlayerPreThinkPost RegisterHam(Ham_Player_PreThink"player""OnCBasePlayer_PreThink_Post"true) )
    
DisableHamForwardg_iCItemThighPackMyTouchPost RegisterHam(Ham_Touch"item_thighpack""CItemThighPack_MyTouch_Post"true) )
}

Set_SetModelbool:bOnOff )
{
    static 
_SetModel 0
    
if( bOnOff )
    {
        if( !
_SetModel )
        {
            
_SetModel register_forward(FM_SetModel"OnSetModel_Post"true)
        }
    }
    else if( 
_SetModel )
    {
        
unregister_forward(FM_SetModel_SetModeltrue)
    }
}

Set_PreThinkid bool:bOnOff )
{
    if( 
bOnOff )
    {
        if( !
g_bitPreThinkPlayers )
        {
            
EnableHamForwardg_iCBasePlayerPreThinkPre )
            
EnableHamForwardg_iCBasePlayerPreThinkPost )
        }

        
EnablePlayerDeathDrop(id)
    }
    else
    {
        
DisablePlayerDeathDrop(id)

        if( !
g_bitPreThinkPlayers )
        {
            
DisableHamForwardg_iCBasePlayerPreThinkPre )
            
DisableHamForwardg_iCBasePlayerPreThinkPost )
        }
    }
}

public 
OnCBasePlayer_Killedid iAttackeriGib)
{
    if( 
get_pdata_bool(idm_bHasC4) )
    {
        
Set_SetModeltrue )
    }
    else if( 
get_pdata_bool(idm_bHasDefuser) )
    {
        
EnableHamForwardg_iCItemThighPackMyTouchPost )
    }
}

public 
OnCBasePlayer_Killed_PostidiAttackeriGib )
{
    
Set_SetModelfalse )
    
DisableHamForwardg_iCItemThighPackMyTouchPost )
    
Set_PreThinkid true )
}

public 
OnCBasePlayer_PreThinkid )
{
    if( 
IsPlayerDeathDropEnabled(id) )
    {
        
Set_SetModeltrue )
    }
}

public 
OnCBasePlayer_PreThink_Postid )
{
    if( 
IsPlayerDeathDropEnabled(id) )
    {
        
Set_PreThinkid false )
        
Set_SetModelfalse )
    }
}

public 
OnSetModel_Post(entmodel[])
{
    if( !
equal(model"models/w_weaponbox.mdl") )
    {
        new 
id pev(entpev_owner)
        if( 
IsPlayer(id) )
        {
            
PlayerDeathDropped(ident)
        }
    }
}

public 
CItemThighPack_MyTouch_Post(entid)
{
    
PlayerDeathDropped(ident)
}

PlayerDeathDropped(ident)
{
    if( 
ExecuteHam(Ham_Weapon_GetWeaponPtrent) == ent )
    {
        new 
iId get_pdata_int(entm_iIdXO_CBasePlayerItem)
        
// iId is CSW_*** const
    
}
    else
    {
        
// defuser
    
}

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
dFF
sıɹɹoɥɔ ʞɔnu
Join Date: Oct 2009
Old 09-07-2012 , 03:57   Re: Get weapon drop on death
Reply With Quote #7

Thank you for the code Connor!

Quote:
Originally Posted by ConnorMcLeod View Post
SetModel is not called so often.
SetModel is call every time when player spawn, when weapon is dropped manually; so I think if is a better method for what i needed.

Last edited by dFF; 09-07-2012 at 03:57.
dFF is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-07-2012 , 06:12   Re: Get weapon drop on death
Reply With Quote #8

You think wrong, and you should stop to say that unless you know what you're taking about. SetModel is not called often at all (it's not like a prethink function eh!) and using only that would be more efficient than the plugin above which does way more extra operations even if it's well coded. People should stop to seek complicated way for a zero benefit which is most of time the reverse. Here the case, and it's completely bullshits for the wanted purpose.
__________________

Last edited by Arkshine; 09-07-2012 at 06:22.
Arkshine is offline
Reply


Thread Tools
Display Modes

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 08:19.


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