Raised This Month: $ Target: $400
 0% 

Detect between trace the entity, not player.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 01-03-2011 , 10:22   Detect between trace the entity, not player.
Reply With Quote #1

So I'm trying to get point from one player to another, but I need to detect if between those two origins are wall or other entity, but not player. How to do it?

PHP Code:
public bool:IsClientInViewOfAnotherPlayer(client)
{
    new 
Float:vOrigin[3];
    
GetClientAbsOrigin(clientvOrigin);
    for(new 
enemy 1enemy <= MaxClientsenemy++) 
    {
        if ( 
IsValidAlive(enemy) )
        {
            new 
Float:targetorigin[3];
            
GetClientAbsOrigin enemytargetorigin );
    
            new 
Handle:trace TR_TraceRayFilterExvOrigintargetoriginMASK_SOLIDRayType_InfiniteTraceEntityFilterPlayer2);
    
            if(
TR_DidHit(trace))
            {
                return 
true;
            }
                
            
CloseHandle(trace);
        }
    }

    return 
false;
}
public 
bool:TraceEntityFilterPlayer2(entityiContentsMask)
{
    return 
entity GetMaxClients();

__________________
xbatista is offline
Send a message via Skype™ to xbatista
blodia
Veteran Member
Join Date: Sep 2009
Location: UK
Old 01-03-2011 , 10:37   Re: Detect between trace the entity, not player.
Reply With Quote #2

i don't get why you started another thread when this is just the same thing you asked in a previous thread.

you want to use RayType_EndPoint not RayType_Infinite if the 2nd parameter is a set of coordinates and not an angle vector.

in your filter you want to hit world (entity 0) and any entity that is not a player (entity > MaxClients).
blodia is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 01-03-2011 , 13:10   Re: Detect between trace the entity, not player.
Reply With Quote #3

Ohh thanks RayType_EndPoint did it(and a bit edited code) , now it works, but have a little little bug.
And I still don't understand that raytypes

PHP Code:
public bool:IsClientNotInView(client)
{
    new 
Float:vOrigin[3], Float:distancebetween;
    
GetClientAbsOrigin(clientvOrigin);
    
    
vOrigin[2] += 35.0
    
    
for(new enemy 1enemy <= MaxClientsenemy++) 
    {
        if ( 
IsValidAlive(enemy) )
        {
            new 
Float:targetorigin[3];
            
GetClientAbsOrigin enemytargetorigin );
                
            
targetorigin[2] += 35.0
    
            
new Handle:trace TR_TraceRayFilterExvOrigintargetoriginMASK_SOLIDRayType_EndPointTraceEntityFilterPlayer2);
    
            if( 
TR_DidHit(trace) )
            {
                    return 
true;
            }
                
            
CloseHandle(trace);
        }
    }

    return 
false;
}
public 
bool:TraceEntityFilterPlayer2(entityiContentsMask)
{
    return 
entity GetMaxClients();

__________________

Last edited by xbatista; 01-03-2011 at 14:50.
xbatista is offline
Send a message via Skype™ to xbatista
FaTony
Veteran Member
Join Date: Aug 2008
Old 01-03-2011 , 17:37   Re: Detect between trace the entity, not player.
Reply With Quote #4

You should really use MaxClients instead of GetMaxClients();
__________________
FaTony is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 01-04-2011 , 02:45   Re: Detect between trace the entity, not player.
Reply With Quote #5

Ahhh okay forgot about that
__________________
xbatista is offline
Send a message via Skype™ to xbatista
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 01-08-2011 , 07:18   Re: Detect between trace the entity, not player.
Reply With Quote #6

I've noticed that it works weird really, so I tried to use TraceHull,but don't know how to figure this out :/
I just want to check if client in other players Hull(mins,max) with a multiplied value such as this :
PHP Code:
// In some place
new Float:vecMin[3], Float:vecMax[3], Float:Origin[3];
    
GetClientMinsenemyvecMin);
GetClientMaxsenemyvecMax);
                            
vecMin[0] += 2000.0;
vecMin[1] += 2000.0;
                            
vecMax[0] += 2000.0
vecMax
[1] += 2000.0
vecMax
[2] += 2000.0

GetClientAbsOrigin
(clientOrigin);

new 
Handle:trace TR_TraceHullFilterEx(OriginOriginvecMinvecMaxMASK_SOLIDTraceEntityFilterPlayer2);
                        
if ( 
TR_DidHit(trace) )
{
// Hit wall, well then client not seen to others enemy.
}
else
{
// Ohh no, you've been seen by other player.
}

CloseHandle(trace);

// Filter function
public bool:TraceEntityFilterPlayer2(entityiContentsMask)
{
    return 
entity MaxClients;

But it didn't hit the wall using Hull.
__________________

Last edited by xbatista; 01-08-2011 at 07:23.
xbatista is offline
Send a message via Skype™ to xbatista
FaTony
Veteran Member
Join Date: Aug 2008
Old 01-08-2011 , 07:26   Re: Detect between trace the entity, not player.
Reply With Quote #7

That's a very bad code. What are you trying to achieve?
__________________
FaTony is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 01-08-2011 , 07:37   Re: Detect between trace the entity, not player.
Reply With Quote #8

Picture uploaded.
Ehhmm... I just want to check is client in sight of other clients... Using Hull.
Attached Thumbnails
Click image for larger version

Name:	sight.jpg
Views:	228
Size:	50.0 KB
ID:	80347  
__________________
xbatista is offline
Send a message via Skype™ to xbatista
FaTony
Veteran Member
Join Date: Aug 2008
Old 01-08-2011 , 08:23   Re: Detect between trace the entity, not player.
Reply With Quote #9

No, you check enemy positions against your coords and then trace rays from client to enemies.
__________________
FaTony is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 01-08-2011 , 08:29   Re: Detect between trace the entity, not player.
Reply With Quote #10

It will be only point, and it's bugged that code is above that I gave (3rd post).
__________________
xbatista is offline
Send a message via Skype™ to xbatista
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 05:05.


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