Raised This Month: $ Target: $400
 0% 

Check if the player is over the entity and it's touching it


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 06-22-2014 , 15:07   Re: Check if the player is over the entity and it's touching it
Reply With Quote #2

try it

PHP Code:
// if you dont like the fakemeta, replace it with engine...
// returns 1 if ent2 is above ent1 
stock is_touchingent1ent2 )
{
    static 
Float:mins1[3], Float:mins2[3], Float:mins[3]
    static 
Float:maxs1[3], Float:maxs2[3], Float:maxs[3]    
    static 
Float:o1[3], Float:o2[3]
    static 
aFloat:d[3]
    
pevent1pev_minsmins1 )
    
pevent2pev_minsmins2 )
    
pevent1pev_maxsmaxs1 )
    
pevent2pev_maxsmaxs2 )
    
pevent1pev_origino1 )
    
pevent2pev_origino2 )
    for( 
03a++ )
    {
        
d[a] = o1[a] - o2[a]
        
mins[a] = mins1[a] + mins2[a]
        
maxs[a] = maxs1[a] + maxs2[a]
        if( (
d[a] < 0.0 && mins[a] < d[a]) || ( d[a] > 0.0 || maxs[a] > d[a] ) ) return 0
    
}
    return 
1

edit ( since misunderstood the op )
PHP Code:
// if you dont like the fakemeta, replace it with engine...
// returns 1 if is touching ( also returns 1 when entity is inside of another entity )
// ( in your case ent2 will be id or player  )
stock is_touching_from_aboveent1ent2 )
{
    static 
Float:mins1[3], Float:mins2[3], Float:mins[3]
    static 
Float:maxs1[3], Float:maxs2[3], Float:maxs[3]    
    static 
Float:o1[3], Float:o2[3]
    static 
aFloat:d[3]
    
pevent1pev_minsmins1 )
    
pevent2pev_minsmins2 )
    
pevent1pev_maxsmaxs1 )
    
pevent2pev_maxsmaxs2 )
    
pevent1pev_origino1 )
    
pevent2pev_origino2 )
    
mins1[2] = maxs1[2]
    
maxs1[2] += 1.0
    
for( 03a++ )
    {
        
d[a] = o1[a] - o2[a]
        
mins[a] = mins1[a] + mins2[a]
        
maxs[a] = maxs1[a] + maxs2[a]
        if( (
d[a] < 0.0 && mins[a] < d[a]) || ( d[a] > 0.0 || maxs[a] > d[a] ) ) return 0
    
}
    return 
1


Last edited by .Dare Devil.; 06-22-2014 at 16:53.
.Dare Devil. is offline
 



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:10.


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