Raised This Month: $ Target: $400
 0% 

CurWeapon event will fire on Fire


Post New Thread Reply   
 
Thread Tools Display Modes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-30-2024 , 19:47   Re: CurWeapon event will fire on Fire
Reply With Quote #21

I tried getting the weapon entity index the simplest way using find_ent_by_owner(), but this was returning 0 because the owner of the weapon is not yet established when the WeapPickup event is called. You could use WeapPickup with a 0.1 delay via set_task(), which works, but I don't like the idea of calling set_task() over and over again.

There are probably simpler ways, but this is what I threw together
PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <engine>
#include <cstrike>

new const Version [] = "0.1";

new const 
m_rgpPlayerItems_CWeaponBox]  = { 34 35 , ... };
const 
XO_WEAPONBOX 4;

new 
g_TouchedWeaponboxMAX_PLAYERS ];

public 
plugin_init() 
{
    
register_plugin"Weapon Pickup" Version "bugsy" );

    
register_touch"weaponbox" "player" "PlayerTouchWeaponbox" );
    
RegisterHamHam_AddPlayerItem "player""AddPlayerItem" );
}

public 
PlayerTouchWeaponboxiWeaponbox iPlayer )
{
    new 
iWeapon;
    
    for ( new 
iSlot iSlot <= iSlot++ )
    {
        if ( ( 
iWeapon get_pdata_cbaseiWeaponbox m_rgpPlayerItems_CWeaponBoxiSlot ] , XO_WEAPONBOX ) ) > )
            break;
    }
    
    
g_TouchedWeaponboxiPlayer ] = iWeapon;
}

public 
AddPlayerItemid iWeaponEntity )
{
    if ( 
g_TouchedWeaponboxid ] == iWeaponEntity )
    {
        new 
szName32 ] , szWeaponName24 ] , iWeaponID cs_get_weapon_idiWeaponEntity );
        
        
get_user_nameid szName charsmaxszName ) );
        
get_weaponnameiWeaponID szWeaponName charsmaxszWeaponName ) );
        
        
client_printprint_chat "%s picked up %s weapon, CSW_ id = %d, entity id = %d" szName szWeaponName] , iWeaponID iWeaponEntity );
        
g_TouchedWeaponboxid ] = 0;
    }

__________________

Last edited by Bugsy; 03-31-2024 at 12:21.
Bugsy is offline
Cuttlas
Senior Member
Join Date: Jan 2015
Old 03-30-2024 , 21:38   Re: CurWeapon event will fire on Fire
Reply With Quote #22

nice hints bro, Bugsy.

You are great at pawn. I will use it
__________________
To Infinity n Beyond
Cuttlas 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 19:59.


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