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

Solved [L4D2] How to get bullet fired direction?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Paimon
Member
Join Date: Jul 2021
Location: Zootopia
Old 02-02-2024 , 06:42   [L4D2] How to get bullet fired direction?
Reply With Quote #1

As the title says, I want to know how to get the bullet fired direction of a gun(like smg) after using the gun's spread.
I know the guns use ray to simulate the bullet, but no matter what it is, can I get the ray's or bullet's direction in some way?
__________________

Last edited by Paimon; 02-03-2024 at 00:36.
Paimon is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 02-02-2024 , 06:53   Re: [L4D2] How to get bullet fired direction?
Reply With Quote #2

Maybe you can use the "bullet_impact" event

bullet_impact
Structure:
short userid
float x
float y
float z
__________________
Marttt is offline
Paimon
Member
Join Date: Jul 2021
Location: Zootopia
Old 02-02-2024 , 07:34   Re: [L4D2] How to get bullet fired direction?
Reply With Quote #3

Quote:
Originally Posted by Marttt View Post
Maybe you can use the "bullet_impact" event

bullet_impact
Structure:
short userid
float x
float y
float z
Find it at "CTerrorPlayer::FireBullet(Vector, QAngle const&, CSWeaponID, int)" in server.so
Maybe I could make a detour to get the origin and the direction.
I will try it tomrrow. Thanks!
__________________

Last edited by Paimon; 02-02-2024 at 07:45.
Paimon is offline
Paimon
Member
Join Date: Jul 2021
Location: Zootopia
Old 02-03-2024 , 00:35   Re: [L4D2] How to get bullet fired direction?
Reply With Quote #4

I found the solution:
PHP Code:
Action TEHook_Bullets(const char[] te_name, const int[] Playersint numClientsfloat delay)
{
    
int client TE_ReadNum("m_iPlayer");
    
float origin[3], angle[3];
    
TE_ReadVector("m_vecOrigin"origin);
    
angle[0] = TE_ReadFloat("m_vecAngles[0]");
    
angle[1] = TE_ReadFloat("m_vecAngles[1]");
    
PrintToChatAll("org: %N %.2f %.2f %.2f"clientorigin[0], origin[1], origin[2]);
    
PrintToChatAll("ang: %N %.2f %.2f"clientangle[0], angle[1]);
    
ShowAngle(COLOR_GREENoriginangle1.01000.00.10.1);

    return 
Plugin_Continue;
}

public 
void OnPluginStart()
{
    
AddTempEntHook("Bullets"TEHook_Bullets);

This works well for me.
__________________

Last edited by Paimon; 02-03-2024 at 00:37.
Paimon 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 14:20.


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