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

How to detect if player is x units near ground?


Post New Thread Reply   
 
Thread Tools Display Modes
lazarev
Veteran Member
Join Date: Sep 2008
Old 01-04-2010 , 18:30   Re: How to detect if player is x units near ground?
Reply With Quote #11

Fixed problem the code is:
PHP Code:
public fwdPlayerPreThinkid 
{
    if( 
is_user_aliveid ) )
    {
        if( 
GetHeightOffGroundid ) < 100.0 100.0 
        {
            
// my code
        
}
    }

lazarev is offline
platzpatrone
Veteran Member
Join Date: Apr 2007
Location: Germany
Old 01-04-2010 , 19:09   Re: How to detect if player is x units near ground?
Reply With Quote #12

PHP Code:
if( GetHeightOffGroundid ) < 100.0 100.0 
this makes sense ?
platzpatrone is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 01-04-2010 , 20:56   Re: How to detect if player is x units near ground?
Reply With Quote #13

Quote:
Originally Posted by platzpatrone View Post
PHP Code:
if( GetHeightOffGroundid ) < 100.0 100.0 
this makes sense ?
If you remove the last part it does.
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath is offline
platzpatrone
Veteran Member
Join Date: Apr 2007
Location: Germany
Old 01-04-2010 , 21:35   Re: How to detect if player is x units near ground?
Reply With Quote #14

Quote:
Originally Posted by Xellath View Post
If you remove the last part it does.
thats what i would pointing out thank you
platzpatrone is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-05-2010 , 08:44   Re: How to detect if player is x units near ground?
Reply With Quote #15

I ran a plugin that compared the below function and the one above. The above at times will return 4000+ units while this returns a more realistic number.

PHP Code:
FloatGetHeightOffGroundiPlayer )
{
    if ( 
peviPlayer pev_flags ) & FL_ONGROUND )
        return 
0.0;
        
    new 
Float:fOriginPlayer] , Float:fOriginGround];
    
    
peviPlayer pev_origin fOriginPlayer );
    
fOriginGround fOriginPlayer;
    
fOriginGround] = 0.0;
    
    return 
get_distance_ffOriginPlayer fOriginGround );

To see what I mean, stand on a ramp (like at long A heading to bombsite on dust2) and keep jumping.

PHP Code:
#include <amxmodx>
#include <fakemeta>

public plugin_init() 
{
    
register_plugin"test" "0.1" "bugsy" );
    
    
set_task(1.0"ShowHeight"0__"b" );
}

public 
ShowHeight( )
{
    new 
id get_user_index"bugsy" );
    
    if ( 
id )
    {    
        
client_printid print_chat "%f = %f" GetHeightOffGroundid ) , GetHeightOffGround2id ) );
    }
}

FloatGetHeightOffGround2iPlayer )
{
    if ( 
peviPlayer pev_flags ) & FL_ONGROUND )
        return 
0.0;
        
    new 
Float:fOriginPlayer] , Float:fOriginGround];
    
    
peviPlayer pev_origin fOriginPlayer );
    
fOriginGround fOriginPlayer;
    
fOriginGround] = 0.0;
    
    return 
get_distance_ffOriginPlayer fOriginGround );
}

Float:GetHeightOffGroundiPlayer ) {
    new 
iFlags peviPlayerpev_flags );
    if( 
iFlags FL_ONGROUND ) {
        return 
0.0;
    }
    
    static 
Float:vOrigin];
    
peviPlayerpev_originvOrigin );
    
    static 
Float:vTraceStop];
    
peviPlayerpev_minsvTraceStop );
    
vOrigin] += vTraceStop];
    
    
vTraceStop] = vOrigin];
    
vTraceStop] = vOrigin];
    
vTraceStop] = vOrigin] - 4000.0;
    
    
engfuncEngFunc_TraceHullvOriginvTraceStop0iFlags FL_DUCKING HULL_HEAD HULL_HUMANiPlayer);
    
    
get_tr20TR_vecEndPosvTraceStop );
    
    return ( 
vOrigin] - vTraceStop] + 32.0 );

__________________
Bugsy is offline
kielor
Senior Member
Join Date: Jan 2009
Location: Russia, Novosibirsk
Old 01-05-2010 , 12:11   Re: How to detect if player is x units near ground?
Reply With Quote #16

PHP Code:
FloatGetHeightOffGround2iPlayer 

    if ( 
peviPlayer pev_flags ) & FL_ONGROUND 
        return 
0.0
         
    new 
Float:fOriginPlayer];
     
    
peviPlayer pev_origin fOriginPlayer ); 
     
    return 
floatabsfOriginPlayer[2] ); 

easier, but has the same effect and work only when the ground under you is 0.0 origin[z]
__________________
try using +karma if i helped you...
kielor is offline
Send a message via ICQ to kielor Send a message via Skype™ to kielor
kielor
Senior Member
Join Date: Jan 2009
Location: Russia, Novosibirsk
Old 01-05-2010 , 13:11   Re: How to detect if player is x units near ground?
Reply With Quote #17

btw Exolent your stock gives 4032.0 if we are less than 32 units up(nonducked)
__________________
try using +karma if i helped you...
kielor is offline
Send a message via ICQ to kielor Send a message via Skype™ to kielor
bibu
Veteran Member
Join Date: Sep 2010
Old 01-15-2011 , 09:45   Re: How to detect if player is x units near ground?
Reply With Quote #18

I am using this (exolents stock):

PHP Code:
GetHeightOffGround(id) > 800.0 
Should then the player not be over the ground? Cause it returns true if I am on ground.
bibu is offline
lazarev
Veteran Member
Join Date: Sep 2008
Old 01-15-2011 , 13:45   Re: How to detect if player is x units near ground?
Reply With Quote #19

Quote:
Originally Posted by bibu View Post
I am using this (exolents stock):

PHP Code:
GetHeightOffGround(id) > 800.0 
Should then the player not be over the ground? Cause it returns true if I am on ground.
Thank you for such an awesome bump!
The answer is: yes
lazarev is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 01-15-2011 , 13:49   Re: How to detect if player is x units near ground?
Reply With Quote #20

It isn't a bump at all. I didn't want to start a new thread for this. Tell me also something to my second statement.
bibu 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 08:49.


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