AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   getting grenade count in csgo (https://forums.alliedmods.net/showthread.php?t=253748)

8guawong 12-27-2014 19:09

getting grenade count in csgo
 
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


TnTSCS 12-27-2014 20:56

Re: getting grenade count in csgo
 
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.

8guawong 12-27-2014 22:01

Re: getting grenade count in csgo
 
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));



Bacardi 12-28-2014 11:02

Re: getting grenade count in csgo
 
https://forums.alliedmods.net/showpo...0&postcount=15

TnTSCS 12-29-2014 13:29

Re: getting grenade count in csgo
 
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

8guawong 12-29-2014 22:40

Re: getting grenade count in csgo
 
so your bots only had Incgrenade and Decoy?

TnTSCS 12-30-2014 09:30

Re: getting grenade count in csgo
 
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?

8guawong 12-30-2014 09:52

Re: getting grenade count in csgo
 
Quote:

Originally Posted by TnTSCS (Post 2242122)
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? :P
and you don't need to test with bots just test it on yourself :P
but i think what bacardi posted works just haven't tested it yet

Bacardi 12-30-2014 10:32

Re: getting grenade count in csgo
 
not 100% sure, maybe because you both where using Prop_Data instead Prop_Send

SanKen 12-30-2014 11:27

Re: getting grenade count in csgo
 
tested and always smoke,fb,he is 0. It is in inventory.


All times are GMT -4. The time now is 01:50.

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