AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how to execute a function if player is in air? (https://forums.alliedmods.net/showthread.php?t=324903)

Grovliom 05-31-2020 11:24

how to execute a function if player is in air?
 
how do i do that? thanks!

Celena Luna 05-31-2020 11:31

Re: how to execute a function if player is in air?
 
check player flags, if there ain't FL_ONGROUND => player on air (or on ladder)
PHP Code:

if(!(pev(idpev_flags) & FL_ONGROUUND))
{
        
//Here



Grovliom 05-31-2020 11:35

Re: how to execute a function if player is in air?
 
Quote:

Originally Posted by Celena Luna (Post 2703318)
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

supertrio17 05-31-2020 11:36

Re: how to execute a function if player is in air?
 
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
    
}



Grovliom 05-31-2020 11:37

Re: how to execute a function if player is in air?
 
Quote:

Originally Posted by supertrio17 (Post 2703320)
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)

supertrio17 05-31-2020 11:38

Re: how to execute a function if player is in air?
 
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
    
}



Grovliom 05-31-2020 11:39

Re: how to execute a function if player is in air?
 
Quote:

Originally Posted by supertrio17 (Post 2703322)
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?

supertrio17 05-31-2020 11:43

Re: how to execute a function if player is in air?
 
Quote:

Originally Posted by Grovliom (Post 2703323)
ali kako jednom samo da uradi nesto kad je na nebu, ne sto puta?

hm, cek da razmislim malo pa ti kazem :)

Grovliom 05-31-2020 11:45

Re: how to execute a function if player is in air?
 
Quote:

Originally Posted by supertrio17 (Post 2703324)
hm, cek da razmislim malo pa ti kazem :)

ok brate! :)

supertrio17 05-31-2020 11:47

Re: how to execute a function if player is in air?
 
Jel ti treba ako Player skoci ili ako je bas u vazduhu?


All times are GMT -4. The time now is 17:11.

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