Raised This Month: $51 Target: $400
 12% 

Solved [CS:GO] How to get a Count of players inventory item?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Austin
Senior Member
Join Date: Oct 2005
Old 06-17-2023 , 13:23   [CS:GO] How to get a Count of players inventory item?
Reply With Quote #1

I have the following that list out each item a player has in their inventory
but it doesn't give me a count and
even if they have two of something
it only prints out once so I can't do a count on them.

How would I for example get the number of healthshots a player has?
tx

PHP Code:
int arraysize GetEntPropArraySize(clientProp_Send"m_hMyWeapons");
for(
int x 0arraysizex++)
{
    
entity GetEntPropEnt(clientProp_Send"m_hMyWeapons"x);
    if(
entity != -1)
    {
        
GetEntityClassname(entityclassnamesizeof(classname));
        
PrintToServer("iNVENTORY iTEM = %s"classname); 
        
        
CS_GetTranslatedWeaponAlias(classnameclassnamesizeof(classname));
        
CSWeaponID weaponID CS_AliasToWeaponID(classname);

        if(
weaponID == CSWeapon_HEALTHSHOT)
            
PrintToServer("INVENTORY iTEM = %s"classname);
    }


Last edited by Austin; 07-01-2023 at 20:40.
Austin is offline
Austin
Senior Member
Join Date: Oct 2005
Old 06-18-2023 , 16:17   Re: [CS:GO] How to get a Count of players inventory item?
Reply With Quote #2

I was thinking the grenade plugins must have some way to check how many grenades a player has so I found this plugin that shows how to get a count of the grenades.

https://forums.alliedmods.net/showthread.php?p=1796153

PHP Code:
    #define     HEGrenadeOffset         14    // (14 * 4)
    #define     FlashbangOffset         15    // (15 * 4)
    #define     SmokegrenadeOffset        16    // (16 * 4)
    #define    IncenderyGrenadesOffset    17    // (17 * 4) Also Molotovs
    #define    DecoyGrenadeOffset        18    // (18 * 4)

    
int heNades GetEntProp(clientProp_Data"m_iAmmo"_HEGrenadeOffset);
    
PrintToServer("heNades = %d"heNades); 
How would I find the "offset" for weapon_healthshot?
How would I find a list of offsets for -any- other item a player can have?
tx
Austin is offline
Austin
Senior Member
Join Date: Oct 2005
Old 07-01-2023 , 20:40   Re: [CS:GO] How to get a Count of players inventory item?
Reply With Quote #3

Thanks goes to Vit_amin for suggesting this method to find the health shot offset.

1) Go in game and give yourself 4 health shots.
2) Write a plugin that lists all offsets and counts.

weapon_healthshot = offset 21 !!

PHP Code:
public Action Command_Test(int clientint args)
{
    
int item;
    for(
int i 0i<=31;i++)
    {
        
item GetEntProp(clientProp_Data"m_iAmmo"_i);
        
PrintToServer("item %d = %d"iitem);
    }
    return 
Plugin_Continue;

Output
item 0 = 0
item 1 = 0
item 2 = 0
item 3 = 0
item 4 = 0
item 5 = 0
item 6 = 0
item 7 = 0
item 8 = 0
item 9 = 0
item 10 = 0
item 11 = 0
item 12 = 0
item 13 = 203
item 14 = 2
item 15 = 2
item 16 = 2
item 17 = 1
item 18 = 2
item 19 = 0
item 20 = 0
item 21 = 4 <= was holding 4 weapon_healthshot
item 22 = 2
item 23 = 0
item 24 = 0
item 25 = 0
item 26 = 0
item 27 = 0
item 28 = 0
item 29 = 0
item 30 = 0
item 31 = 0

Last edited by Austin; 07-01-2023 at 20:41.
Austin is offline
azalty
AlliedModders Donor
Join Date: Feb 2020
Location: France
Old 07-14-2023 , 22:00   Re: [CS:GO] How to get a Count of players inventory item?
Reply With Quote #4

Thanks, useful knowledge
__________________
GitHub | Discord: @azalty | Steam
azalty is offline
Reply



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 04:38.


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