AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Events when player drop gun (https://forums.alliedmods.net/showthread.php?t=295335)

Krtola 03-22-2017 19:59

Events when player drop gun
 
PHP Code:

#include < amxmodx >
#include < fakemeta >
#include < cstrike >
#include < hamsandwich >
#include < zombieplague >

new const PLUGIN_VERSION[ ]    =  "1.0.0 FINAL";

const 
OFFSET_WEAPONOWNER    =      41
const OFFSET_LINUX    =    5
const OFFSET_LINUX_WEAPONS     =      4

const WEAP_KEY   =    545464464
const MAX_PLAYERS   =        32

const m_flNextPrimaryAttack 46;
const 
m_iClip =    51;
const 
m_flNextAttack 83;
const 
m_flTimeWeaponIdle    48
const 
m_szAnimExtention     492

enum 
( <<=)
{
    
DROP_PRIMARY 1,
    
DROP_SECONDARY
};    

const 
IDLE 
const RELOAD 1
const DRAW 2
const SHOOT_1 3
const SHOOT_END 

#define HoldCBaseWeapon(%0)    ( get_user_weapon( %0 ) == g_iWeaponID  && g_pWeaponA[ %0 ] )
#define IsValidPrivateData(%0)    ( pev_valid( %0 ) == 2 )

#define PRECACHE_MODEL(%0)        engfunc(EngFunc_PrecacheModel, %0)
#define PRECACHE_SOUND(%0)        engfunc(EngFunc_PrecacheSound, %0)
#define PRECACHE_GENERIC(%0)        engfunc(EngFunc_PrecacheGeneric, %0)

new const WEAPON_SOUND_FIRE[ ] = "weapons/plasmagun-1.wav";
new const 
WEAPON_SOUND_BOMB[ ] = "weapons/plasmagun_exp.wav";

new const 
WEAPON_LIST[ ]   =   "weapon_plasmagun";
new const 
WEAPON_BASE_NAME[ ]   =  "weapon_m249";

const 
FloatRELOAD_TIME  =   3.36 //Время перезарядки

const AMMO__WEAPON       =  200 //Кол-во обоймы
const CLIP__WEAPON      =  45 //Кол-во патрон 
const BALL__SPEED         =  2000 //Скорость  

const FloatBALL__DAMAGE       =   200.0 //Урон
const FloatBALL__RADIUS      =  125.0 //Радиус 
const FloatWEAPON__SPEED          0.15 //Скорость орудия 

new const EXTRA_ITEM_NAME[ ]    =   "Plasmagun"//Название в Extra-Items 

new V_MODEL[ ] = "models/v_plasmagun.mdl";
new 
P_MODEL[ ] = "models/p_plasmagun.mdl";
new 
W_MODEL[ ] = "models/w_plasmagun.mdl";

new 
R_MODEL[ ] = "sprites/plasmaball.spr";

new const 
HUD_SPRITES[ ] [ ] = 
{
    
"sprites/640hud3.spr" 
    
"sprites/640hud91.spr"
};

new 
g_iItem  g_iForwardIndex g_iExpSprite  
new 
g_pWeaponAMAX_PLAYERS ] ;
new 
g_iWeaponID 0;

new const 
BALL__CLASSNAME[ ]  =   "zsClassBall";    

const 
WEAPONS_PRIMARY_BITSUM     = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90);
const 
WEAPONS_SECONDARY_BITSUM     = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE);

public 
plugin_precache( )
{
    
PRECACHE_MODELV_MODEL );
    
PRECACHE_MODELP_MODEL );
    
PRECACHE_MODELW_MODEL );
    
PRECACHE_MODELR_MODEL );
    
PRECACHE_SOUNDS_FROM_MODELV_MODEL );
    
    
PRECACHE_SOUNDWEAPON_SOUND_BOMB );
    
PRECACHE_SOUNDWEAPON_SOUND_FIRE );
    
    static 
iFile
    
for( iFile iFile sizeof HUD_SPRITESiFile++ ) 
    {
        
PRECACHE_GENERICHUD_SPRITESiFile ] )
    }    
    
    static 
szFile 128 ];
    
formatex szFile charsmaxszFile ) , "sprites/%s.txt" WEAPON_LIST );
    
PRECACHE_GENERICszFile );
    
    
g_iExpSprite precache_model"sprites/plasmabomb.spr" );
}

public 
plugin_init()
{
    
register_plugin"[CSO] Extra Item PlasmaGun" PLUGIN_VERSION "Shurik07" );
    
register_clcmdWEAPON_LIST"weapon_hook_an" );
    
    
register_forwardFM_SetModel"Forward_SetModel" false );
    
register_forwardFM_UpdateClientData"Forward_UpdateClientData" true );
    
    
RegisterHamHam_Item_AddToPlayerWEAPON_BASE_NAME"CBaseWeapon__AddToPlayer__Post" , .Post true );
    
RegisterHamHam_Item_DeployWEAPON_BASE_NAME "CBaseWeapon__Deploy__Post", .Post true );
    
RegisterHamHam_Weapon_PrimaryAttackWEAPON_BASE_NAME"CBaseWeapon__PrimaryAttack__Pre" , .Post false );
    
RegisterHamHam_Item_PostFrameWEAPON_BASE_NAME"CBaseWeapon__PostFrame__Pre" , .Post false );
    
RegisterHamHam_Weapon_ReloadWEAPON_BASE_NAME"CBaseWeapon__Reload_Pre" , .Post false );
    
RegisterHamHam_Weapon_WeaponIdle,    WEAPON_BASE_NAME,     "CBaseWeapon__Idle_Pre",    false );
    
RegisterHamHam_TraceAttack,    "player",         "CBase__TraceAttack_Pre"false );
    
    
register_forwardFM_Touch "Forward_Touch" );

    
g_iItem zp_register_extra_itemEXTRA_ITEM_NAME0ZP_TEAM_HUMAN );
    
g_iWeaponID get_weaponidWEAPON_BASE_NAME );
}

public 
zp_extra_item_selectedpPlayer pItem )
{
    if( 
pItem == g_iItem  )
    {
         
UTIL__DropWeaponspPlayerDROP_PRIMARY )
         
         
g_pWeaponApPlayer ]  = true;
         
         static 
pEntity;
         
pEntity fm_give_itempPlayer WEAPON_BASE_NAME ); 
         
         if( 
pEntity cs_set_weapon_ammopEntityCLIP__WEAPON );    
         
         
cs_set_user_bpammopPlayer g_iWeaponID AMMO__WEAPON );
         
         
UTIL__WeaponListpPlayer,  WEAPON_LIST AMMO__WEAPON , -, -4  g_iWeaponID );
    }    
}

public 
weapon_hook_anpPlayer  
{
    
engclient_cmdpPlayerWEAPON_BASE_NAME);
    return 
PLUGIN_HANDLED;
}

public 
zp_user_humanized_postpPlayer )
{
    
g_pWeaponApPlayer ] = false;
}

public 
client_disconnectpPlayer )
{
    
g_pWeaponApPlayer ]  = false;
}

public 
Forward_SetModelpEntity, const pModel[ ] )
{
    if( !
pev_validpEntity ) ) 
    {
        return 
FMRES_IGNORED;
    }    
    
    static 
szClassName 33 ]
    
pevpEntitypev_classnameszClassNamecharsmax(szClassName) );
        
    if( !
equal szClassName"weaponbox" ) )
    {
        return 
FMRES_IGNORED;
    }    
    
    static 
pOwner pModel
    pModel 
fm_find_ent_by_owner ( -1WEAPON_BASE_NAMEpEntity );
    
pOwner pev pEntitypev_owner );
    
    if ( 
g_pWeaponA pOwner ]  && pev_valid pModel ) )
    {
        
set_pevpModel pev_impulse WEAP_KEY );
        
engfuncEngFunc_SetModelpEntityW_MODEL );
        
        
g_pWeaponA pOwner ]   = false;
        return 
FMRES_SUPERCEDE;
    }

    return 
FMRES_IGNORED;
}

public 
Forward_UpdateClientDatapPlayer SendWeaponsCD_Handle )
{
    if ( !
HoldCBaseWeaponpPlayer ) )
    {
        return 
HAM_IGNORED;
    }

    static 
Float:fGametime;
    
fGametime get_gametime( );
    
    
set_cd CD_HandleCD_flNextAttackfGametime 0.001 );

    return 
FMRES_HANDLED;
}

public 
Forward_PlayBackEvent(flagsinvokereventindexFloat:delayFloat:origin[3], Float:fvangles[3], Float:fparam1Float:fparam2iParam1iParam2bParam1bParam2)
{
    return 
FMRES_SUPERCEDE


public 
CBaseWeapon__AddToPlayer__PostpEntity pPlayer )
{
    if( !
pev_validpEntity ) && !is_user_connectedpPlayer ) ) 
    {
         return 
HAM_IGNORED;
    }
    
    if( 
pevpEntitypev_impulse) == WEAP_KEY )
    {
        
g_pWeaponApPlayer ]  = true;
        
        
UTIL__WeaponListpPlayer,  WEAPON_LIST AMMO__WEAPON , -, -4  g_iWeaponID );

        return 
HAM_IGNORED  ;
    }
    else
    {
        
UTIL__WeaponListpPlayer,  WEAPON_BASE_NAME AMMO__WEAPON , -, -4  g_iWeaponID )
    }    

    return 
HAM_IGNORED;
}

public 
CBaseWeapon__Deploy__PostpEntity )
{
    if( !
IsValidPrivateDatapEntity ) )
    {
                return 
HAM_IGNORED;
    }
    
    static 
pId 
    pId 
get_pdata_cbasepEntity OFFSET_WEAPONOWNER OFFSET_LINUX_WEAPONS );
    
    if ( !
g_pWeaponApId ] )
    {
        return 
HAM_IGNORED;
    }    
    
    
set_pevpIdpev_viewmodel2V_MODEL);
    
set_pevpIdpev_weaponmodel2P_MODEL);
    
    
set_pdata_floatpIdm_flNextAttack1.0OFFSET_LINUX );
    
set_pdata_floatpEntitym_flTimeWeaponIdle1.0 OFFSET_LINUX_WEAPONS );
    
set_pdata_stringpIdm_szAnimExtention 4"rifle" , -1OFFSET_LINUX 4);
    
    
UTIL_SenwWeaponAnimpIdDRAW );
    
    return 
HAM_IGNORED ;
}

public 
CBaseWeapon__PrimaryAttack__Pre(pEntity)
{
    if( !
IsValidPrivateDatapEntity ) )
    {
        return 
HAM_IGNORED;
    }

    static     
pId  pId get_pdata_cbasepEntity OFFSET_WEAPONOWNER OFFSET_LINUX_WEAPONS );
    static 
iClip iClip get_pdata_intpEntitym_iClipOFFSET_LINUX_WEAPONS );
    
    static 
FloatvecPuncheAngle];

    if ( !
HoldCBaseWeaponpId ) || iClip <= )
    {
        return 
HAM_IGNORED;
    }
    
    
g_iForwardIndex register_forwardFM_PlaybackEvent"Forward_PlayBackEvent" false )
    
    
pev(pIdpev_punchanglevecPuncheAngle);
    
ExecuteHam(Ham_Weapon_PrimaryAttackpEntity);
    
set_pev(pIdpev_punchangleFloat:{ -5.00.00.0 });
    
    
Ball__CreatepId )
    
    
emit_soundpIdCHAN_WEAPONWEAPON_SOUND_FIREVOL_NORMATTN_NORM0PITCH_NORM );
    
UTIL_SenwWeaponAnimpIdSHOOT_1 );
    
    
set_pdata_floatpEntitym_flNextPrimaryAttack WEAPON__SPEED OFFSET_LINUX_WEAPONS );
    
set_pdata_floatpEntitym_flTimeWeaponIdleWEAPON__SPEED 3.0  OFFSET_LINUX_WEAPONS );
    
    
unregister_forward(FM_PlaybackEventg_iForwardIndex false);
    
    return 
HAM_SUPERCEDE;
}

Ball__Create (  const pId )
{
    static 
pEntity;

    if ( ( 
pEntity engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"env_sprite") ) ) )
    {
        static 
Float:vf_vOrigin] , Floatvf_vAngle]; 
        
engfuncEngFunc_GetAttachment pId vf_vOrigin vf_vAngle )
        
        
set_pev pEntitypev_classname BALL__CLASSNAME );
        
set_pev pEntitypev_movetypeMOVETYPE_FLY );
        
set_pev pEntitypev_solidSOLID_SLIDEBOX   );
        
        
engfunc EngFunc_SetModel pEntityR_MODEL );
        
engfunc EngFunc_SetOriginpEntityvf_vOrigin );
        
engfunc EngFunc_SetSize  pEntityFloat:{ 0.00.00.0 }, Float:{ 0.00.00.0 } );
        
        
set_pev pEntitypev_renderfxkRenderFxGlowShell );
        
set_pev pEntitypev_rendermodekRenderTransAdd );
        
set_pev pEntitypev_renderamt,   255.0 )
        
set_pev pEntitypev_scale random_floatrandom_float0.1 0.2 ) , random_float0.3 0.4 ) ) );
        
set_pev pEntitypev_iuser1 pId );
        
        static 
Float:vf_vVelocity];
        
velocity_by_aimpIdBALL__SPEEDvf_vVelocity );
        
set_pevpEntitypev_velocityvf_vVelocity );

        static 
Float:vf_vAngles];
        
engfuncEngFunc_VecToAnglesvf_vVelocityvf_vAngles );
        
set_pevpEntitypev_anglesvf_vAngles );
    }
}

public 
CBaseWeapon__PostFrame__PrepEntity 
{
    if( !
IsValidPrivateDatapEntity ) )
    {
                return 
HAM_IGNORED;
    }

    static 
pId;
    
pId get_pdata_cbasepEntity OFFSET_WEAPONOWNER OFFSET_LINUX_WEAPONS );

    if ( !
is_user_connectedpId ) && !HoldCBaseWeaponpId ) )
    {
        return 
HAM_IGNORED;
    }
    
    static 
fInReload fInReload get_pdata_intpEntity54OFFSET_LINUX_WEAPONS );
    static 
Float:flNextAttack flNextAttack get_pdata_floatpIdm_flNextAttackOFFSET_LINUX_WEAPONS );
    static 
iClip iClip get_pdata_intpEntitym_iClipOFFSET_LINUX_WEAPONS );
    static 
iAmmoType iAmmoType 376 get_pdata_intpEntity49OFFSET_LINUX_WEAPONS );
    static 
iBpAmmo iBpAmmo  get_pdata_intpIdiAmmoTypeOFFSET_LINUX );
    
    if ( 
fInReload && flNextAttack <= RELOAD_TIME )
    {
        static  
minCLIP__WEAPON  iClipiBpAmmo);
    
        
set_pdata_intpEntitym_iClipiClip jOFFSET_LINUX_WEAPONS );
        
set_pdata_intpIdiAmmoTypeiBpAmmo-jOFFSET_LINUX );
        
set_pdata_intpEntity540OFFSET_LINUX_WEAPONS );
    }     
    
    return 
HAM_IGNORED;
}

public 
CBaseWeapon__Reload_Pre(pEntity
{
    if( !
IsValidPrivateDatapEntity ) )
    {
        return 
HAM_IGNORED;
    }

    static 
pId;
    
pId get_pdata_cbasepEntity OFFSET_WEAPONOWNER OFFSET_LINUX_WEAPONS );
    
    static 
iAmmoType iAmmoType 376 get_pdata_intpEntity49OFFSET_LINUX_WEAPONS );
    static 
iBpAmmo iBpAmmo get_pdata_intpIdiAmmoTypeOFFSET_LINUX );
    static 
iClip iClip get_pdata_intpEntitym_iClipOFFSET_LINUX );
    
    if ( 
iBpAmmo <= || iClip >= CLIP__WEAPON )
    {
        return 
HAM_SUPERCEDE;
    } 
    
    
set_pdata_intpEntitym_iClip0OFFSET_LINUX_WEAPONS );
    
ExecuteHamHam_Weapon_ReloadpEntity    );
    
set_pdata_intpEntitym_iClipiClipOFFSET_LINUX_WEAPONS );

    if ( !
is_user_connectedpId ) || !HoldCBaseWeaponpId ) )
    {
        return 
HAM_IGNORED;
    }
    
    
set_pdata_floatpIdm_flNextAttackRELOAD_TIME OFFSET_LINUX);
    
set_pdata_floatpEntitym_flTimeWeaponIdleRELOAD_TIME OFFSET_LINUX_WEAPONS );
    
    
UTIL_SenwWeaponAnim(pIdRELOAD);
    
    return 
HAM_SUPERCEDE;
}

public 
CBaseWeapon__Idle_PrepEntity )
{
    if( !
IsValidPrivateDatapEntity ) )
    {
                return 
HAM_IGNORED;
    }

    static 
pId;
    
pId get_pdata_cbasepEntity OFFSET_WEAPONOWNER OFFSET_LINUX_WEAPONS );
    
    
ExecuteHamBHam_Weapon_ResetEmptySoundpEntity );
    
    if (
get_pdata_int(pEntitym_flTimeWeaponIdleOFFSET_LINUX_WEAPONS) > 0.0)
    {
        return 
HAM_IGNORED;
    }

    if ( !
HoldCBaseWeaponpId ) )
    {
        return 
HAM_IGNORED;
    }

    
UTIL_SenwWeaponAnim pIdIDLE );
    
set_pdata_floatpEntitym_flTimeWeaponIdlerandom_float5.0 15.0 ) , OFFSET_LINUX_WEAPONS );

    return 
HAM_SUPERCEDE;
}

public 
CBase__TraceAttack_Pre(const iEntity, const iAttacker, const FloatflDamage)
{
    if ( 
is_user_connectediAttacker ) && HoldCBaseWeaponiAttacker )  )
    {
        return 
HAM_SUPERCEDE;
    }
    
    return 
HAM_IGNORED;
}


public 
Forward_Touch( const pEntity , const i_Other )
{
    if( !
pev_validpEntity ) ) 
    {
        return 
FMRES_IGNORED ;
    }
    
    static  
g_classname32 ]  ; 
    
pevpEntitypev_classnameg_classname31 )
    
    if( 
equalig_classnameBALL__CLASSNAME ) )
    {
        static 
Float:flOrigin];
        
pevpEntitypev_originflOrigin );
        
        
engfuncEngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYflOrigin);
        
write_byteTE_EXPLOSION );
        
engfuncEngFunc_WriteCoordflOrigin] );
        
engfuncEngFunc_WriteCoordflOrigin] );
        
engfuncEngFunc_WriteCoordflOrigin] );
        
write_shortg_iExpSprite );
        
write_byte);
        
write_byte15 );
        
write_byteTE_EXPLFLAG_NOPARTICLES TE_EXPLFLAG_NOSOUND );
        
message_end( );
        
        
emit_soundpEntityCHAN_WEAPONWEAPON_SOUND_BOMB VOL_NORMATTN_NORM0PITCH_NORM );

        static 
pOwner pevVictim ;  
        
pOwner pevpEntitypev_iuser1 ); pevVictim  = -1;
        
        while( ( 
pevVictim engfuncEngFunc_FindEntityInSpherepevVictimflOriginBALL__RADIUS) ) != )
        {
            if( !
is_user_alivepevVictim ) )
                    continue;
                    
            if( !
zp_get_user_zombiepevVictim ) )
                continue;
                
            
ExecuteHamBHam_TakeDamagepevVictimpEntitypOwnerBALL__DAMAGEDMG_SONIC );
        }
        
engfuncEngFunc_RemoveEntity pEntity );
    }
    return 
FMRES_IGNORED ;
}

stock UTIL__DropWeapons(idbitsDropType)
{
    static 
weapons[32], numiweaponid
    num 

    get_user_weapons
(idweaponsnum)
    
    for (
0numi++)
    {
        
weaponid weapons[i]
        
        if ((
bitsDropType == DROP_PRIMARY && ((1<<weaponid) & WEAPONS_PRIMARY_BITSUM)) || (bitsDropType == DROP_SECONDARY && ((1<<weaponid) & WEAPONS_SECONDARY_BITSUM)))
        {
            static 
wname[32]
            
get_weaponname(weaponidwnamecharsmax(wname))
            
            
engclient_cmd(id"drop"wname)
        }
    }
}

stock fm_find_ent_by_owner(entity, const classname[], owner)
{
    while ((
entity engfunc(EngFunc_FindEntityByStringentity"classname"classname)) && pev(entitypev_owner) != owner) { /* keep looping */ }
    return 
entity;
}

stock UTIL_SenwWeaponAnim(const pPlayer, const Sequence)
{
    
set_pev(pPlayerpev_weaponanimSequence)
    
    
message_begin(MSG_ONE_UNRELIABLESVC_WEAPONANIM, .player pPlayer)
    
write_byte(Sequence)
    
write_byte(pev(pPlayerpev_body))
    
message_end()
}

UTIL__WeaponListpPlayer, const szWeapon[ ], intint2int3int4int5int6int7int8 )
{
    
message_beginMSG_ONEget_user_msgid"WeaponList" ) , _pPlayer );
    
write_stringszWeapon );
    
write_byte( int );
    
write_byteint2);
    
write_byteint3 );
    
write_byteint4 );
    
write_byteint5 );
    
write_byteint6 );
    
write_byteint7 );
    
write_byteint8 );
    
message_end( );
}

stock fm_give_item(id, const item[])
{
    static 
ent
    ent 
engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocStringitem))
    if (!
pev_valid(ent)) return 0;
    
    static 
Float:originF[3]
    
pev(idpev_originoriginF)
    
set_pev(entpev_originoriginF)
    
set_pev(entpev_spawnflagspev(entpev_spawnflags) | SF_NORESPAWN)
    
dllfunc(DLLFunc_Spawnent)
    
    static 
save
    save 
pev(entpev_solid)
    
dllfunc(DLLFunc_Touchentid)
    if (
pev(entpev_solid) != save)
        return 
ent ;
    
    
engfunc(EngFunc_RemoveEntityent)
    
    return -
1;
}

PRECACHE_SOUNDS_FROM_MODEL(const szModelPath[])
{
    new 
iFile;
    
    if ((
iFile fopen(szModelPath"rt")))
    {
        new 
szSoundPath[64];
        
        new 
iNumSeqiSeqIndex;
        new 
iEventiNumEventsiEventIndex;
        
        
fseek(iFile164SEEK_SET);
        
fread(iFileiNumSeqBLOCK_INT);
        
fread(iFileiSeqIndexBLOCK_INT);
        
        for (new 
k0iNumSeqi++)
        {
            
fseek(iFileiSeqIndex 48 176 iSEEK_SET);
            
fread(iFileiNumEventsBLOCK_INT);
            
fread(iFileiEventIndexBLOCK_INT);
            
fseek(iFileiEventIndex 176 iSEEK_SET);

            for (
0iNumEventsk++)
            {
                
fseek(iFileiEventIndex 76 kSEEK_SET);
                
fread(iFileiEventBLOCK_INT);
                
fseek(iFile4SEEK_CUR);
                
                if (
iEvent != 5004)
                {
                    continue;
                }

                
fread_blocks(iFileszSoundPath64BLOCK_CHAR);
                
                if (
strlen(szSoundPath))
                {
                    
strtolower(szSoundPath);
                    
PRECACHE_SOUND(szSoundPath);
                }
            }
        }
    }
    
    
fclose(iFile);


As you can see when a player buys this rifle then the
PHP Code:

g_pWeaponA true 

How to set it to be
PHP Code:

g_pWeaponA false 

when player drop this weapon?

PHP Code:

public zp_extra_item_selectedpPlayer pItem )
{
    if( 
pItem == g_iItem  )
    {
         
UTIL__DropWeaponspPlayerDROP_PRIMARY )
         
         
g_pWeaponApPlayer ]  = true;
         
         static 
pEntity;
         
pEntity fm_give_itempPlayer WEAPON_BASE_NAME ); 
         
         if( 
pEntity cs_set_weapon_ammopEntityCLIP__WEAPON );    
         
         
cs_set_user_bpammopPlayer g_iWeaponID AMMO__WEAPON );
         
         
UTIL__WeaponListpPlayer,  WEAPON_LIST AMMO__WEAPON , -, -4  g_iWeaponID );
    }    



yas17sin 03-22-2017 20:12

Re: Events when player drop gun
 
something like this :
PHP Code:

public plugin_init()
{
    
register_clcmd("drop""CmdDrop");
}

public 
CmdDrop(id)
{
    if(
is_user_alive(id))
    {
        new 
Weapon;
        
Weapon get_user_weapon(id__);
        if(
Weapon == CSW_M249
        {
            
g_pWeaponA[id] = true;
        }
    }


so it will be like this, not tested :
PHP Code:

#include < amxmodx >
#include < fakemeta >
#include < cstrike >
#include < hamsandwich >
#include < zombieplague >

new const PLUGIN_VERSION[ ]    =  "1.0.0 FINAL";

const 
OFFSET_WEAPONOWNER    =      41
const OFFSET_LINUX    =    5
const OFFSET_LINUX_WEAPONS     =      4

const WEAP_KEY   =    545464464
const MAX_PLAYERS   =        32

const m_flNextPrimaryAttack 46;
const 
m_iClip =    51;
const 
m_flNextAttack 83;
const 
m_flTimeWeaponIdle    48
const 
m_szAnimExtention     492

enum 
( <<=)
{
    
DROP_PRIMARY 1,
    
DROP_SECONDARY
};    

const 
IDLE 
const RELOAD 1
const DRAW 2
const SHOOT_1 3
const SHOOT_END 

#define HoldCBaseWeapon(%0)    ( get_user_weapon( %0 ) == g_iWeaponID  && g_pWeaponA[ %0 ] )
#define IsValidPrivateData(%0)    ( pev_valid( %0 ) == 2 )

#define PRECACHE_MODEL(%0)        engfunc(EngFunc_PrecacheModel, %0)
#define PRECACHE_SOUND(%0)        engfunc(EngFunc_PrecacheSound, %0)
#define PRECACHE_GENERIC(%0)        engfunc(EngFunc_PrecacheGeneric, %0)

new const WEAPON_SOUND_FIRE[ ] = "weapons/plasmagun-1.wav";
new const 
WEAPON_SOUND_BOMB[ ] = "weapons/plasmagun_exp.wav";

new const 
WEAPON_LIST[ ]   =   "weapon_plasmagun";
new const 
WEAPON_BASE_NAME[ ]   =  "weapon_m249";

const 
FloatRELOAD_TIME  =   3.36 //Время перезарядки

const AMMO__WEAPON       =  200 //Кол-во обоймы
const CLIP__WEAPON      =  45 //Кол-во патрон 
const BALL__SPEED         =  2000 //Скорость  

const FloatBALL__DAMAGE       =   200.0 //Урон
const FloatBALL__RADIUS      =  125.0 //Радиус 
const FloatWEAPON__SPEED          0.15 //Скорость орудия 

new const EXTRA_ITEM_NAME[ ]    =   "Plasmagun"//Название в Extra-Items 

new V_MODEL[ ] = "models/v_plasmagun.mdl";
new 
P_MODEL[ ] = "models/p_plasmagun.mdl";
new 
W_MODEL[ ] = "models/w_plasmagun.mdl";

new 
R_MODEL[ ] = "sprites/plasmaball.spr";

new const 
HUD_SPRITES[ ] [ ] = 
{
    
"sprites/640hud3.spr" 
    
"sprites/640hud91.spr"
};

new 
g_iItem  g_iForwardIndex g_iExpSprite  
new 
g_pWeaponAMAX_PLAYERS ] ;
new 
g_iWeaponID 0;

new const 
BALL__CLASSNAME[ ]  =   "zsClassBall";    

const 
WEAPONS_PRIMARY_BITSUM     = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90);
const 
WEAPONS_SECONDARY_BITSUM     = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE);

public 
plugin_precache( )
{
    
PRECACHE_MODELV_MODEL );
    
PRECACHE_MODELP_MODEL );
    
PRECACHE_MODELW_MODEL );
    
PRECACHE_MODELR_MODEL );
    
PRECACHE_SOUNDS_FROM_MODELV_MODEL );
    
    
PRECACHE_SOUNDWEAPON_SOUND_BOMB );
    
PRECACHE_SOUNDWEAPON_SOUND_FIRE );
    
    static 
iFile
    
for( iFile iFile sizeof HUD_SPRITESiFile++ ) 
    {
        
PRECACHE_GENERICHUD_SPRITESiFile ] )
    }    
    
    static 
szFile 128 ];
    
formatex szFile charsmaxszFile ) , "sprites/%s.txt" WEAPON_LIST );
    
PRECACHE_GENERICszFile );
    
    
g_iExpSprite precache_model"sprites/plasmabomb.spr" );
}

public 
plugin_init()
{
    
register_plugin"[CSO] Extra Item PlasmaGun" PLUGIN_VERSION "Shurik07" );
    
register_clcmdWEAPON_LIST"weapon_hook_an" );
    
    
register_forwardFM_SetModel"Forward_SetModel" false );
    
register_forwardFM_UpdateClientData"Forward_UpdateClientData" true );
    
    
RegisterHamHam_Item_AddToPlayerWEAPON_BASE_NAME"CBaseWeapon__AddToPlayer__Post" , .Post true );
    
RegisterHamHam_Item_DeployWEAPON_BASE_NAME "CBaseWeapon__Deploy__Post", .Post true );
    
RegisterHamHam_Weapon_PrimaryAttackWEAPON_BASE_NAME"CBaseWeapon__PrimaryAttack__Pre" , .Post false );
    
RegisterHamHam_Item_PostFrameWEAPON_BASE_NAME"CBaseWeapon__PostFrame__Pre" , .Post false );
    
RegisterHamHam_Weapon_ReloadWEAPON_BASE_NAME"CBaseWeapon__Reload_Pre" , .Post false );
    
RegisterHamHam_Weapon_WeaponIdle,    WEAPON_BASE_NAME,     "CBaseWeapon__Idle_Pre",    false );
    
RegisterHamHam_TraceAttack,    "player",         "CBase__TraceAttack_Pre"false );
    
    
register_forwardFM_Touch "Forward_Touch" );
    
    
register_clcmd("drop""CmdDrop");

    
g_iItem zp_register_extra_itemEXTRA_ITEM_NAME0ZP_TEAM_HUMAN );
    
g_iWeaponID get_weaponidWEAPON_BASE_NAME );
}

public 
zp_extra_item_selectedpPlayer pItem )
{
    if( 
pItem == g_iItem  )
    {
         
UTIL__DropWeaponspPlayerDROP_PRIMARY )
         
         
g_pWeaponApPlayer ]  = true;
         
         static 
pEntity;
         
pEntity fm_give_itempPlayer WEAPON_BASE_NAME ); 
         
         if( 
pEntity cs_set_weapon_ammopEntityCLIP__WEAPON );    
         
         
cs_set_user_bpammopPlayer g_iWeaponID AMMO__WEAPON );
         
         
UTIL__WeaponListpPlayer,  WEAPON_LIST AMMO__WEAPON , -, -4  g_iWeaponID );
    }    
}
public 
CmdDrop(id)
{
    if(
is_user_alive(id))
    {
        new 
Weapon;
        
Weapon get_user_weapon(id__);
        if(
Weapon == CSW_M249
        {
            
g_pWeaponA[id] = false
        
}
    }
}
public 
weapon_hook_anpPlayer  
{
    
engclient_cmdpPlayerWEAPON_BASE_NAME);
    return 
PLUGIN_HANDLED;
}

public 
zp_user_humanized_postpPlayer )
{
    
g_pWeaponApPlayer ] = false;
}

public 
client_disconnectpPlayer )
{
    
g_pWeaponApPlayer ]  = false;
}

public 
Forward_SetModelpEntity, const pModel[ ] )
{
    if( !
pev_validpEntity ) ) 
    {
        return 
FMRES_IGNORED;
    }    
    
    static 
szClassName 33 ]
    
pevpEntitypev_classnameszClassNamecharsmax(szClassName) );
        
    if( !
equal szClassName"weaponbox" ) )
    {
        return 
FMRES_IGNORED;
    }    
    
    static 
pOwner pModel
    pModel 
fm_find_ent_by_owner ( -1WEAPON_BASE_NAMEpEntity );
    
pOwner pev pEntitypev_owner );
    
    if ( 
g_pWeaponA pOwner ]  && pev_valid pModel ) )
    {
        
set_pevpModel pev_impulse WEAP_KEY );
        
engfuncEngFunc_SetModelpEntityW_MODEL );
        
        
g_pWeaponA pOwner ]   = false;
        return 
FMRES_SUPERCEDE;
    }

    return 
FMRES_IGNORED;
}

public 
Forward_UpdateClientDatapPlayer SendWeaponsCD_Handle )
{
    if ( !
HoldCBaseWeaponpPlayer ) )
    {
        return 
HAM_IGNORED;
    }

    static 
Float:fGametime;
    
fGametime get_gametime( );
    
    
set_cd CD_HandleCD_flNextAttackfGametime 0.001 );

    return 
FMRES_HANDLED;
}

public 
Forward_PlayBackEvent(flagsinvokereventindexFloat:delayFloat:origin[3], Float:fvangles[3], Float:fparam1Float:fparam2iParam1iParam2bParam1bParam2)
{
    return 
FMRES_SUPERCEDE


public 
CBaseWeapon__AddToPlayer__PostpEntity pPlayer )
{
    if( !
pev_validpEntity ) && !is_user_connectedpPlayer ) ) 
    {
         return 
HAM_IGNORED;
    }
    
    if( 
pevpEntitypev_impulse) == WEAP_KEY )
    {
        
g_pWeaponApPlayer ]  = true;
        
        
UTIL__WeaponListpPlayer,  WEAPON_LIST AMMO__WEAPON , -, -4  g_iWeaponID );

        return 
HAM_IGNORED  ;
    }
    else
    {
        
UTIL__WeaponListpPlayer,  WEAPON_BASE_NAME AMMO__WEAPON , -, -4  g_iWeaponID )
    }    

    return 
HAM_IGNORED;
}

public 
CBaseWeapon__Deploy__PostpEntity )
{
    if( !
IsValidPrivateDatapEntity ) )
    {
                return 
HAM_IGNORED;
    }
    
    static 
pId 
    pId 
get_pdata_cbasepEntity OFFSET_WEAPONOWNER OFFSET_LINUX_WEAPONS );
    
    if ( !
g_pWeaponApId ] )
    {
        return 
HAM_IGNORED;
    }    
    
    
set_pevpIdpev_viewmodel2V_MODEL);
    
set_pevpIdpev_weaponmodel2P_MODEL);
    
    
set_pdata_floatpIdm_flNextAttack1.0OFFSET_LINUX );
    
set_pdata_floatpEntitym_flTimeWeaponIdle1.0 OFFSET_LINUX_WEAPONS );
    
set_pdata_stringpIdm_szAnimExtention 4"rifle" , -1OFFSET_LINUX 4);
    
    
UTIL_SenwWeaponAnimpIdDRAW );
    
    return 
HAM_IGNORED ;
}

public 
CBaseWeapon__PrimaryAttack__Pre(pEntity)
{
    if( !
IsValidPrivateDatapEntity ) )
    {
        return 
HAM_IGNORED;
    }

    static     
pId  pId get_pdata_cbasepEntity OFFSET_WEAPONOWNER OFFSET_LINUX_WEAPONS );
    static 
iClip iClip get_pdata_intpEntitym_iClipOFFSET_LINUX_WEAPONS );
    
    static 
FloatvecPuncheAngle];

    if ( !
HoldCBaseWeaponpId ) || iClip <= )
    {
        return 
HAM_IGNORED;
    }
    
    
g_iForwardIndex register_forwardFM_PlaybackEvent"Forward_PlayBackEvent" false )
    
    
pev(pIdpev_punchanglevecPuncheAngle);
    
ExecuteHam(Ham_Weapon_PrimaryAttackpEntity);
    
set_pev(pIdpev_punchangleFloat:{ -5.00.00.0 });
    
    
Ball__CreatepId )
    
    
emit_soundpIdCHAN_WEAPONWEAPON_SOUND_FIREVOL_NORMATTN_NORM0PITCH_NORM );
    
UTIL_SenwWeaponAnimpIdSHOOT_1 );
    
    
set_pdata_floatpEntitym_flNextPrimaryAttack WEAPON__SPEED OFFSET_LINUX_WEAPONS );
    
set_pdata_floatpEntitym_flTimeWeaponIdleWEAPON__SPEED 3.0  OFFSET_LINUX_WEAPONS );
    
    
unregister_forward(FM_PlaybackEventg_iForwardIndex false);
    
    return 
HAM_SUPERCEDE;
}

Ball__Create (  const pId )
{
    static 
pEntity;

    if ( ( 
pEntity engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"env_sprite") ) ) )
    {
        static 
Float:vf_vOrigin] , Floatvf_vAngle]; 
        
engfuncEngFunc_GetAttachment pId vf_vOrigin vf_vAngle )
        
        
set_pev pEntitypev_classname BALL__CLASSNAME );
        
set_pev pEntitypev_movetypeMOVETYPE_FLY );
        
set_pev pEntitypev_solidSOLID_SLIDEBOX   );
        
        
engfunc EngFunc_SetModel pEntityR_MODEL );
        
engfunc EngFunc_SetOriginpEntityvf_vOrigin );
        
engfunc EngFunc_SetSize  pEntityFloat:{ 0.00.00.0 }, Float:{ 0.00.00.0 } );
        
        
set_pev pEntitypev_renderfxkRenderFxGlowShell );
        
set_pev pEntitypev_rendermodekRenderTransAdd );
        
set_pev pEntitypev_renderamt,   255.0 )
        
set_pev pEntitypev_scale random_floatrandom_float0.1 0.2 ) , random_float0.3 0.4 ) ) );
        
set_pev pEntitypev_iuser1 pId );
        
        static 
Float:vf_vVelocity];
        
velocity_by_aimpIdBALL__SPEEDvf_vVelocity );
        
set_pevpEntitypev_velocityvf_vVelocity );

        static 
Float:vf_vAngles];
        
engfuncEngFunc_VecToAnglesvf_vVelocityvf_vAngles );
        
set_pevpEntitypev_anglesvf_vAngles );
    }
}

public 
CBaseWeapon__PostFrame__PrepEntity 
{
    if( !
IsValidPrivateDatapEntity ) )
    {
                return 
HAM_IGNORED;
    }

    static 
pId;
    
pId get_pdata_cbasepEntity OFFSET_WEAPONOWNER OFFSET_LINUX_WEAPONS );

    if ( !
is_user_connectedpId ) && !HoldCBaseWeaponpId ) )
    {
        return 
HAM_IGNORED;
    }
    
    static 
fInReload fInReload get_pdata_intpEntity54OFFSET_LINUX_WEAPONS );
    static 
Float:flNextAttack flNextAttack get_pdata_floatpIdm_flNextAttackOFFSET_LINUX_WEAPONS );
    static 
iClip iClip get_pdata_intpEntitym_iClipOFFSET_LINUX_WEAPONS );
    static 
iAmmoType iAmmoType 376 get_pdata_intpEntity49OFFSET_LINUX_WEAPONS );
    static 
iBpAmmo iBpAmmo  get_pdata_intpIdiAmmoTypeOFFSET_LINUX );
    
    if ( 
fInReload && flNextAttack <= RELOAD_TIME )
    {
        static  
minCLIP__WEAPON  iClipiBpAmmo);
    
        
set_pdata_intpEntitym_iClipiClip jOFFSET_LINUX_WEAPONS );
        
set_pdata_intpIdiAmmoTypeiBpAmmo-jOFFSET_LINUX );
        
set_pdata_intpEntity540OFFSET_LINUX_WEAPONS );
    }     
    
    return 
HAM_IGNORED;
}

public 
CBaseWeapon__Reload_Pre(pEntity
{
    if( !
IsValidPrivateDatapEntity ) )
    {
        return 
HAM_IGNORED;
    }

    static 
pId;
    
pId get_pdata_cbasepEntity OFFSET_WEAPONOWNER OFFSET_LINUX_WEAPONS );
    
    static 
iAmmoType iAmmoType 376 get_pdata_intpEntity49OFFSET_LINUX_WEAPONS );
    static 
iBpAmmo iBpAmmo get_pdata_intpIdiAmmoTypeOFFSET_LINUX );
    static 
iClip iClip get_pdata_intpEntitym_iClipOFFSET_LINUX );
    
    if ( 
iBpAmmo <= || iClip >= CLIP__WEAPON )
    {
        return 
HAM_SUPERCEDE;
    } 
    
    
set_pdata_intpEntitym_iClip0OFFSET_LINUX_WEAPONS );
    
ExecuteHamHam_Weapon_ReloadpEntity    );
    
set_pdata_intpEntitym_iClipiClipOFFSET_LINUX_WEAPONS );

    if ( !
is_user_connectedpId ) || !HoldCBaseWeaponpId ) )
    {
        return 
HAM_IGNORED;
    }
    
    
set_pdata_floatpIdm_flNextAttackRELOAD_TIME OFFSET_LINUX);
    
set_pdata_floatpEntitym_flTimeWeaponIdleRELOAD_TIME OFFSET_LINUX_WEAPONS );
    
    
UTIL_SenwWeaponAnim(pIdRELOAD);
    
    return 
HAM_SUPERCEDE;
}

public 
CBaseWeapon__Idle_PrepEntity )
{
    if( !
IsValidPrivateDatapEntity ) )
    {
                return 
HAM_IGNORED;
    }

    static 
pId;
    
pId get_pdata_cbasepEntity OFFSET_WEAPONOWNER OFFSET_LINUX_WEAPONS );
    
    
ExecuteHamBHam_Weapon_ResetEmptySoundpEntity );
    
    if (
get_pdata_int(pEntitym_flTimeWeaponIdleOFFSET_LINUX_WEAPONS) > 0.0)
    {
        return 
HAM_IGNORED;
    }

    if ( !
HoldCBaseWeaponpId ) )
    {
        return 
HAM_IGNORED;
    }

    
UTIL_SenwWeaponAnim pIdIDLE );
    
set_pdata_floatpEntitym_flTimeWeaponIdlerandom_float5.0 15.0 ) , OFFSET_LINUX_WEAPONS );

    return 
HAM_SUPERCEDE;
}

public 
CBase__TraceAttack_Pre(const iEntity, const iAttacker, const FloatflDamage)
{
    if ( 
is_user_connectediAttacker ) && HoldCBaseWeaponiAttacker )  )
    {
        return 
HAM_SUPERCEDE;
    }
    
    return 
HAM_IGNORED;
}


public 
Forward_Touch( const pEntity , const i_Other )
{
    if( !
pev_validpEntity ) ) 
    {
        return 
FMRES_IGNORED ;
    }
    
    static  
g_classname32 ]  ; 
    
pevpEntitypev_classnameg_classname31 )
    
    if( 
equalig_classnameBALL__CLASSNAME ) )
    {
        static 
Float:flOrigin];
        
pevpEntitypev_originflOrigin );
        
        
engfuncEngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYflOrigin);
        
write_byteTE_EXPLOSION );
        
engfuncEngFunc_WriteCoordflOrigin] );
        
engfuncEngFunc_WriteCoordflOrigin] );
        
engfuncEngFunc_WriteCoordflOrigin] );
        
write_shortg_iExpSprite );
        
write_byte);
        
write_byte15 );
        
write_byteTE_EXPLFLAG_NOPARTICLES TE_EXPLFLAG_NOSOUND );
        
message_end( );
        
        
emit_soundpEntityCHAN_WEAPONWEAPON_SOUND_BOMB VOL_NORMATTN_NORM0PITCH_NORM );

        static 
pOwner pevVictim ;  
        
pOwner pevpEntitypev_iuser1 ); pevVictim  = -1;
        
        while( ( 
pevVictim engfuncEngFunc_FindEntityInSpherepevVictimflOriginBALL__RADIUS) ) != )
        {
            if( !
is_user_alivepevVictim ) )
                    continue;
                    
            if( !
zp_get_user_zombiepevVictim ) )
                continue;
                
            
ExecuteHamBHam_TakeDamagepevVictimpEntitypOwnerBALL__DAMAGEDMG_SONIC );
        }
        
engfuncEngFunc_RemoveEntity pEntity );
    }
    return 
FMRES_IGNORED ;
}

stock UTIL__DropWeapons(idbitsDropType)
{
    static 
weapons[32], numiweaponid
    num 

    get_user_weapons
(idweaponsnum)
    
    for (
0numi++)
    {
        
weaponid weapons[i]
        
        if ((
bitsDropType == DROP_PRIMARY && ((1<<weaponid) & WEAPONS_PRIMARY_BITSUM)) || (bitsDropType == DROP_SECONDARY && ((1<<weaponid) & WEAPONS_SECONDARY_BITSUM)))
        {
            static 
wname[32]
            
get_weaponname(weaponidwnamecharsmax(wname))
            
            
engclient_cmd(id"drop"wname)
        }
    }
}

stock fm_find_ent_by_owner(entity, const classname[], owner)
{
    while ((
entity engfunc(EngFunc_FindEntityByStringentity"classname"classname)) && pev(entitypev_owner) != owner) { /* keep looping */ }
    return 
entity;
}

stock UTIL_SenwWeaponAnim(const pPlayer, const Sequence)
{
    
set_pev(pPlayerpev_weaponanimSequence)
    
    
message_begin(MSG_ONE_UNRELIABLESVC_WEAPONANIM, .player pPlayer)
    
write_byte(Sequence)
    
write_byte(pev(pPlayerpev_body))
    
message_end()
}

UTIL__WeaponListpPlayer, const szWeapon[ ], intint2int3int4int5int6int7int8 )
{
    
message_beginMSG_ONEget_user_msgid"WeaponList" ) , _pPlayer );
    
write_stringszWeapon );
    
write_byte( int );
    
write_byteint2);
    
write_byteint3 );
    
write_byteint4 );
    
write_byteint5 );
    
write_byteint6 );
    
write_byteint7 );
    
write_byteint8 );
    
message_end( );
}

stock fm_give_item(id, const item[])
{
    static 
ent
    ent 
engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocStringitem))
    if (!
pev_valid(ent)) return 0;
    
    static 
Float:originF[3]
    
pev(idpev_originoriginF)
    
set_pev(entpev_originoriginF)
    
set_pev(entpev_spawnflagspev(entpev_spawnflags) | SF_NORESPAWN)
    
dllfunc(DLLFunc_Spawnent)
    
    static 
save
    save 
pev(entpev_solid)
    
dllfunc(DLLFunc_Touchentid)
    if (
pev(entpev_solid) != save)
        return 
ent ;
    
    
engfunc(EngFunc_RemoveEntityent)
    
    return -
1;
}

PRECACHE_SOUNDS_FROM_MODEL(const szModelPath[])
{
    new 
iFile;
    
    if ((
iFile fopen(szModelPath"rt")))
    {
        new 
szSoundPath[64];
        
        new 
iNumSeqiSeqIndex;
        new 
iEventiNumEventsiEventIndex;
        
        
fseek(iFile164SEEK_SET);
        
fread(iFileiNumSeqBLOCK_INT);
        
fread(iFileiSeqIndexBLOCK_INT);
        
        for (new 
k0iNumSeqi++)
        {
            
fseek(iFileiSeqIndex 48 176 iSEEK_SET);
            
fread(iFileiNumEventsBLOCK_INT);
            
fread(iFileiEventIndexBLOCK_INT);
            
fseek(iFileiEventIndex 176 iSEEK_SET);

            for (
0iNumEventsk++)
            {
                
fseek(iFileiEventIndex 76 kSEEK_SET);
                
fread(iFileiEventBLOCK_INT);
                
fseek(iFile4SEEK_CUR);
                
                if (
iEvent != 5004)
                {
                    continue;
                }

                
fread_blocks(iFileszSoundPath64BLOCK_CHAR);
                
                if (
strlen(szSoundPath))
                {
                    
strtolower(szSoundPath);
                    
PRECACHE_SOUND(szSoundPath);
                }
            }
        }
    }
    
    
fclose(iFile);



EFFx 03-22-2017 20:16

Re: Events when player drop gun
 
PHP Code:

register_clcmd("drop""cmdDrop"

PHP Code:

public cmdDrop(id)
{
    if(
get_user_weapon(id) == CSW_M249)
    {
        if(
g_pWeaponA[id])
        {
            
g_pWeaponA[id] = false
        
}
    }



PRoSToTeM@ 03-22-2017 20:19

Re: Events when player drop gun
 
It is already implemented in Forward_SetModel.

yas17sin 03-22-2017 20:34

Re: Events when player drop gun
 
the code give him will work or not ? it should.

Natsheh 03-22-2017 21:11

Re: Events when player drop gun
 
Quote:

Originally Posted by EFFx (Post 2505857)
PHP Code:

register_clcmd("drop""cmdDrop"

PHP Code:

public cmdDrop(id)
{
    if(
get_user_weapon(id) & CSW_M249)
    {
        if(
g_pWeaponA[id])
        {
            
g_pWeaponA[id] = false
        
}
    }



Get_user_weapon dosent return abitsum value its return an integer value so instead of & use ==

Krtola 03-23-2017 03:30

Re: Events when player drop gun
 
EFFx , yas17sin In this case,if I drop gun(deagle,glock etc...) then will be g_pWeaponA[id] = false.

But I need false only when I drop Plasma Gun.

PRoSToTeM@ 03-23-2017 05:27

Re: Events when player drop gun
 
You already have falsing on drop in Forward_SetModel.

yas17sin 03-23-2017 08:03

Re: Events when player drop gun
 
Quote:

Originally Posted by Krtola (Post 2505899)
EFFx , yas17sin In this case,if I drop gun(deagle,glock etc...) then will be g_pWeaponA[id] = false.

But I need false only when I drop Plasma Gun.

yes the weapon code you post is based on M249, so when you drop the plasma gun it will set to false also when you drop the default normal 249, it will set to false but it's not something you shuold be afraid of.

also check the reply, #8. it says all.

Krtola 03-23-2017 08:48

Re: Events when player drop gun
 
I understund now. Problem was in other extra gun who has no that options for w_model. So i just add that options and now problem is fixed
Thanks...Solved


All times are GMT -4. The time now is 18:02.

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