Raised This Month: $ Target: $400
 0% 

Solved Detect Drop weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 04-06-2018 , 09:57   Detect Drop weapon
Reply With Quote #1

Hi guys,

How to properly detect when the player drops a certain weapon. I'm making a plugin that I need to detect some weapon drops, but I'm not doing well.

Last edited by iceeedr; 04-28-2018 at 00:41.
iceeedr is offline
Send a message via Skype™ to iceeedr
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-06-2018 , 11:07   Re: Detect Drop weapon
Reply With Quote #2

Post what have you done....
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
man_s_our
Senior Member
Join Date: Jul 2017
Location: aim_taliban
Old 04-06-2018 , 13:05   Re: Detect Drop weapon
Reply With Quote #3

look in this tutorial:
https://forums.alliedmods.net/showthread.php?t=49247
__________________
man_s_our is offline
man_s_our
Senior Member
Join Date: Jul 2017
Location: aim_taliban
Old 04-06-2018 , 13:21   Re: Detect Drop weapon
Reply With Quote #4

for the manual drop you can use
PHP Code:
register_clcmd("drop""Event_WeaponDrop"
__________________

Last edited by man_s_our; 04-06-2018 at 13:22.
man_s_our is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 04-06-2018 , 19:25   Re: Detect Drop weapon
Reply With Quote #5

Quote:
Originally Posted by Natsheh View Post
Post what have you done....
I took an example already in the forum made by Ven, and made some adjustments, awp is being excluded from the game, but the debug message does not appear.

PHP Code:
public SetModel(iEntszModel[]) 
{     for (new 
g_max_clients 1g_max_entities; ++i)
    {
        if (!
pev_valid(i) || iEnt != pev(ipev_owner))
            continue
        
        new 
id pev(iEntpev_owner)
        if (!(
g_start_client_index <= id <= g_max_clients))
        return 
FMRES_IGNORED
        
        
for (new g_max_clients 1g_max_entities; ++i)
        {
            if (!
pev_valid(i) || iEnt != pev(ipev_owner))
            continue
        }
        if( 
equal(szModel"models/w_"9) ) 
        {
            if(
equalszModel[9], "weaponbox") && szModel[9] != 'h' && !equalszModel[9], "sm") && !equalszModel[9], "fl"))
                
set_pev(iEntpev_nextthinkget_gametime() + 0.1)
            else if(
equalszModel[9], "aw"))
                
set_pev(iEntpev_nextthinkget_gametime() + 0.1)
            else if(
equal(g_command[id], g_drop))
                
client_print_color(id"%s !yDebug Message"xPrefixChat)
            else
                return 
FMRES_IGNORED
        
}
    }
    return 
FMRES_IGNORED

iceeedr is offline
Send a message via Skype™ to iceeedr
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-07-2018 , 10:15   Re: Detect Drop weapon
Reply With Quote #6

This does not work perfectly for all weapons, for example the glock. But if all you care about is AWP then this will work fine. I also included AK47 so you can see how to use this with multiple weapons.
PHP Code:
#include <amxmodx>
#include <fakemeta>

#define MAX_PLAYERS    32

#define IsPlayer(%1)    (1<=%1<=MAX_PLAYERS)

const DetectDrop 

    ( 
<< CSW_AK47 ) | 
    ( 
<< CSW_AWP 
);

new 
WeaponName25 ] = "weapon_";

public 
plugin_init() 
{
    
register_forwardFM_SetModel "Forward_SetModel" );
}

public 
Forward_SetModeliEntity , const szModel[] ) 
{     
    static 
iOwneriWID szName32 ];
    
    
//Get owner of weapon. If 0 then no owner assigned yet, if between 1 and MaxPlayers then a player owns it.
    
iOwner peviEntity pev_owner );
    
    
//Check if owner is player and the model being set is a weapon model.
    
if ( IsPlayeriOwner ) && equalszModel "models/w_" ) )
    {
        
//Format weapon name to 'weapon_WEAPONNAME' format so it can be used in get_weaponid().
        
copyWeaponName] , charsmaxWeaponName ) - szModel] );
        
WeaponNamestrlenWeaponName ) - ] = EOS;
        
        
//Get CSW_ weapon index using 'weapon_WEAPONNAME' string that was created above.
        //Will not work with glock since the 18 in glock18 is not used with get_weaponid().
        
iWID get_weaponidWeaponName )
        
        
//Check if this weapon is one that we care about (set in DetectDrop bit-field).
        
if ( DetectDrop & ( << iWID ) )
        {
            
get_user_nameiOwner szName charsmaxszName ) );
            
client_printprint_chat "%s dropped %s [CSW_ ID = %d]." szName WeaponName iWID )
        }
    }

__________________
Bugsy 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 06:10.


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