Raised This Month: $51 Target: $400
 12% 

Problem with setting iAmmo value


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
steambob
Member
Join Date: Sep 2007
Old 09-08-2007 , 17:25   Problem with setting iAmmo value
Reply With Quote #1

Hi all!

I am trying to set CHL2MP_Player.baseclass.baseclass.localdata.m _iAmmo.004
(HL2MP game and the ammo slot is for SMG weapon) to a certain value on player respawn.

However the following code:
Code:
new ammooffset = FindSendPropOffs("CHL2MP_Player", "m_iAmmo");
SetEntData(client, ammooffset+16, 20, 4, true);
does not result in setting the ammo to 20, but in adding 20 to the ammo.

How can I set the ammo to a value? Negative values do not work (results in high positive values).

Could anyone give me a hint?
Thanks.
steambob is offline
Fredd
Veteran Member
Join Date: Jul 2007
Old 09-08-2007 , 17:53   Re: Problem with setting iAmmo value
Reply With Quote #2

im not sure about this but isn't a player classname is any hl2 mod is CBasePlayer ?
__________________
Need a private coder? AMXX, SourceMOD, MMS? PM me!
Fredd is offline
steambob
Member
Join Date: Sep 2007
Old 09-08-2007 , 18:11   Re: Problem with setting iAmmo value
Reply With Quote #3

I've tried both CHL2MP_Player and CBasePlayer.
It works the same way.
steambob is offline
Nican
Veteran Member
Join Date: Jan 2006
Location: NY
Old 09-09-2007 , 00:12   Re: Problem with setting iAmmo value
Reply With Quote #4

This page:
http://plugins.mfzb.de/offsets/DBSOURCE_Props.txt
Tells me that:
CBasePlayer, CDBS_Player and CHL2_Player has m_iAmmo values
__________________
http://www.nican132.com
I require reputation!
Nican is offline
Send a message via ICQ to Nican Send a message via MSN to Nican
pRED*
Join Date: Dec 2006
Old 09-09-2007 , 01:49   Re: Problem with setting iAmmo value
Reply With Quote #5

Nican that offset page is for dragonball source. He's running hl2mp.

steambob try doing the same thing using the datamap type instead of send.

I can't remember the exact code but you do need to find the offset for every player not the classname.

If that doesn't work you could try sending a large negative number of ammo and see if that zero's it. Depends if the game allows negative ammo or not. If that works then you can send the exact number you want straight after
pRED* is offline
steambob
Member
Join Date: Sep 2007
Old 09-09-2007 , 07:03   Re: Problem with setting iAmmo value
Reply With Quote #6

Thanks for the feedback!

pRED* | NZ:
I've tried it with
Code:
new ammooffset = FindDataMapOffs(client, "m_iAmmo");
SetEntData(client, ammooffset+16, 20, 4, true);
This works the same way - adds 20 to the ammo

I will experiment with more negative values, but I guess the data might be treated as unsigned.
steambob is offline
pRED*
Join Date: Dec 2006
Old 09-09-2007 , 16:22   Re: Problem with setting iAmmo value
Reply With Quote #7

Couple of things. Why the +16?

and are you sure its a 4 bit? My guess would be 1...
pRED* is offline
Fredd
Veteran Member
Join Date: Jul 2007
Old 09-09-2007 , 16:37   Re: Problem with setting iAmmo value
Reply With Quote #8

1= byte, 2= short and i don't know the rest lol.
__________________
Need a private coder? AMXX, SourceMOD, MMS? PM me!
Fredd is offline
steambob
Member
Join Date: Sep 2007
Old 09-09-2007 , 17:39   Re: Problem with setting iAmmo value
Reply With Quote #9

The dump produced by this plugin, says:

Code:
          
         m_iAmmo (1596)
         000 (0)
         001 (4)
         002 (8)
         003 (12)
         004 (16)
         005 (20)
and I need ...iAmmo.004
It also seems to be of size 4. BTW, this seems to be so for any game mod.
I do not really know if one can make it better (I mean not using +16).

Last edited by steambob; 09-09-2007 at 17:43.
steambob is offline
steambob
Member
Join Date: Sep 2007
Old 09-24-2007 , 03:29   Re: Problem with setting iAmmo value
Reply With Quote #10

It did work finally with negative values.

Code:
new iAmmo = -45;
SetEntData(client, ammooffset+16, iAmmo, 4, true);
(default ammo is 45)
resulted in having no ammo - thats what I wanted
steambob is offline
Reply



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


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