AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [CS:GO] Check if player has Revolver or Deagle in loadout (https://forums.alliedmods.net/showthread.php?t=331958)

eyal282 04-15-2021 18:03

[CS:GO] Check if player has Revolver or Deagle in loadout
 
This stock allows you to know if someone has revolver or deagle, also allows to know if someone has m4a1-s or m4a4. Also allows to know if someone has tec-9 or cz75a.

Example: CS_IsWeaponInLoadout(client, LOADOUT_POSITION_SECONDARY4, CSWeapon_Deagle);
Example: CS_IsWeaponInLoadout(client, LOADOUT_POSITION_RIFLE1, CSWeapon_M4A1);
Example: CS_IsWeaponInLoadout(client, LOADOUT_POSITION_SECONDARY3, CSWeapon_CZ75A);

Code:

//-----------------------------------------------------------------------------
// Purpose: Slots for items within loadouts
// NOTE: Explicitly numbered slots are for shipped features with the number saved in the database, do not renumber.
// Some legacy entries in the enum are still here and some game code uses them, but are not yet shipped and would be
// safe to renumber or remove if needed
//-----------------------------------------------------------------------------
enum loadout_positions_t
{
        LOADOUT_POSITION_INVALID                = -1,

        LOADOUT_POSITION_MELEE                        = 0,
        LOADOUT_POSITION_C4                                = 1,

        LOADOUT_POSITION_SECONDARY0 = 2,
        LOADOUT_POSITION_SECONDARY1 = 3,
        LOADOUT_POSITION_SECONDARY2 = 4,
        LOADOUT_POSITION_SECONDARY3 = 5,
        LOADOUT_POSITION_SECONDARY4 = 6,
        LOADOUT_POSITION_SECONDARY5 = 7, // Unused, no instances in database yet

        LOADOUT_POSITION_SMG0 = 8,
        LOADOUT_POSITION_SMG1 = 9,
        LOADOUT_POSITION_SMG2 = 10,
        LOADOUT_POSITION_SMG3 = 11,
        LOADOUT_POSITION_SMG4 = 12,
        LOADOUT_POSITION_SMG5 = 13, // Unused, no instances in database yet

        LOADOUT_POSITION_RIFLE0 = 14,
        LOADOUT_POSITION_RIFLE1 = 15,
        LOADOUT_POSITION_RIFLE2 = 16,
        LOADOUT_POSITION_RIFLE3 = 17,
        LOADOUT_POSITION_RIFLE4 = 18,
        LOADOUT_POSITION_RIFLE5 = 19,

        LOADOUT_POSITION_HEAVY0 = 20,
        LOADOUT_POSITION_HEAVY1 = 21,
        LOADOUT_POSITION_HEAVY2 = 22,
        LOADOUT_POSITION_HEAVY3 = 23,
        LOADOUT_POSITION_HEAVY4 = 24,
        LOADOUT_POSITION_HEAVY5        = 25, // Unused, no instances in database yet
};

stock bool CS_IsWeaponInLoadout(client, loadout_positions_t loadoutPos, CSWeaponID WepID)
{
        if(CS_WeaponIDToItemDefIndex(WepID) == GetEntProp(client, Prop_Send, "m_EquippedLoadoutItemDefIndices", _, loadoutPos))
                return true;
   
        return false;
}


kratoss1812 04-16-2021 09:19

Re: [CS:GO] Check if player has Revolver or Deagle in loadout
 
lovely, thanks for sharing !


All times are GMT -4. The time now is 23:44.

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