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

TraceRay cant get hit


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
_GamerX
AlliedModders Donor
Join Date: Jun 2011
Location: Fun Server
Old 12-18-2018 , 18:16   TraceRay cant get hit
Reply With Quote #1

Hello i make laser game to my JB everything works but traceray cant get hit to player I try so much ways but never get hit or only hit only world

where is problem?

PHP Code:
public Action LazzerGame(Handle timerany nothing)
{
    if(
LazzerPositions.Length)
    {
        for(
int i 0LazzerPositions.Lengthi++)
        {
            
float start[3], end[3];
            
start[0] = float(LazzerPositions.Get(i0));
            
start[1] = float(LazzerPositions.Get(i1));
            
start[2] = float(LazzerPositions.Get(i2));
            
end[0] = float(LazzerPositions.Get(i3));
            
end[1] = float(LazzerPositions.Get(i4));
            
end[2] = float(LazzerPositions.Get(i5));
            if(
end[0] == 0.0 && end[1] == 0.0 && end[2] == 0.0) continue;
            
TE_SetupBeamPoints(startendPrecacheModel("materials/sprites/laserbeam.vmt"), 0000.22.02.0100.0, {25500175}, 0);
            
TE_SendToAll();
            if(
lazzer_teleport[0] != 0.0 && lazzer_teleport[1] != 0.0 && lazzer_teleport[2] != 0.0)
            {
                
CPrintToChatAll("1");
                
TR_TraceRay(startendCONTENTS_PLAYERCLIPRayType_EndPoint);
                if(
TR_GetEntityIndex(INVALID_HANDLE))
                {
                    
int player_hit TR_GetEntityIndex(INVALID_HANDLE);
                    
CPrintToChatAll("ID: %i"player_hit);
                    if(
IsValidClient(player_hittrue))
                    {
                        
TeleportEntity(player_hitlazzer_teleportNULL_VECTORNULL_VECTOR);
                        
check_stuck(player_hit0);
                    }
                }
                else 
CPrintToChatAll("X");
            }
        }
    }
    else return 
Plugin_Stop;
    return 
Plugin_Continue;
}
public 
bool TraceEntityOnlyPlayer(int entityint contentsMask)
{
    return (
<= entity <= MaxClients) ? true false;

__________________

Last edited by _GamerX; 12-18-2018 at 18:19.
_GamerX is offline
Send a message via ICQ to _GamerX Send a message via Skype™ to _GamerX
Kolapsicle
Senior Member
Join Date: Oct 2014
Old 12-19-2018 , 11:19   Re: TraceRay cant get hit
Reply With Quote #2

I think CONTENTS_PLAYERCLIP refers to the player clip brush texture (invisible walls to players). You can trace a player with CONTENTS_SOLID, but this will also trace brush. As long as you place your start and end points with brush in mind you should be able to achieve what you want.
Kolapsicle is offline
_GamerX
AlliedModders Donor
Join Date: Jun 2011
Location: Fun Server
Old 12-20-2018 , 15:23   Re: TraceRay cant get hit
Reply With Quote #3

I try all MASK with TR_TraceRayFiler i filter non player ents but still get hit to world 0 why?
__________________
_GamerX is offline
Send a message via ICQ to _GamerX Send a message via Skype™ to _GamerX
Aes
Junior Member
Join Date: Nov 2018
Old 12-20-2018 , 19:35   Re: TraceRay cant get hit
Reply With Quote #4

I'm using this fine, to check if a ray hit the player

Code:
Handle trace = TR_TraceRayFilterEx(vEPos, vEnd, MASK_SHOT, RayType_EndPoint,TraceEntityFilterCurrentPlayer , client);
if (TR_DidHit(trace))
{
	int target = TR_GetEntityIndex(trace);
	if(IsValidClient(target))
	{
		return;
	}
}
delete trace;

public bool TraceEntityFilterCurrentPlayer(int entity, int contentsMask, int client)
{
	return entity != client;
}
Try it
Aes is offline
_GamerX
AlliedModders Donor
Join Date: Jun 2011
Location: Fun Server
Old 12-21-2018 , 08:02   Re: TraceRay cant get hit
Reply With Quote #5

still getting only hit to world
__________________
_GamerX is offline
Send a message via ICQ to _GamerX Send a message via Skype™ to _GamerX
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 17:43.


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