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

Player between a Rectangle


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dordnung
Veteran Member
Join Date: Apr 2010
Old 11-01-2010 , 16:43   Player between a Rectangle
Reply With Quote #1

This Snippet checks if a player is between a rectangular area specified by two opposite corners

Picture (;



PHP Code:
#include <sourcemod>

bool:IsbetweenRect(Float:Pos[3], Float:Corner1[3], Float:Corner2[3], client=0

    
decl Float:Entity[3]; 
    
decl Float:field1[2]; 
    
decl Float:field2[2]; 
    
decl Float:field3[2]; 
    
    if (!
client)
    {
        
Entity Pos;
    }
    else 
GetClientAbsOrigin(clientEntity); 
     
    
// Sort Floats... 
     
    
if (FloatCompare(Corner1[0], Corner2[0]) == -1)  
    { 
        
field1[0] = Corner1[0]; 
        
field1[1] = Corner2[0]; 
    } 
    else 
    { 
        
field1[0] = Corner2[0]; 
        
field1[1] = Corner1[0]; 
    } 
    if (
FloatCompare(Corner1[1], Corner2[1]) == -1)  
    { 
        
field2[0] = Corner1[1]; 
        
field2[1] = Corner2[1]; 
    } 
    else 
    { 
        
field2[0] = Corner2[1]; 
        
field2[1] = Corner1[1]; 
    } 
    if (
FloatCompare(Corner1[2], Corner2[2]) == -1)  
    { 
        
field3[0] = Corner1[2]; 
        
field3[1] = Corner2[2]; 
    } 
    else 
    { 
        
field3[0] = Corner2[2]; 
        
field3[1] = Corner1[2]; 
    } 
     
    
// Check the Vectors ... 
     
    
if (Entity[0] < field1[0] || Entity[0] > field1[1]) return false
    if (
Entity[1] < field2[0] || Entity[1] > field2[1]) return false
    if (
Entity[2] < field3[0] || Entity[2] > field3[1]) return false
     
    return 
true

Have fun with it (;
Attached Thumbnails
Click image for larger version

Name:	eg.jpg
Views:	864
Size:	30.9 KB
ID:	76562  
__________________

Last edited by dordnung; 11-03-2010 at 03:09.
dordnung is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 11-02-2010 , 06:31   Re: Player between a Rectangle
Reply With Quote #2

Define: between a rectangle.
__________________

Last edited by FaTony; 11-02-2010 at 06:44.
FaTony is offline
M1NDFREAK
Junior Member
Join Date: Nov 2010
Old 11-02-2010 , 07:29   Re: Player between a Rectangle
Reply With Quote #3

Which rectancle?
M1NDFREAK is offline
dordnung
Veteran Member
Join Date: Apr 2010
Old 11-02-2010 , 07:47   Re: Player between a Rectangle
Reply With Quote #4

Oh sry, i updated my first post

"Checks if a player is between a rectangular area specified by two opposite corners"

And also add a Picture ^^
__________________

Last edited by dordnung; 11-02-2010 at 10:19.
dordnung is offline
Sammy-ROCK!
Senior Member
Join Date: Jun 2008
Location: Near Mrs.Lag
Old 11-02-2010 , 20:58   Re: Player between a Rectangle
Reply With Quote #5

Why not make it Vector instead of client?
Sammy-ROCK! is offline
dordnung
Veteran Member
Join Date: Apr 2010
Old 11-03-2010 , 03:10   Re: Player between a Rectangle
Reply With Quote #6

Ok, i updated the first post, where both is possible (;
__________________
dordnung is offline
SuperShadow
SourceMod Donor
Join Date: Jun 2008
Location: Westminster, MD
Old 11-03-2010 , 14:33   Re: Player between a Rectangle
Reply With Quote #7

Shouldn't that be check if a client is within a box (cube)? A rectangle is 2 dimensional shape.
SuperShadow is offline
dordnung
Veteran Member
Join Date: Apr 2010
Old 11-03-2010 , 18:06   Re: Player between a Rectangle
Reply With Quote #8

"rectangular area" means "cuboid"
__________________
dordnung is offline
SuperShadow
SourceMod Donor
Join Date: Jun 2008
Location: Westminster, MD
Old 11-03-2010 , 18:20   Re: Player between a Rectangle
Reply With Quote #9

Not in English, a rectangle is the surface of one side of a cube.
SuperShadow is offline
dordnung
Veteran Member
Join Date: Apr 2010
Old 11-03-2010 , 18:54   Re: Player between a Rectangle
Reply With Quote #10

Mh, ok ;D
__________________
dordnung 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 19:33.


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