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

Teleport by using traceray


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CamerDisco
AlliedModders Donor
Join Date: Aug 2015
Location: Poland
Old 05-25-2017 , 10:31   Teleport by using traceray
Reply With Quote #1

Hello, I want to teleport player where he looks, but of course it'll teleport player to textures, so I tried traceray:
PHP Code:
    float PlayerPos[3];
    
float clientEye[3], clientAngle[3];
    
GetClientEyePosition(clientclientEye);
    
GetClientEyeAngles(clientclientAngle);

    
TR_TraceRayFilter(clientEyeclientAngleMASK_SOLIDRayType_InfiniteTraceRayTryToHit);
    
    
    if (
TR_DidHit(INVALID_HANDLE))
        
TR_GetEndPosition(PlayerPos);
        
    
TeleportEntity(clientPlayerPosNULL_VECTORNULL_VECTOR); 
and
PHP Code:
public bool TraceRayTryToHit(int entityint mask)
{
    if(
entity && entity <= MaxClients)
        return 
false;
    return 
true;

but it also can teleport to walls, I think bool TraceRayTryToHit must be changed, but I don't know what exactly.
__________________


Max-Play.pl - the best polish servers
CamerDisco is offline
Kinsi
Senior Member
Join Date: Apr 2013
Old 05-25-2017 , 14:21   Re: Teleport by using traceray
Reply With Quote #2

Since you are setting the center of the players Origin, the center will be where the client looks, so inside a wall / surface. You could try to give the player noclip twice (give and instantly take away) because in CS:GO players are attempted to "unstuck" by the engine when they exit noclip (noclip_fixup)
Kinsi is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 05-25-2017 , 15:16   Re: Teleport by using traceray
Reply With Quote #3

I think you can check if the player would be stuck before actually teleporting him.
https://forums.alliedmods.net/showpo...13&postcount=2
You could probably change this so it checks for the world and other entities.
Mitchell is offline
Despirator
Senior Member
Join Date: Jun 2011
Location: Kazakhstan ->Shymkent
Old 05-26-2017 , 00:06   Re: Teleport by using traceray
Reply With Quote #4

You can use TraceHull to the point you looking at. This function allows you to check the mins and maxs being touched by any entity. Then use TR_GetEndPosition

Last edited by Despirator; 05-26-2017 at 00:06.
Despirator is offline
CamerDisco
AlliedModders Donor
Join Date: Aug 2015
Location: Poland
Old 05-26-2017 , 08:06   Re: Teleport by using traceray
Reply With Quote #5

Quote:
Originally Posted by Despirator View Post
You can use TraceHull to the point you looking at. This function allows you to check the mins and maxs being touched by any entity. Then use TR_GetEndPosition
PHP Code:
    float PlayerPos[3];
    
float clientEye[3], clientAngle[3];
    
GetClientEyePosition(clientclientEye);
    
GetClientEyeAngles(clientclientAngle);

    
float mins[3], maxs[3];
    
GetClientMins(clientmins);
    
GetClientMaxs(clientmaxs);

    
TR_TraceHull(clientEyeclientAngleminsmaxsMASK_SOLID);
    
    
    if(
TR_DidHit())
        
TR_GetEndPosition(PlayerPos);
    
    
PrintToChat(client"%f"PlayerPos);
        
    
TeleportEntity(clientPlayerPosNULL_VECTORNULL_VECTOR); 
I tried something like this, but it doesn't work, it's teleporting me a little to up.
__________________


Max-Play.pl - the best polish servers
CamerDisco is offline
Despirator
Senior Member
Join Date: Jun 2011
Location: Kazakhstan ->Shymkent
Old 05-26-2017 , 23:52   Re: Teleport by using traceray
Reply With Quote #6

Quote:
if(TR_DidHit())
Remove it

Also TraceHull is point to point ray not angles
https://sm.alliedmods.net/new-api/sd...e/TR_TraceHull

Quote:
TR_TraceHull(vecPos, vecEndPos, mins, maxs, MASK_SOLID);

--.A---------.B
ray

Last edited by Despirator; 05-26-2017 at 23:55.
Despirator is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 05-27-2017 , 00:26   Re: Teleport by using traceray
Reply With Quote #7

It's almost like I didnt link to a working snippet already..
Mitchell is offline
CamerDisco
AlliedModders Donor
Join Date: Aug 2015
Location: Poland
Old 05-27-2017 , 07:25   Re: Teleport by using traceray
Reply With Quote #8

Quote:
Originally Posted by Despirator View Post
Remove it

Also TraceHull is point to point ray not angles
https://sm.alliedmods.net/new-api/sd...e/TR_TraceHull
But How can I get end pos?

Quote:
Originally Posted by Mitchell View Post
It's almost like I didnt link to a working snippet already..
I don't understand how can it help me. It's bool who is checking that player is stucked on other player.


@ I got stocks from this topic: https://forums.alliedmods.net/showth...0782?p=1370782 and it seems to be working.
__________________


Max-Play.pl - the best polish servers

Last edited by CamerDisco; 05-27-2017 at 07:38.
CamerDisco 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 22:04.


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