get coordinates of the players shoot at postition
Moderator: Core Staff
get coordinates of the players shoot at postition
i know there is bullettrace, but i am a bit confused on how it works. Some enlightenment would be great
-
- CJ G0D!
- Posts: 1575
- Joined: June 3rd, 2009, 9:02 pm
- Location: Cardiff University, UK
Re: get coordinates of the players shoot at postition
Bullettrace doesn't actually trace players bullets. It is used to `simulate` a bullet going from one point to another.
BulletTrace( <start>, <end>, <hit characters>, <ignore entity> )
Where you choose the start and end point, and decide if you want to trace what it hits etc. It is normally used for seeing if there is any obstacles in a straight line between points A and B.
As for your problem, do you need the co-ordinates of where a player is shooting from, or the co-ordinates of where the player's bullet hits? Either way you'll need to know when a person is firing, I think the only accurate way to do this is to use menu files. Again, I can't really help with this but it's not too hard to pick up on. Once you've monitored when they're attacking (shooting), you can either get their player.origin, or, if it's the latter, you will need to call the BulletTrace on that player at this time.
It would be a bit tricky but as they fire their shot you would want to get their player.angles (to see which way they're looking) and their eyePos (since bullets come out of players heads viewpoint, not the gun - I believe there is a function for this), and then something like this:
trace = BulletTrace( eyePos, eyePos + (player.angles*100000), true, undefined );
and then use trace["position"] to return the origin of where the bullet hit.
More info on BulletTrace http://wiki.modsrepository.com/index.ph ... ulletTrace. Hope this helps.
BulletTrace( <start>, <end>, <hit characters>, <ignore entity> )
Where you choose the start and end point, and decide if you want to trace what it hits etc. It is normally used for seeing if there is any obstacles in a straight line between points A and B.
As for your problem, do you need the co-ordinates of where a player is shooting from, or the co-ordinates of where the player's bullet hits? Either way you'll need to know when a person is firing, I think the only accurate way to do this is to use menu files. Again, I can't really help with this but it's not too hard to pick up on. Once you've monitored when they're attacking (shooting), you can either get their player.origin, or, if it's the latter, you will need to call the BulletTrace on that player at this time.
It would be a bit tricky but as they fire their shot you would want to get their player.angles (to see which way they're looking) and their eyePos (since bullets come out of players heads viewpoint, not the gun - I believe there is a function for this), and then something like this:
trace = BulletTrace( eyePos, eyePos + (player.angles*100000), true, undefined );
and then use trace["position"] to return the origin of where the bullet hit.
More info on BulletTrace http://wiki.modsrepository.com/index.ph ... ulletTrace. Hope this helps.
-
Re: get coordinates of the players shoot at postition
You actually need to convert angles to vector firstly with a stock function anglesToForward(angles)trace = BulletTrace( eyePos, eyePos + (player.angles*100000), true, undefined );
Re: get coordinates of the players shoot at postition
what exactly does angletoforward() return?
Re: get coordinates of the players shoot at postition
and couldnt i just getplayerattackbuttonpressed() and attacb a trigger to the gun?
-
- CJ G0D!
- Posts: 1575
- Joined: June 3rd, 2009, 9:02 pm
- Location: Cardiff University, UK
Re: get coordinates of the players shoot at postition
You could, but it would mean running an infinite loop on the player, with a delay time of 0.01 or something to be accurate. If this is on every player it may cause some server stress. It would probably still be okay, just using menu files to monitor the keys is much less stress on the server.pcbouncer wrote:and couldnt i just getplayerattackbuttonpressed() and attacb a trigger to the gun?
And yeah megazor is right, player.angles is just 3 numbers. If you use anglestoforward(player.angles) it converts these angles into a vector which runs in the direction of the player angles. This vector you would want to multiply by something like 10000 and add onto eyePos to get the end point of the bullettrace.
-
Re: get coordinates of the players shoot at postition
but what is exactly anglestoforward??
-
- CJ G0D!
- Posts: 1575
- Joined: June 3rd, 2009, 9:02 pm
- Location: Cardiff University, UK
Re: get coordinates of the players shoot at postition
A function, that returns a vector value in the direction of some given angles.pcbouncer wrote:but what is exactly anglestoforward??
-
Re: get coordinates of the players shoot at postition
oh like the distances in front of you???
-
- CJ G0D!
- Posts: 1575
- Joined: June 3rd, 2009, 9:02 pm
- Location: Cardiff University, UK
Re: get coordinates of the players shoot at postition
Imagine you're looking exactly straight forward. (I.e. in a 3-Dimensional axis you are looking along the Z-axis, since you're not looking up/down at all nor left/right).
AnglesToForward in this case would return the vector (0,0,1). Multiply this by 10000 and you have the vector (0,0,10000). Therefore eyePos + (0,0,10000) would be the same as starting at your eyePos, and following a straight line for 10000 units along the Z axis. Resulting in the object that you are looking at, 10000 units away from you.
AnglesToForward in this case would return the vector (0,0,1). Multiply this by 10000 and you have the vector (0,0,10000). Therefore eyePos + (0,0,10000) would be the same as starting at your eyePos, and following a straight line for 10000 units along the Z axis. Resulting in the object that you are looking at, 10000 units away from you.
-
Re: get coordinates of the players shoot at postition
but you said it would return the pos where you hit
Re: get coordinates of the players shoot at postition
You cannot get the hit position by modding means. You cannot get the exact moment of shooting, neither can you get the exact direction of a bullet (it will spread, you know).
With bulletTrace(), you can only get the position you're looking at. Usually, when hitting a target, you're looking at it. Also, the bullet spread angle is usually small, being about 1 degree. So, the main problem is to catch the moment of shooting.
There is a function attackButtonPressed(), however a) bullet coming out of your weapon and b) you holding your attack button are two different events. When clicking the attack button, its not necessary that your gun fires. It can be reloading, it can be out of ammo, it can be nonautomatic, like pistols (so you would have to release the button and press it again in order to fire).
As you can see, it's not enough to use this function. You will want to deal with weapon ammo count, clip ammo... Or look for another way, if it exists.
With bulletTrace(), you can only get the position you're looking at. Usually, when hitting a target, you're looking at it. Also, the bullet spread angle is usually small, being about 1 degree. So, the main problem is to catch the moment of shooting.
There is a function attackButtonPressed(), however a) bullet coming out of your weapon and b) you holding your attack button are two different events. When clicking the attack button, its not necessary that your gun fires. It can be reloading, it can be out of ammo, it can be nonautomatic, like pistols (so you would have to release the button and press it again in order to fire).
As you can see, it's not enough to use this function. You will want to deal with weapon ammo count, clip ammo... Or look for another way, if it exists.
Who is online
Users browsing this forum: Semrush [Bot] and 41 guests