Raised This Month: $42 Target: $400
 10% 

getting grenade count in csgo


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 12-27-2014 , 19:09   getting grenade count in csgo
Reply With Quote #1

i'm trying to get the number of grenades for player in csgo
but getting weird as hell results

PHP Code:
#include <sourcemod>
#include <sdktools>

#pragma semicolon 1

public OnPluginStart()
{
    
RegConsoleCmd("sm_test"test"show # of grenades");
}

public 
Action:test(clientarg)
{
    new 
String:sWeaponName[64];
    
GetClientWeapon(clientsWeaponNamesizeof(sWeaponName));
    
PrintToChat(client"%s"sWeaponName);
    
PrintToChat(client"IncGrendae: %d"GetEntData(clientFindDataMapOffs(client"m_iAmmo")+56));
    
PrintToChat(client"HEGrenade: %d"GetEntData(clientFindDataMapOffs(client"m_iAmmo")+44));
    
PrintToChat(client"SmokeGrenade: %d"GetEntData(clientFindDataMapOffs(client"m_iAmmo")+52));

here is a video showing the weird ass result


Last edited by 8guawong; 12-27-2014 at 19:10.
8guawong is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 12-27-2014 , 20:56   Re: getting grenade count in csgo
Reply With Quote #2

You can check out the code in my ZeusRound plugin - I store the number of each type of grenade a player has

PHP Code:
#define     HEGrenadeOffset         11    // (11 * 4)
#define     FlashbangOffset         12    // (12 * 4)
#define     SmokegrenadeOffset        13    // (13 * 4)
#define     IncenderyGrenadesOffset    14    // (14 * 4) Also Molotovs
#define     DecoyGrenadeOffset        15    // (15 * 4)

GetClientHEGrenades(client)
{
    return 
GetEntProp(clientProp_Data"m_iAmmo"_HEGrenadeOffset);
}

GetClientSmokeGrenades(client)
{
    return 
GetEntProp(clientProp_Data"m_iAmmo"_SmokegrenadeOffset);
}

GetClientFlashbangs(client)
{
    return 
GetEntProp(clientProp_Data"m_iAmmo"_FlashbangOffset);
}

GetClientDecoyGrenades(client)
{
    return 
GetEntProp(clientProp_Data"m_iAmmo"_DecoyGrenadeOffset);
}

GetClientIncendaryGrenades(client)
{
    return 
GetEntProp(clientProp_Data"m_iAmmo"_IncenderyGrenadesOffset);

Asherkin assisted me with the GetEntProp - I was using a different method before and the GetEntProp is cleaner.
__________________
View my Plugins | Donate

Last edited by TnTSCS; 12-27-2014 at 20:59.
TnTSCS is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 12-27-2014 , 22:01   Re: getting grenade count in csgo
Reply With Quote #3

Hello i tried your code but it still returning wrong number of grenades

PHP Code:
#include <sourcemod>
#include <sdktools>

#pragma semicolon 1

#define     HEGrenadeOffset         11    // (11 * 4)
#define     FlashbangOffset         12    // (12 * 4)
#define     SmokegrenadeOffset        13    // (13 * 4)
#define     IncenderyGrenadesOffset    14    // (14 * 4) Also Molotovs
#define     DecoyGrenadeOffset        15    // (15 * 4)

public OnPluginStart()
{
    
RegConsoleCmd("sm_test"test"show # of grenades");
}

public 
Action:test(clientarg)
{
    new 
String:sWeaponName[64];
    
GetClientWeapon(clientsWeaponNamesizeof(sWeaponName));
    
PrintToChat(client"%s"sWeaponName);
    
PrintToChat(client"IncGrendae: %d"GetEntProp(clientProp_Data"m_iAmmo"_IncenderyGrenadesOffset));
    
PrintToChat(client"HEGrenade: %d"GetEntProp(clientProp_Data"m_iAmmo"_HEGrenadeOffset));
    
PrintToChat(client"SmokeGrenade: %d"GetEntProp(clientProp_Data"m_iAmmo"_SmokegrenadeOffset));


Last edited by 8guawong; 12-27-2014 at 22:02.
8guawong is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-28-2014 , 11:02   Re: getting grenade count in csgo
Reply With Quote #4

https://forums.alliedmods.net/showpo...0&postcount=15
__________________
Do not Private Message @me
Bacardi is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 12-29-2014 , 13:29   Re: getting grenade count in csgo
Reply With Quote #5

I don't know what's up with your code, but the following works for me - I just tested it:

test code to get grenade count

output
__________________
View my Plugins | Donate
TnTSCS is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 12-29-2014 , 22:40   Re: getting grenade count in csgo
Reply With Quote #6

so your bots only had Incgrenade and Decoy?
8guawong is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 12-30-2014 , 09:30   Re: getting grenade count in csgo
Reply With Quote #7

I tested with bots only. I suppose I could freeze them all and give them all a variation of things, then run the command, but I'm fairly certain I would see expected results.

What results are you seeing?
__________________
View my Plugins | Donate
TnTSCS is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 12-30-2014 , 09:52   Re: getting grenade count in csgo
Reply With Quote #8

Quote:
Originally Posted by TnTSCS View Post
I tested with bots only. I suppose I could freeze them all and give them all a variation of things, then run the command, but I'm fairly certain I would see expected results.

What results are you seeing?
similar to the youtube video in my first post
aren't you curious why they don't have other grenade types?
and you don't need to test with bots just test it on yourself
but i think what bacardi posted works just haven't tested it yet

Last edited by 8guawong; 12-30-2014 at 09:54.
8guawong is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-30-2014 , 10:32   Re: getting grenade count in csgo
Reply With Quote #9

not 100% sure, maybe because you both where using Prop_Data instead Prop_Send
__________________
Do not Private Message @me
Bacardi is offline
SanKen
Senior Member
Join Date: Oct 2012
Location: /var/logs
Old 12-30-2014 , 11:27   Re: getting grenade count in csgo
Reply With Quote #10

tested and always smoke,fb,he is 0. It is in inventory.
__________________
SanKen is offline
Reply


Thread Tools
Display Modes

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


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