Raised This Month: $ Target: $400
 0% 

...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-30-2009 , 00:44   Re: curweapon event
Reply With Quote #1

Detect weapon change with CurWeapon event filtered :

PHP Code:
#include <amxmodx>

enum _:CurWeapon_Structure {     
    
CurWeapon_IsActive 1,
    
CurWeapon_WeaponID,
    
CurWeapon_ClipAmmo
}

const 
MAX_PLAYERS 32

new g_iCurWeapon[MAX_PLAYERS+1]

public 
plugin_init()
{
    
register_event("CurWeapon""Event_CurWeapon""be""1=1")
}

public 
Event_CurWeaponid )
{
    new 
iCurWeapon read_dataCurWeapon_WeaponID )
    if( 
g_iCurWeapon[id] != iCurWeapon )
    {
        
// player has switch from CSW_[ g_iCurWeapon[id] ] to CSW_[ iCurWeapon ]
        
g_iCurWeapon[id] = iCurWeapon
    
}

You could consider hamsandwich :

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

const EXTRAOFFSET_WEAPON        4
const m_pPlayer            41

const EXTRAOFFSET_PLAYER        5
const m_pLastItem            375

public plugin_init()
{
    new 
szWeaponName[32]
    for(new 
i=CSW_P228i<=CSW_P90i++)
    {
        if( 
get_weaponname(iszWeaponNamecharsmax(szWeaponName)) )
        {
            
RegisterHam(Ham_Item_DeployszWeaponName"Weapon_Deploy_Post"1)
        }
    }
}

public 
Weapon_Deploy_PostiWeapon )
{
    new 
bHasDeployed
    GetOrigHamReturnInteger
(bHasDeployed)

    if( 
bHasDeployed )
    {
        new 
id get_pdata_cbase(iWeaponm_pPlayerEXTRAOFFSET_WEAPON)
        new 
CSW_ID cs_get_weapon_id(iWeapon)

        new 
iLastWeapon get_pdata_cbase(idm_pLastItemEXTRAOFFSET_PLAYER)
        if( 
iLastWeapon )
        {
            new 
iLastWeaponCSW_ID cs_get_weapon_id(iLastWeapon)
        }
        
// player has switch from CSW_[ iLastWeaponCSW_ID ] weapon entity [ iLastWeapon ]  to CSW_[ CSW_ID ] weapon entity iWeapon
    
}

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 11-30-2009 at 00:57.
ConnorMcLeod is offline
hectorz0r
Senior Member
Join Date: Oct 2008
Old 11-30-2009 , 10:33   Re: curweapon event
Reply With Quote #2

...

Last edited by hectorz0r; 04-09-2010 at 16:49.
hectorz0r is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-30-2009 , 11:07   Re: curweapon event
Reply With Quote #3

Also, to force a player to switch his weapon, i would recommand to use ExecuteHam(Ham_Item_Deploy, iNewWeaponEntity).
You may have to execute Ham_Holster on previous one.
engclient_cmd doesn't trigger CurWeapon event so with (for example) models plugins that use this event models will be messed up.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
hectorz0r
Senior Member
Join Date: Oct 2008
Old 11-30-2009 , 11:09   Re: curweapon event
Reply With Quote #4

...

Last edited by hectorz0r; 04-09-2010 at 16:49.
hectorz0r 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 13:38.


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