View Single Post
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 05-15-2015 , 12:31   Re: [TF2] Accurately get a weapon's max clip/ammo.
Reply With Quote #5

Quote:
Originally Posted by Powerlord View Post
To be honest, after doing a bit of research, it's a bit of a pain to check ammo levels using methods. Hell, you'd need a signature to call CAmmDef::MaxCarry as it has no entity.

Incidentally, why would you need a TF2Items callback to get accurate numbers? Doesn't the post_inventory_application event fire after a player is given a new inventory? You could just iterate over their item slots then.
Hm, I used to use post_inventory_application but had problems. I ought to test it again.

and isvalident is something I mostly use privately, usually I edit that out of public things, dunno why I didn't here

So...

PHP Code:
stock GetWeaponAmmo(weapon)
{
    new 
owner GetEntPropEnt(weaponProp_Send"m_hOwnerEntity");
    if (
owner == -1) return 0;
    if (
IsValidEntity(weapon))
    {
        new 
iOffset GetEntProp(weaponProp_Send"m_iPrimaryAmmoType"1);
        return 
GetEntProp(ownerProp_Send"m_iAmmo"_iOffset);
    }
    return 
0;
}] 
I'd make an sdkcall but i'm too lazy.

Quote:
Originally Posted by Powerlord View Post
The 4 doesn't even need to be set as GetEntProp can figure it out on its own.
What exactly does "GetEntProp" do to "figure it out"? I see it has a default value of 4 for the size, but I don't see anything like sizeof(int) or something.
__________________

Last edited by Chdata; 05-17-2015 at 06:52.
Chdata is offline