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

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


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
!Morte
Veteran Member
Join Date: May 2010
Old 06-22-2014 , 14:54   Check if the player is over the entity and it's touching it
Reply With Quote #1

I have an entity with a box model, the objetive is everybody have a certain time to get on the entity or they will die.

I have something like this to check if the player is over the entity:

PHP Code:
new FloatiOrigin]
entity_get_vectoridEV_VEC_originiOrigin )

if( 
iOrigin] >= 140.0 )
{
         
client_printidprint_chat"You're over the entity" )

When the player is over the box, his Z origin is > 140.0.

Now the problem is if i just jump away from de box, my Z origin still being > 140.0.

I want to know how i can check if the player is touching the entity without have to use register_touch or any fuction which is called a many often, because i try with this:

PHP Code:
 register_touchMy_Entity"player""function" )

public function( 
entid )
{
           if( !
pev_validid ) )
                   return;

           
g_Touchingid ] = true

And i know that is bad as hell because register_touch it's called a lot of time per second
__________________
First Zombie Class
[ZP] Zombie Class: Houndeye Zombie
Quote:
Originally Posted by lucas_7_94 View Post
tenes que saber pawn antes de intentar hacer algo digno.
!Morte is offline
Send a message via MSN to !Morte Send a message via Skype™ to !Morte
.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
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 06-22-2014 , 16:38   Re: Check if the player is over the entity and it's touching it
Reply With Quote #3

PHP Code:
pev(idpev_groundentity); 
on player think maybe? pev_groundentity tells on which entity are you standing on right now.
klippy is online now
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 16:01.


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