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

how to execute a function if player is in air?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Grovliom
Member
Join Date: Mar 2020
Location: somewhere in Serbia
Old 05-31-2020 , 11:24   how to execute a function if player is in air?
Reply With Quote #1

how do i do that? thanks!
Grovliom is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 05-31-2020 , 11:31   Re: how to execute a function if player is in air?
Reply With Quote #2

check player flags, if there ain't FL_ONGROUND => player on air (or on ladder)
PHP Code:
if(!(pev(idpev_flags) & FL_ONGROUUND))
{
        
//Here

__________________
My plugin:
Celena Luna is offline
Grovliom
Member
Join Date: Mar 2020
Location: somewhere in Serbia
Old 05-31-2020 , 11:35   Re: how to execute a function if player is in air?
Reply With Quote #3

Quote:
Originally Posted by Celena Luna View Post
check player flags, if there ain't FL_ONGROUND => player on air (or on ladder)
PHP Code:
if(!(pev(idpev_flags) & FL_ONGROUUND))
{
        
//Here

i tried it in client_PreThink, but it just executes the function a lot of times.. what else can i use except client_prethink
Grovliom is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 05-31-2020 , 11:36   Re: how to execute a function if player is in air?
Reply With Quote #4

I belive that easiest solution is to use get_entity_flags, something like this:

PHP Code:
public is_user_in_air(id)
{
    if(!(
get_entity_flags(id) & FL_ONGROUND))
    {
        
//execute when in air
    
}
    else
    {
        
//execute when on ground
    
}

supertrio17 is offline
Grovliom
Member
Join Date: Mar 2020
Location: somewhere in Serbia
Old 05-31-2020 , 11:37   Re: how to execute a function if player is in air?
Reply With Quote #5

Quote:
Originally Posted by supertrio17 View Post
I belive that easiest solution is to use get_entity_flags, something like this:

PHP Code:
public is_user_in_air(id)
{
    if(!(
get_entity_flags(id) & FL_ONGROUND))
    {
        
//execute when in air
    
}
    else
    {
        
//execute when on ground
    
}

in what function do i put it so it checks? (like client_prethink)
Grovliom is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 05-31-2020 , 11:38   Re: how to execute a function if player is in air?
Reply With Quote #6

PHP Code:
public client_PreThink(id)
{
    
is_user_in_air(id)
}

public 
is_user_in_air(id)
{
    if(!(
get_entity_flags(id) & FL_ONGROUND))
    {
        
//execute when in air
    
}
    else
    {
        
//execute when on ground
    
}


Last edited by supertrio17; 05-31-2020 at 11:38.
supertrio17 is offline
Grovliom
Member
Join Date: Mar 2020
Location: somewhere in Serbia
Old 05-31-2020 , 11:39   Re: how to execute a function if player is in air?
Reply With Quote #7

Quote:
Originally Posted by supertrio17 View Post
PHP Code:
public client_PreThink(id)
{
    
is_user_in_air(id)
}

public 
is_user_in_air(id)
{
    if(!(
get_entity_flags(id) & FL_ONGROUND))
    {
        
//execute when in air
    
}
    else
    {
        
//execute when on ground
    
}

(srb)
ali kako jednom samo da uradi nesto kad je na nebu, ne sto puta?
(eng)
but how do i execute it once, not a 100 times?

Last edited by Grovliom; 05-31-2020 at 11:43.
Grovliom is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 05-31-2020 , 11:43   Re: how to execute a function if player is in air?
Reply With Quote #8

Quote:
Originally Posted by Grovliom View Post
ali kako jednom samo da uradi nesto kad je na nebu, ne sto puta?
hm, cek da razmislim malo pa ti kazem
supertrio17 is offline
Grovliom
Member
Join Date: Mar 2020
Location: somewhere in Serbia
Old 05-31-2020 , 11:45   Re: how to execute a function if player is in air?
Reply With Quote #9

Quote:
Originally Posted by supertrio17 View Post
hm, cek da razmislim malo pa ti kazem
ok brate!
Grovliom is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 05-31-2020 , 11:47   Re: how to execute a function if player is in air?
Reply With Quote #10

Jel ti treba ako Player skoci ili ako je bas u vazduhu?
supertrio17 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 16:50.


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