Raised This Month: $ Target: $400
 0% 

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:39   Re: how to execute a function if player is in air?
Reply With Quote #1

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 #2

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 #3

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 #4

Jel ti treba ako Player skoci ili ako je bas u vazduhu?
supertrio17 is offline
Grovliom
Member
Join Date: Mar 2020
Location: somewhere in Serbia
Old 05-31-2020 , 11:48   Re: how to execute a function if player is in air?
Reply With Quote #5

Quote:
Originally Posted by supertrio17 View Post
Jel ti treba ako Player skoci ili ako je bas u vazduhu?
kad je u vazduhu

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

Quote:
Originally Posted by Grovliom View Post
kad je u vazduhu
PHP Code:
#include <amxmodx>
#include <engine>
#include <ColorChat>

new Air

public plugin_init()
{
    
register_plugin("Player in Air""3.2""Mr. Boopsy");
}

public 
client_authorized(id)
{
    
Air 1
}

public 
client_PreThink(id)
{
    
when_in_air(id);
    
when_on_ground(id);
}

public 
when_in_air(id)
{
    if(!(
get_entity_flags(id) & FL_ONGROUND))
    {
        if(
Air == 1)
        {
            
ColorChat(idGREEN"You are in air");
            
Air 0;
        }
    }


public 
when_on_ground(id)
{
    if(
get_entity_flags(id) & FL_ONGROUND)
    {
        
Air 1;
    }

My brain is officialy melted, its so simple solution, but it took me ages to figure this out.
supertrio17 is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 05-31-2020 , 13:56   Re: how to execute a function if player is in air?
Reply With Quote #7

Quote:
Originally Posted by Grovliom View Post
kad je u vazduhu
To make it a little bit simpler, here is more compact one

PHP Code:
#include <amxmodx>
#include <engine>
#include <ColorChat>

new Air

public plugin_init()
{
    
register_plugin("Player in Air""3.3""Mr. Boopsy");
}

public 
client_authorized(id)
{
    
Air 1
}

public 
client_PreThink(id)
{
    if(!(
get_entity_flags(id) & FL_ONGROUND))
    {
        if(
Air == 1)
        {
            
ColorChat(idGREEN"You are in air");
            
Air 0;
        }
    }
    else
    {
        
Air 1;
    }

Edit:

It's not only for jumping, but for falling too, so if you fall of a box or something similar it will execute your command, in my case "ColorChat(id, GREEN, "You are in air")".
Hope I helped

Last edited by supertrio17; 05-31-2020 at 14:01.
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 17:11.


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