 |
|
AMX Mod X Plugin Approver
|

05-10-2014
, 08:23
Re: How to detach and attach shield entity to player?
|
#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(user, m_bHasPrimary)) { return false; } // Don't give shield if player has already elite weapon. new item = get_pdata_cbase(user, m_rgpPlayerItems + slotSecondary); if (item && get_pdata_int(item, m_iId, 4) == CSW_ELITE) { return false; } // Weapon can't be holstered. new activeItem = get_pdata_cbase(user, m_pActiveItem); if (activeItem && !ExecuteHamB(Ham_Item_CanHolster, activeItem)) { return false; } // Don't give shield to VIP. if (get_pdata_bool(user, m_bIsVIP)) { return false; } } set_pdata_bool(user, m_bOwnsShield, true); set_pdata_bool(user, m_bHasPrimary, true);
new activeItem = get_pdata_cbase(user, m_pActiveItem); if (activeItem) { if (retire) { if (get_pdata_cbase(user, m_rgAmmo + get_pdata_int(activeItem, m_iPrimaryAmmoType, 4)) > 0) { ExecuteHamB(Ham_Item_Holster, activeItem, 0); // No ammo, we holster. } if (!ExecuteHamB(Ham_Item_Deploy, activeItem)) { ExecuteHamB(Ham_Weapon_RetireWeapon, activeItem); // We can't deploy, so we retire weapon. } } } if (pickupSound) { emit_sound(user, CHAN_AUTO, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM); } set_pev(user, pev_gamestate, 0); return true; }
__________________
Last edited by Arkshine; 05-10-2014 at 08:38.
|
|
|
|