Raised This Month: $ Target: $400
 0% 

How to detach and attach shield entity to player?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-10-2014 , 08:23   Re: How to detach and attach shield entity to player?
Reply With Quote #6

Troll apart, here cs_set_user_shield() and cs_remove_user_shield().


PHP Code:
stock cs_remove_user_shield(user)
{
    return 
amxclient_cmd(user"drop""weapon_shield");

PHP Code:
stock bool:cs_set_user_shield(const user, const bool:retire true, const bool:gameCheck true, const bool:pickupSound true)
{
    const 
m_bHasPrimary      464;         // player
    
const m_bIsVIP           837;         // player
    
const m_bOwnsShield      2043;        // player
    
const m_pActiveItem      1492 4;    // player
    
const m_rgpPlayerItems   1468 4;    // player
    
const m_rgAmmo           1504 4     // player
    
const m_iPrimaryAmmoType 208  4;    // weapon
    
const m_iId              168  4;    // weapon
    
    // Sanity check.
    
if (gameCheck)
    {
        const 
slotSecondary 2;
    
        
// Not a player or has already a primary weapon
        
if( !is_user_alive(user) || get_pdata_bool(userm_bHasPrimary))
        {
            return 
false;
        }
        
        
// Don't give shield if player has already elite weapon.
        
new item get_pdata_cbase(userm_rgpPlayerItems slotSecondary);
        if (
item && get_pdata_int(itemm_iId4) == CSW_ELITE)
        {
            return 
false;
        }
        
        
// Weapon can't be holstered.
        
new activeItem get_pdata_cbase(userm_pActiveItem);
        if (
activeItem && !ExecuteHamB(Ham_Item_CanHolsteractiveItem))
        {
            return 
false;
        }
    
        
// Don't give shield to VIP.
        
if (get_pdata_bool(userm_bIsVIP))
        {
            return 
false;
        }
    }
    
    
set_pdata_bool(userm_bOwnsShieldtrue);
    
set_pdata_bool(userm_bHasPrimarytrue);

    new 
activeItem get_pdata_cbase(userm_pActiveItem);
    if (
activeItem)
    {
        if (
retire)
        {
            if (
get_pdata_cbase(userm_rgAmmo get_pdata_int(activeItemm_iPrimaryAmmoType4)) > 0)
            {
                
ExecuteHamB(Ham_Item_HolsteractiveItem0);       // No ammo, we holster.
            
}
            
            if (!
ExecuteHamB(Ham_Item_DeployactiveItem))
            {
                
ExecuteHamB(Ham_Weapon_RetireWeaponactiveItem);   // We can't deploy, so we retire weapon.
            
}
        }
    }
    
    if (
pickupSound)
    {
        
emit_sound(userCHAN_AUTO"items/gunpickup2.wav"VOL_NORMATTN_NORM0PITCH_NORM);
    }
    
    
set_pev(userpev_gamestate0);
    
    return 
true;

__________________

Last edited by Arkshine; 05-10-2014 at 08:38.
Arkshine is offline
 



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 09:48.


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