Raised This Month: $ Target: $400
 0% 

How do I determine when a bullet is fired?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 12-30-2004 , 16:47   How do I determine when a bullet is fired?
Reply With Quote #1

All I want to know is when someone presses the trigger. Now I could catch CurWeapon, except that is called while changing weapons.

I could also catch IN_ATTACK but that could register when someone is pressing attack but bullets aren't fired (i.e. while reloading).

Is there any for-sure way of determining this?
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
syphilis
Member
Join Date: Sep 2004
Old 12-30-2004 , 16:51  
Reply With Quote #2

Maybe try catching IN_ATTACK in client_PreThink(), saveing the client's clip ammount to a variable, and then in client_PostThink() check if the client's clip is 1 less than the variable from earlier.

That's just speculation, hopefully it'll give you some more ideas for solving the problem.
syphilis is offline
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 12-30-2004 , 19:18  
Reply With Quote #3

brilliant That'll work perfect, now I need to determine how to get the user's clip from an amxmodx module
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
jtp10181
Veteran Member
Join Date: May 2004
Location: Madison, WI
Old 12-30-2004 , 21:24  
Reply With Quote #4

its easier to just use CurWeapon and save the clip ammount in a global variable, if the clip ammount is less than the last time it got checked they just fired a bullet.

Code:
new lastclip[33]
new lastweap[33]

public curweapon(id)
{
	new wpnid = read_data(2)
	new clip = read_data(3)

	if (lastweap[id] != wpnid){
		//Changed weapons
	}
	else if ( lastclip[id] > clip ) {
		if (wpnid != CSW_C4 && wpnid != CSW_HEGRENADE && wpnid != CSW_FLASHBANG && wpnid != CSW_SMOKEGRENADE && wpnid != CSW_KNIFE) {
			//Fired a Bullet
		}
	}

	lastclip[id] = clip
	lastweap[id] = wpnid
}
__________________
jtp10181 is offline
Send a message via ICQ to jtp10181 Send a message via AIM to jtp10181 Send a message via MSN to jtp10181 Send a message via Yahoo to jtp10181
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 12-30-2004 , 22:08  
Reply With Quote #5

Yea it's just not so easy to get that data in an amxx module. At least I'm not very good at it :/
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
Timmi the savage
Senior Member
Join Date: Jul 2004
Location: seattle
Old 12-31-2004 , 08:16  
Reply With Quote #6

hmmm.. maybe this isnt the best way but...

Code:
new oldclip[33]
new weapon[33]

public spent_ammo(id)  {
  new clip
  new weapon
  new reservetemp
  get_user_ammo(id, weapon, clip, reservetemp)
  if (weapon[id] != weapon) {
     weapon[id] = weapon 
     return PLUGIN_CONTINUE
     }
  if (oldclip[id] == clip) return PLUGIN_CONTINUE
  if (oldclip[id] != clip) {
  oldclip[id] = clip
  do_what_ever_you_want_to_do_here()
  }
  return PLUGIN_CONTINUE
}
You could set this as a task or link it to | Damage |
or even make it return if ammo changed or not.

Perhaps this is what you mean??
Timmi the savage is offline
Send a message via Yahoo to Timmi the savage
Timmi the savage
Senior Member
Join Date: Jul 2004
Location: seattle
Old 12-31-2004 , 08:42  
Reply With Quote #7

Also if you make either of these ways to run as a task....

Put

if ( read_data(2) ) {

first thing after the function then it will only execute if someone gets hurt.

And even link it from Damage event.

Or both ... o.O
Timmi the savage is offline
Send a message via Yahoo to Timmi the savage
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 12-31-2004 , 12:19  
Reply With Quote #8

thanks but you don't have read_data in an amxx module... I think I'm good now, but I don't think I"ll be able to do this how I want to. B/c I'll have to compare gpGlobals->time and I don't know how great of an option that is.

(I need to execute code in FN_Traceline based on if the user is firing)
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
jtp10181
Veteran Member
Join Date: May 2004
Location: Madison, WI
Old 12-31-2004 , 14:38  
Reply With Quote #9

Quote:
Originally Posted by Geesu
Yea it's just not so easy to get that data in an amxx module. At least I'm not very good at it :/
you are trying to write a module?
__________________
jtp10181 is offline
Send a message via ICQ to jtp10181 Send a message via AIM to jtp10181 Send a message via MSN to jtp10181 Send a message via Yahoo to jtp10181
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 12-31-2004 , 15:46  
Reply With Quote #10

Quote:
Originally Posted by jtp10181
you are trying to write a module?
Quote:
Originally Posted by Geesu
brilliant That'll work perfect, now I need to determine how to get the user's clip from an amxmodx module
Quote:
Originally Posted by Geesu
Yea it's just not so easy to get that data in an amxx module. At least I'm not very good at it :/
Quote:
Originally Posted by Geesu
thanks but you don't have read_data in an amxx module... I think I'm good now, but I don't think I"ll be able to do this how I want to. B/c I'll have to compare gpGlobals->time and I don't know how great of an option that is.

(I need to execute code in FN_Traceline based on if the user is firing)
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX 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 19:23.


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