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

Tracerays! and detecting water!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mitchell
~lick~
Join Date: Mar 2010
Old 05-29-2012 , 01:01   Tracerays! and detecting water!
Reply With Quote #1

SOLVED!
snippet:
PHP Code:
public Action:GetEnd(clientargs)
{
    new 
Float:vAngles[3], Float:vOrigin[3], Float:pos[3];

    
GetClientEyePosition(clientvOrigin);
    
GetClientEyeAngles(clientvAngles);

    new 
Handle:trace TR_TraceRayFilterEx(vOriginvAnglesMASK_WATERRayType_InfiniteTraceASDF);

    if(
TR_DidHit(trace))
    {
        
TR_GetEndPosition(postrace);
        if(
TR_GetPointContents(pos) != 1)
        {
            
PrintToChat(client"Hit water! :D");
        }
    }
    
CloseHandle(trace);

    return 
Plugin_Handled;


Last edited by Mitchell; 05-31-2012 at 18:56.
Mitchell is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 05-29-2012 , 06:30   Re: Tracerays! and detecting water!
Reply With Quote #2

Ahem, this is not about wether a player is LOOKING at water.
Dr. Greg House is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 05-30-2012 , 21:46   Re: Tracerays! and detecting water!
Reply With Quote #3

Please help? :]
Mitchell is offline
Impact123
Veteran Member
Join Date: Oct 2011
Location: Germany
Old 05-30-2012 , 22:33   Re: Tracerays! and detecting water!
Reply With Quote #4

Don't really know much about it, but something like this should do the trick
PHP Code:
new Float:vec[3];
new 
Float:angles[3];

GetClientEyePosition(clientvec);
GetClientEyeAngles(clientangles);


TR_TraceRay(vecanglesMASK_WATERRayType_Infinite);

if(
TR_DidHit())
{
    
// Is looking at water
}
else
{
   
// Is not looking at water

Yours sincerely
Impact
__________________

Last edited by Impact123; 05-30-2012 at 22:35.
Impact123 is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 05-30-2012 , 23:29   Re: Tracerays! and detecting water!
Reply With Quote #5

Quote:
Originally Posted by Impact123 View Post
Don't really know much about it, but something like this should do the trick
PHP Code:
new Float:vec[3];
new 
Float:angles[3];

GetClientEyePosition(clientvec);
GetClientEyeAngles(clientangles);


TR_TraceRay(vecanglesMASK_WATERRayType_Infinite);

if(
TR_DidHit())
{
    
// Is looking at water
}
else
{
   
// Is not looking at water

Yours sincerely
Impact
I do have a similiar code, but you can look at water inside the ground, like its hard to explain, it ignores ground, i want it to not ignore the Solid Mask, so you cant get a trace if there is something in front of you.
Mitchell is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 05-30-2012 , 23:32   Re: Tracerays! and detecting water!
Reply With Quote #6

after 5 seconds, and several hours after i found a solution, it returns these contents when you look at water on the ground: 256, but 1 if there is something in the way.
PHP Code:
public Action:GetEnd(clientargs)
{
    new 
Float:vAngles[3], Float:vOrigin[3], Float:pos[3];

    
GetClientEyePosition(clientvOrigin);
    
GetClientEyeAngles(clientvAngles);

    new 
Handle:trace TR_TraceRayFilterEx(vOriginvAnglesMASK_WATERRayType_InfiniteTraceASDF);

    if(
TR_DidHit(trace))
    {
        
TR_GetEndPosition(postrace);
        if(
TR_GetPointContents(pos) != 1)
        {
            
PrintToChat(client"Hit water! :D");
        }
    }
    
CloseHandle(trace);

    return 
Plugin_Handled;

Mitchell is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 05-31-2012 , 00:54   Re: Tracerays! and detecting water!
Reply With Quote #7

Realy realy usefull, nice found.
Mathias. is offline
Zephyrus
Cool Pig B)
Join Date: Jun 2010
Location: Hungary
Old 05-31-2012 , 01:04   Re: Tracerays! and detecting water!
Reply With Quote #8

Quote:
Originally Posted by Mitchell View Post
after 5 seconds, and several hours after i found a solution, it returns these contents when you look at water on the ground: 256, but 1 if there is something in the way.
PHP Code:
public Action:GetEnd(clientargs)
{
    new 
Float:vAngles[3], Float:vOrigin[3], Float:pos[3];

    
GetClientEyePosition(clientvOrigin);
    
GetClientEyeAngles(clientvAngles);

    new 
Handle:trace TR_TraceRayFilterEx(vOriginvAnglesMASK_WATERRayType_InfiniteTraceASDF);

    if(
TR_DidHit(trace))
    {
        
TR_GetEndPosition(postrace);
        if(
TR_GetPointContents(pos) != 1)
        {
            
PrintToChat(client"Hit water! :D");
        }
    }
    
CloseHandle(trace);

    return 
Plugin_Handled;

you should also check waterlevel to make sure hes not standing in the water
__________________
Taking private C++/PHP/SourcePawn requests, PM me.
Zephyrus is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 05-31-2012 , 13:31   Re: Tracerays! and detecting water!
Reply With Quote #9

Quote:
Originally Posted by Zephyrus View Post
you should also check waterlevel to make sure hes not standing in the water
Good point, also i need to check the distance but that shouldnt be too hard.
Mitchell is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 05-31-2012 , 18:54   Re: Tracerays! and detecting water!
Reply With Quote #10

This should be like moved to the Snippet section cause it technically is a snippet.
Mitchell 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 21:00.


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