AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   trace ray not hitting head (https://forums.alliedmods.net/showthread.php?t=331696)

farawayf 04-02-2021 13:25

trace ray not hitting head
 
as the title of topic says, traceray never hits players head.
is there any way to get if client aiming head ?

Bacardi 04-02-2021 14:13

Re: trace ray not hitting head
 
show your code

farawayf 04-02-2021 15:04

Re: trace ray not hitting head
 
Quote:

Originally Posted by Bacardi (Post 2742763)
show your code

it not matters. i tried any snippets from topics and all of them not hitting players head.
for example https://forums.alliedmods.net/showpo...4&postcount=12|
hits body, but not head.
and "int GetClientAimTarget(int client, bool only_clients)" have same problem.

the game is cs:s. all player models are default one.

Marttt 04-02-2021 17:40

Re: trace ray not hitting head
 
Maybe you have to use TR_TraceHullFilterEx.

Btw is always important to share some code that you are using if you want some help. (I know you shared that link but the reply was kinda rude IMO)

No code is like a shot in the dark.

Bacardi 04-02-2021 17:42

Re: trace ray not hitting head
 
yep. Show your code next time...
*I quick tested in cs:go tough...


PHP Code:

#include <sdktools>

// ---------------------------
//  Hit Group standards
// ---------------------------
#define        HITGROUP_GENERIC    0
#define        HITGROUP_HEAD        1
#define        HITGROUP_CHEST        2
#define        HITGROUP_STOMACH    3
#define        HITGROUP_LEFTARM    4    
#define        HITGROUP_RIGHTARM    5
#define        HITGROUP_LEFTLEG    6
#define        HITGROUP_RIGHTLEG    7
#define        HITGROUP_GEAR        10            // alerts NPC, but doesn't do damage or bleed (1/100th damage)



public void OnPluginStart()
{
    
RegConsoleCmd("sm_test"test);
}

public 
Action test(int clientint args)
{
    
float eyespos[3];
    
GetClientEyePosition(clienteyespos);
    
float eyesang[3];
    
GetClientEyeAngles(clienteyesang);

    
Handle Ray TR_TraceRayFilterEx(eyesposeyesangMASK_SHOTRayType_Infinitefilterclient);
    
int index TR_GetEntityIndex(Ray);
    
int hitgroup TR_GetHitGroup(Ray);

    if(
index && hitgroup == HITGROUP_HEAD)
        
PrintToServer("%N HitBoxIndex %i HitGroup %i"indexTR_GetHitBoxIndex(Ray), hitgroup);
    
    
delete Ray;
    


    return 
Plugin_Handled;
}



public 
bool filter(int entityint contentsMaskany data)
{
    
// Don't look yourself, only client indexes
    
if(entity != data && entity && entity <= MaxClients) return true;

    return 
false;



farawayf 04-02-2021 18:16

Re: trace ray not hitting head
 
i wasnt trying to be rude. thats just the answer.
i did not write my code because after it i tried a lot of codes and all the results were the same, so it was just nonse doing it again.
Thank you both.

Will test your example when ill be free. Bacardi


All times are GMT -4. The time now is 12:11.

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