Raised This Month: $ Target: $400
 0% 

Changing Ammo in a weapon given using GivePlayerItem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hardcor3
Member
Join Date: Mar 2009
Old 12-07-2010 , 11:29   Changing Ammo in a weapon given using GivePlayerItem
Reply With Quote #1

Basically im removing all weapons for a specific player on spawn and giving them a pistol (this all works fine). Im just curious how i would go about removing the extra ammo it gives them as well.

e.g. USP 12ammo + 100 reserve

I want to set the reserve ammo lower or nothing so they only have the 12 bullets. Can anyone help me out, ive been mucking about for 2days and i just cant seem to get anything to work.

Game is CSS btw. Thanks in advanced.
Hardcor3 is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 12-07-2010 , 12:01   Re: Changing Ammo in a weapon given using GivePlayerItem
Reply With Quote #2

You can set reserve ammo to 0.
__________________
FaTony is offline
Hardcor3
Member
Join Date: Mar 2009
Old 12-07-2010 , 12:30   Re: Changing Ammo in a weapon given using GivePlayerItem
Reply With Quote #3

Kool, but more to the point how?

Tbh i dont actually want to set it to zero i want to set it to values based upon conditions but just looking for the basic code for setting the reserve ammo.
Hardcor3 is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 12-07-2010 , 12:35   Re: Changing Ammo in a weapon given using GivePlayerItem
Reply With Quote #4

I'm sure it's NetProp, haven't done this myself.
__________________
FaTony is offline
Hardcor3
Member
Join Date: Mar 2009
Old 12-07-2010 , 12:58   Re: Changing Ammo in a weapon given using GivePlayerItem
Reply With Quote #5

Ok fair enough, i did play around with a few netprops and m_iClip1 appears to be the ammo in the gun already. m_iClip2 appears to be always set to -1 and doesnt seem to do anything on the USP.

PHP Code:
new weapon GivePlayerItem(client"weapon_usp");
new 
offset FindSendPropInfo("CBaseCombatWeapon""m_iClip2");
SetEntData(weaponoffset0_true); 
Anyone know what im doing wrong if this is indeed the right offset?

edit: i also tried to get the weapon entity by using GetPlayerWeaponSlot() also didnt work for me.

Last edited by Hardcor3; 12-07-2010 at 13:02.
Hardcor3 is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 12-07-2010 , 13:24   Re: Changing Ammo in a weapon given using GivePlayerItem
Reply With Quote #6

Oh, found a test code that sets Engineer metal in TF2.
PHP Code:
public Action:Command_Metal (clientargs)
{
    new 
String:s[16];
    
GetCmdArg(1s16);
    new 
a=StringToInt(s);
    
//new metal = GetEntData(client, FindDataMapOffs(client, "m_iAmmo") + (3 * 4));
    
SetEntData(clientFindDataMapOffs(client"m_iAmmo") + (4), a4true);
    return 
Plugin_Handled;

__________________
FaTony 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:43.


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