Raised This Month: $2 Target: $400
 0% 

L4D2, How to Get Reserve Ammo Without m_hOwnerEntity?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NgBUCKWANGS
Senior Member
Join Date: Dec 2014
Old 09-28-2017 , 05:51   L4D2, How to Get Reserve Ammo Without m_hOwnerEntity?
Reply With Quote #1

Hello,

I have a gripe with how I'm getting reserve ammo to any primary weapon. I currently have

PHP Code:
int _GetReserve(int ent) {

    static 
clienttype;
    
client GetEntPropEnt(entProp_Send"m_hOwnerEntity");

    if (
IsClientValid(client2)) {
        
type GetEntProp(entProp_Send"m_iPrimaryAmmoType");
        return 
GetEntProp(clientProp_Send"m_iAmmo"4type);
    }

    return -
1;

This works perfectly if the weapon is being held by a player. If the weapon is on the ground, it's f*****. I was
equipping the weapon onto a player just to get the reserve and then removing it but it feels hackish and if I remember correctly the player could potentially end up with 2 weapons in their primary slot. I was thinking about creating one fake client and hiding them off the map but again, it feels so damn hackish. I'm thinking there has to be a way to look at any weapon and without anyone holding it, get the reserve ammo?

I'm thinking maybe SetEntProp on the m_hOwnerEntity to the client requesting the reserve? If you know a better approach, can you please share? Thanks!
NgBUCKWANGS is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 09-28-2017 , 10:09   Re: L4D2, How to Get Reserve Ammo Without m_hOwnerEntity?
Reply With Quote #2

Supposedly the reserve ammo is held by the player, not the weapon.
__________________
hleV is online now
NgBUCKWANGS
Senior Member
Join Date: Dec 2014
Old 09-28-2017 , 11:07   Re: L4D2, How to Get Reserve Ammo Without m_hOwnerEntity?
Reply With Quote #3

Quote:
Originally Posted by hleV View Post
Supposedly the reserve ammo is held by the player, not the weapon.
if I equip the weapon, I have no problem getting the reserve. but just looking at a weapon on the floor get's tricky as hell. short of equipping it I'm trying to mess with some netprops to sort of simulate having it equipped but without moving it. I tried changing the m_hOwnerEntity (and others) of the weapon but it's unreliable. I tried just grabbing a random survivor, getting the ammo type of the weapon and then just going for the m_iAmmo and no luck.

There's got to be a way to grab the reserve (without equipping/moving the weapon) reliably and I'm stumped.
NgBUCKWANGS is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-29-2017 , 04:57   Re: L4D2, How to Get Reserve Ammo Without m_hOwnerEntity?
Reply With Quote #4

Quote:
Originally Posted by NgBUCKWANGS View Post
if I equip the weapon, I have no problem getting the reserve. but just looking at a weapon on the floor get's tricky as hell. short of equipping it I'm trying to mess with some netprops to sort of simulate having it equipped but without moving it. I tried changing the m_hOwnerEntity (and others) of the weapon but it's unreliable. I tried just grabbing a random survivor, getting the ammo type of the weapon and then just going for the m_iAmmo and no luck.

There's got to be a way to grab the reserve (without equipping/moving the weapon) reliably and I'm stumped.
Actually, are you sure the entities for the weapons on the floor are the same entities when a player is carrying them? I don't have L4D datamap and netprop dumps to check.
__________________
Am I back? Well, we'll see.
Powerlord is offline
NgBUCKWANGS
Senior Member
Join Date: Dec 2014
Old 09-29-2017 , 08:05   Re: L4D2, How to Get Reserve Ammo Without m_hOwnerEntity?
Reply With Quote #5

Quote:
Originally Posted by Powerlord View Post
Actually, are you sure the entities for the weapons on the floor are the same entities when a player is carrying them? I don't have L4D datamap and netprop dumps to check.
Not 100% but I did as a last hack resort kind of thing, scripted in OnPlayerRunCmd that when ever I looked at a weapon, I'd get a bot to immediately use that weapon. I did only check to see if their original item changed and if so, I'd get them to use it again. Now while they were actually holding the weapon in question, I tried getting the reserve and that was unreliable. I tried quite a few things and it gotten pretty ridiculous.

For those googling and curious, you'd get dumps of most stuff (e.g., datamaps, netprops) with
PHP Code:
"sm_dump_admcache"
 
Dumps the admin cache for debugging
"sm_dump_classes"
 
Dumps the class list as a text file
"sm_dump_datamaps"
 
Dumps the data map list as a text file
"sm_dump_handles"
 
Dumps Handle usage to a file for finding Handle leaks
"sm_dump_netprops"
 
Dumps the networkable property table as a text file
"sm_dump_netprops_xml"
 
Dumps the networkable property table as an XML file
"sm_dump_teprops"
 
Dumps tempentity props to a file 
Yesterday, I kept at it for a while and couldn't reliably within the same frame get the reserve of a weapon just laying on the ground without moving it (I know it has ammo, I put it there). My attempts would sometimes work but most of the time they won't. All my methods were in the end just completely unreliable. As far as what I'm working on, I don't technically need to even do this but it's a problem I'm really curious about and I'm fascinated by it.

I mean, even if it's the client that has that information, why can't I as a client get it without moving the weapon? If I make any progress on this, I'll report back. Thanks fellas
NgBUCKWANGS is offline
MasterMind420
Veteran Member
Join Date: Nov 2010
Old 10-31-2017 , 02:16   Re: L4D2, How to Get Reserve Ammo Without m_hOwnerEntity?
Reply With Quote #6

Quote:
Originally Posted by hleV View Post
Supposedly the reserve ammo is held by the player, not the weapon.
This is correct. The only way I can think of buckwangs is to track the reserve ammo count and entindex of the weapon. When the weapon is dropped store reserve count and entindex. When the weapon is picked back up set the ammo reserve amount to whatever that entindex has stored. That should effectively track the reserve ammo per gun and not just on the player.

Last edited by MasterMind420; 10-31-2017 at 02:22.
MasterMind420 is offline
NgBUCKWANGS
Senior Member
Join Date: Dec 2014
Old 10-31-2017 , 10:59   Re: L4D2, How to Get Reserve Ammo Without m_hOwnerEntity?
Reply With Quote #7

Quote:
Originally Posted by MasterMind420 View Post
This is correct. The only way I can think of buckwangs is to track the reserve ammo count and entindex of the weapon. When the weapon is dropped store reserve count and entindex. When the weapon is picked back up set the ammo reserve amount to whatever that entindex has stored. That should effectively track the reserve ammo per gun and not just on the player.
Your idea will work but I'm kind of urked knowing that that information is in the ether somewhere
NgBUCKWANGS is offline
MasterMind420
Veteran Member
Join Date: Nov 2010
Old 10-31-2017 , 20:12   Re: L4D2, How to Get Reserve Ammo Without m_hOwnerEntity?
Reply With Quote #8

Quote:
Originally Posted by NgBUCKWANGS View Post
Your idea will work but I'm kind of urked knowing that that information is in the ether somewhere
I know exactly what you mean, its more of a workaround to store it somewhere and be able to retrieve it. Totally not ideal, I think it was pretty stupid the way valve handled reserve ammo in L4D2, should have been stored same way clips are using a netprop/datamap, and not on the players, not sure the logic behind that decision. Maybe they had a good reason but I don't know...having to basically hack it is just a dirty way of doing it...

Last edited by MasterMind420; 11-01-2017 at 20:24.
MasterMind420 is offline
xZk
Senior Member
Join Date: Nov 2017
Location: cl
Old 03-27-2020 , 13:15   Re: L4D2, How to Get Reserve Ammo Without m_hOwnerEntity?
Reply With Quote #9

I know that it may be too late, but perhaps this will be of some use:
PHP Code:

int _GetReserve
(int weapon) { 
 return 
GetEntProp(weaponProp_Data"m_iExtraPrimaryAmmo");

pd: only work when weapon is dropped

credits to panxiaohai
xZk is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine
Old 03-27-2020 , 13:26   Re: L4D2, How to Get Reserve Ammo Without m_hOwnerEntity?
Reply With Quote #10

Perhaps, can be easily found using tEntDev (sm_ted_select) + Dev Cmds (sm_ent).

Make snapshot #1, shoot some ammo, make snapshot #2, compare 2 left4dead/kvtest.txt files using any tool like WinMerge.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch)
[My plugins] [My tools] [GitHub] [Articles]
Dragokas 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 05:16.


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