AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   ... (https://forums.alliedmods.net/showthread.php?t=110448)

hectorz0r 11-29-2009 16:41

...
 
...

minimiller 11-29-2009 16:55

Re: curweapon event
 
hook curweapon and read_data(2) (i think)

Bugsy 11-29-2009 20:08

Re: curweapon event
 
not tested
PHP Code:

register_event"CurWeapon" "fw_EvCurWeapon" "be" "1=1" );

public 
fw_EvCurWeaponid )
{
    new 
iWeapon read_data);
    new 
iClipAmmo read_data);



ConnorMcLeod 11-30-2009 00:44

Re: curweapon event
 
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
    
}



hectorz0r 11-30-2009 10:33

Re: curweapon event
 
...

ConnorMcLeod 11-30-2009 11:07

Re: curweapon event
 
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.

hectorz0r 11-30-2009 11:09

Re: curweapon event
 
...


All times are GMT -4. The time now is 13:38.

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