Raised This Month: $32 Target: $400
 8% 

Solved Check walll between two players


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Minfas
Member
Join Date: Dec 2017
Old 01-27-2020 , 01:46   Check walll between two players
Reply With Quote #1

Hello,
how to check if there is a wall between two players? (game csgo)
Thank you.

Last edited by Minfas; 02-04-2020 at 10:20. Reason: Solved
Minfas is offline
Kolapsicle
Senior Member
Join Date: Oct 2014
Old 01-29-2020 , 04:25   Re: Check walll between two players
Reply With Quote #2

Using both clients' positions, you can cast a ray from one to the other, and check for collisions. TR_TraceRayFilter will allow you to do this, but depending on your plans you may want a hull trace. Since you'll be using client positions, you will likely need to filter out clients from the trace, hence the filter callback. Inside the include file you'll find different masks, enums, and other flags.
Kolapsicle is offline
Minfas
Member
Join Date: Dec 2017
Old 01-29-2020 , 06:58   Re: Check walll between two players
Reply With Quote #3

Thanks for reply, I have currently this

PHP Code:
float traceDir[3];
SubtractVectors(iPosclientPostraceDir);

TR_TraceHullFilter(iPostraceDir, const float mins[3], const float maxs[3], MASK_VISIBLETraceFilterClients);
if(
TR_DidHit()) 
{
    
//...

PHP Code:
public bool TraceFilterClients(entitycontentsMaskany data
{    
    if (
entity && entity <= MaxClients
    { 
        return 
true
    }
    else 
    { 
        return 
false
    } 

I don't know what are maxs and mins.
Minfas is offline
Kolapsicle
Senior Member
Join Date: Oct 2014
Old 01-29-2020 , 07:23   Re: Check walll between two players
Reply With Quote #4

Mins and Maxs are points that form the hull. You can define the points yourself, or get the existing values from the clients.

PHP Code:
float vecMins[3], vecMaxs[3];
GetClientMins(clientvecMins);
GetClientMaxs(clientvecMaxs); 

Last edited by Kolapsicle; 01-29-2020 at 07:24.
Kolapsicle is offline
Minfas
Member
Join Date: Dec 2017
Old 01-29-2020 , 11:30   Re: Check walll between two players
Reply With Quote #5

Now I am trying to make something like fake explosion.
PHP Code:
float traceDir[3];
SubtractVectors(clientPosexplosionPostraceDir);

float vecMins[3], vecMaxs[3];
vecMins[0] = 16.0;
vecMins[1] = 16.0;
vecMins[2] = 16.0;
vecMaxs[0] = 16.0;
vecMaxs[1] = 16.0;
vecMaxs[2] = 16.0;

TR_TraceHull(explosionPosclientPosvecMinsvecMaxsMASK_SOLID);
if(!
TR_DidHit())
{
     
PrintToChatAll("hit!");

It's never working. Can someone help what to use? I tried TraceRay, but maybe with wrong filters or mask.

Last edited by Minfas; 01-29-2020 at 11:44.
Minfas is offline
Kolapsicle
Senior Member
Join Date: Oct 2014
Old 01-30-2020 , 02:05   Re: Check walll between two players
Reply With Quote #6

Mins is the minimum size of your hull, and Maxs is the maximum size.



If you don't need a hull, then you should use a Ray.

Last edited by Kolapsicle; 01-30-2020 at 09:51.
Kolapsicle is offline
Minfas
Member
Join Date: Dec 2017
Old 01-30-2020 , 13:49   Re: Check walll between two players
Reply With Quote #7

I tried Ray function but its not doing anything neither I am behind wall or not.
PHP Code:
TR_TraceRayFilter(clientPosexplosionPosMASK_SOLIDRayType_EndPointTraceRayFilter);
if(!
TR_DidHit())
{
    
PrintToChat(client"hit!");

Minfas is offline
Kolapsicle
Senior Member
Join Date: Oct 2014
Old 01-31-2020 , 00:32   Re: Check walll between two players
Reply With Quote #8

You aren't passing any data to the filter callback. Your trace is probably just hitting the client at clientPos, and returning a collision. See the last parameter of TR_TraceRayFilter.
Kolapsicle is offline
Minfas
Member
Join Date: Dec 2017
Old 01-31-2020 , 18:31   Re: Check walll between two players
Reply With Quote #9

Ok, now its working, but even through walls. :/

PHP Code:
float traceDir[3];
SubtractVectors(explosionPosclientPostraceDir);

Handle trace TR_TraceRayFilterEx(explosionPostraceDirMASK_SOLIDRayType_InfiniteTraceFilterClientsclient);
if(
TR_DidHit(trace))
{
    
PrintToChatAll("hit!");

PHP Code:
public bool TraceFilterClients(int entityint contentsMaskany data
{    
    if (
entity && entity <= MaxClients
    {
        return 
true
    }
    else 
    { 
        return 
false
    } 

Minfas is offline
Kolapsicle
Senior Member
Join Date: Oct 2014
Old 01-31-2020 , 23:35   Re: Check walll between two players
Reply With Quote #10

Your second parameter should be an angle, but traceDir is a vector. Try first getting the angle from the vector with GetVectorAngles.

Also, since you are now passing a client into your filter, you can simplify the filter callback.
PHP Code:
bool TraceFilterClients(int entityint contentsMaskany data)
{
    return 
entity == data// If the entity we collided with is the same as our data (last parameter), return true (filter it)

Kolapsicle is offline
Reply


Thread Tools
Display Modes

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 19:27.


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