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

How to detect if player is x units near ground?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lazarev
Veteran Member
Join Date: Sep 2008
Old 01-04-2010 , 08:52   How to detect if player is x units near ground?
Reply With Quote #1

title.

Last edited by lazarev; 01-04-2010 at 09:22.
lazarev is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-04-2010 , 09:02   Re: How to detect if player is x units before ground?
Reply With Quote #2

Something like this:
Code:
#include < amxmodx > #include < fakemeta > Float:GetHeightOffGround( iPlayer ) {     new iFlags = pev( iPlayer, pev_flags );     if( iFlags & FL_ONGROUND ) {         return 0.0;     }         static Float:vOrigin[ 3 ];     pev( iPlayer, pev_origin, vOrigin );         static Float:vTraceStop[ 3 ];     pev( iPlayer, pev_mins, vTraceStop );     vOrigin[ 2 ] += vTraceStop[ 2 ];         vTraceStop[ 0 ] = vOrigin[ 0 ];     vTraceStop[ 1 ] = vOrigin[ 1 ];     vTraceStop[ 2 ] = vOrigin[ 2 ] - 4000.0;         engfunc( EngFunc_TraceHull, vOrigin, vTraceStop, 0, iFlags & FL_DUCKING ? HULL_HEAD : HULL_HUMAN, iPlayer, 0 );         get_tr2( 0, TR_vecEndPos, vTraceStop );         return ( vOrigin[ 2 ] - vTraceStop[ 2 ] + 32.0 ); }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
lazarev
Veteran Member
Join Date: Sep 2008
Old 01-04-2010 , 09:20   Re: How to detect if player is x units before ground?
Reply With Quote #3

can you give me an example how to use it? :[
PHP Code:
    if( GetHeightOffGroundid ) == 18 )
        
client_print(idprint_chat"hi im test"
is that right?
lazarev is offline
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 01-04-2010 , 09:28   Re: How to detect if player is x units near ground?
Reply With Quote #4

needs to be a float

Code:
if( GetHeightOffGround( id ) == 18.0 ) //<-- notice the float
        client_print(id, print_chat, "hi im test")
__________________
minimiller is offline
Send a message via MSN to minimiller
lazarev
Veteran Member
Join Date: Sep 2008
Old 01-04-2010 , 09:52   Re: How to detect if player is x units near ground?
Reply With Quote #5

I tried float, but it didn't help me
lazarev is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-04-2010 , 10:14   Re: How to detect if player is x units near ground?
Reply With Quote #6

Try using this first:
Code:
client_print( iPlayer, print_chat, "Current Height Off Ground: %f", GetHeightOffGround( iPlayer ) );
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
lazarev
Veteran Member
Join Date: Sep 2008
Old 01-04-2010 , 10:16   Re: How to detect if player is x units near ground?
Reply With Quote #7

It works, but I need an action, if player, for example, is on 100 units before ground =)

Last edited by lazarev; 01-04-2010 at 10:21.
lazarev is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-04-2010 , 10:26   Re: How to detect if player is x units near ground?
Reply With Quote #8

There is no "action" for that.
You just have to check the value in something such as Pre/PostThink.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 01-04-2010 , 10:28   Re: How to detect if player is x units near ground?
Reply With Quote #9

PHP Code:
    if( GetHeightOffGroundid ) == 18 )
        
client_print(idprint_chat"hi im test"
when did u call that code?
i doubt even prethink could keep up that fast
u might want to broaden your range
for E.g.
PHP Code:
new Float:flHeight GetHeightOffGround(id);
if(
19.0 flHeight 17.0)
        
client_print(idprint_chat"hi im test"
__________________
minimiller is offline
Send a message via MSN to minimiller
lazarev
Veteran Member
Join Date: Sep 2008
Old 01-04-2010 , 10:33   Re: How to detect if player is x units near ground?
Reply With Quote #10

Quote:
Originally Posted by Exolent[jNr] View Post
There is no "action" for that.
You just have to check the value in something such as Pre/PostThink.
Sorry, I gave you bad explanation, I need something like this:
PHP Code:
if( ( DistanceToGround ) == value ) {
// my code

lazarev 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:43.


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