Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding

Reply
 
Thread Tools Display Modes
Old 02-17-2012, 05:11 AM   #1
hello123
 
Join Date: Aug 2011
Reputation: 20
Posts: 340
Degenerate ammo.

I want the pistol to loose 1 ammo per sec, or something similar.
In the pistols "ItemPostFrame"
Code:
	float AMMO_PER_SECOND = -1;
    int decreaseammo = AMMO_PER_SECOND * gpGlobals->curtime;
	pOwner->RemoveAmmo( decreaseammo, m_iClip1);
That dosent do anything?

Last edited by hello123: 02-17-2012 at 05:14 AM.
hello123 is offline  
Reply With Quote
Old 02-17-2012, 10:46 AM   #2
haraldsegliens
 
Join Date: Nov 2010
Reputation: 4
Posts: 92
You try this :
Code:
float AMMO_PER_SECOND = -1;
float flNextDecreaseTime;//put this in class declarations
float time = 1.0f//I don't know how long is a second
 in frames
if( flNextDecreaseTime >= gpGlobals->curtime )
{
pOwner->RemoveAmmo( AMMO_PER_SECOND, m_iClip1);
flNextDecreaseTime = gpGlobals->curtime + time;
}
In Constructor:
Code:
flNextDecreaseTime = gpGlobals->curtime;
haraldsegliens is offline   Reply With Quote
Old 02-17-2012, 03:34 PM   #3
_drewskis
 
Join Date: Jan 2012
Reputation: 0
Posts: 9
are your going for a gametype? if so could you try a brush Entity, and in your ::Ontouch
function and just decrement the current player's, current weapon ammo?
_drewskis is offline   Reply With Quote
Old 02-18-2012, 09:45 AM   #4
hello123
 
Join Date: Aug 2011
Reputation: 20
Posts: 340
Quote:
Originally Posted by haraldsegliens View Post
You try this :
Code:
float AMMO_PER_SECOND = -1;
float flNextDecreaseTime;//put this in class declarations
float time = 1.0f//I don't know how long is a second
 in frames
if( flNextDecreaseTime >= gpGlobals->curtime )
{
pOwner->RemoveAmmo( AMMO_PER_SECOND, m_iClip1);
flNextDecreaseTime = gpGlobals->curtime + time;
}
In Constructor:
Code:
flNextDecreaseTime = gpGlobals->curtime;
Thanks for replying, sadly, it still dosen't change anything.

Quote:
are your going for a gametype? if so could you try a brush Entity, and in your ::Ontouch
function and just decrement the current player's, current weapon ammo?
No, not a gametype, thanks though.

Last edited by hello123: 02-18-2012 at 10:50 AM.
hello123 is offline   Reply With Quote
Old 02-18-2012, 01:20 PM   #5
haraldsegliens
 
Join Date: Nov 2010
Reputation: 4
Posts: 92
Try put my code in ItemPreFrame.
haraldsegliens is offline   Reply With Quote
Old 02-18-2012, 03:24 PM   #6
hello123
 
Join Date: Aug 2011
Reputation: 20
Posts: 340
Quote:
Originally Posted by haraldsegliens View Post
Try put my code in ItemPreFrame.
Nope, I did try it before, with my own code too, and sadly, no luck.
hello123 is offline   Reply With Quote
Old 02-20-2012, 08:16 PM   #7
Kojaktsl
 
Join Date: Dec 2011
Reputation: 1
Posts: 59
no need for the "pOwner->RemoveAmmo"

just do "m_iClip1 -= AMMO_PER_WHATEVER"

EDIT: Actually doing a pOwner->RemoveAmmo will just confuse the living hell out of the CBasePlayer class. It's expecting an ammo type, not a variable on the CBaseCombatWeapon entity.

Guns store the bullets in the clip, players store the ammo in reserve.

Likewise, if you wanted the player to lose a bullet from the reserve (where reloads come from) do
Code:
pOwner->RemoveAmmo( m_iPrimaryAmmoType, AMMO_PER_WHATEVER )

Last edited by Kojaktsl: 02-21-2012 at 09:10 AM. Reason: I'm an idiot.
Kojaktsl is offline   Reply With Quote
Old 02-23-2012, 01:29 PM   #8
hello123
 
Join Date: Aug 2011
Reputation: 20
Posts: 340
Quote:
Originally Posted by Kojaktsl View Post
no need for the "pOwner->RemoveAmmo"

just do "m_iClip1 -= AMMO_PER_WHATEVER"

EDIT: Actually doing a pOwner->RemoveAmmo will just confuse the living hell out of the CBasePlayer class. It's expecting an ammo type, not a variable on the CBaseCombatWeapon entity.

Guns store the bullets in the clip, players store the ammo in reserve.

Likewise, if you wanted the player to lose a bullet from the reserve (where reloads come from) do
Code:
pOwner->RemoveAmmo( m_iPrimaryAmmoType, AMMO_PER_WHATEVER )
Oh thanks! ^^
hello123 is offline   Reply With Quote
Reply

Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding


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



All times are GMT -7. The time now is 02:39 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site Content Copyright Valve Corporation 1998-2014, All Rights Reserved.