[TF2] Gamedata: GetMaxAmmo / GetMaxClip
2 Attachment(s)
Useful for anyone modding weapons or anything related to them.
This should also work for weapons with custom attributes and custom spawned weapons. Anyway, TF2 doesn't seem to have a netprop or datamap for a weapon's max clip/ammo, meaning you have to use an SDKCall to GetMaxAmmo / GetMaxClip1 to get it. Maybe there's hidden ones really, but yeah. It also properly accounts for mult_clip_size. I believe it returns -1 for energy weapons though. m_iClip1 will be -1 for energy weapons anyway. (Such as the Cow Mangler). I also threw in GetDefaultClip (whatever that is) and GetSlot. And well... see the attached files! Oh, I only set it up for Linux/Mac, because I'm lazy. |
Re: [TF2] Accurately get a weapon's max clip/ammo.
Weapons have a virtual function that can be called to get this information, but Bacardi was saying it doesn't work on TF2 or CS:GO... maybe because they're CEconItems and not standard weapons.
|
Re: [TF2] Accurately get a weapon's max clip/ammo.
I thought of that too, but this is less work and easier.
Also now that I think of it... wow those GetWeaponX functions must be old. But I'm not sure, how would one rewrite those exactly? I think GetWeaponClip would just be PHP Code:
|
Re: [TF2] Accurately get a weapon's max clip/ammo.
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. |
Re: [TF2] Accurately get a weapon's max clip/ammo.
Quote:
There are multiple other issues here as well. Quote:
Quote:
Quote:
Quote:
Quote:
|
Re: [TF2] Accurately get a weapon's max clip/ammo.
Quote:
|
Re: [TF2] Accurately get a weapon's max clip/ammo.
Quote:
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:
Quote:
|
Re: [TF2] Accurately get a weapon's max clip/ammo.
edit: Gonna update this soon with some sdkcalls
|
Re: [TF2] Accurately get a weapon's max clip/ammo.
Quote:
If you check a netprops / datamaps list, you'll notice that it includes the number of bits each thing takes up. That's because the SendProp class (which is what netprops are) stores this information1. I'm assuming the DataMap equivalent does as well. 1Unless it's a CUtlVector SendProp or one of its direct children. These are really a wrapper around a CUtlVector object on the server side and not an actual number/string property. |
Re: [TF2] Accurately get a weapon's max clip/ammo.
Quote:
|
All times are GMT -4. The time now is 13:45. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.