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
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-01-2020 , 21:10   Re: how to execute a function if player is in air?
Reply With Quote #1

Can you explain it a bit, why is that, or why doesn't it work for other players. I'm new at coding, but it works for him,
supertrio17 is offline
thEsp
BANNED
Join Date: Aug 2017
Old 06-02-2020 , 04:30   Re: how to execute a function if player is in air?
Reply With Quote #2

Quote:
Originally Posted by supertrio17 View Post
Can you explain it a bit, why is that, or why doesn't it work for other players. I'm new at coding, but it works for him,
In coding world "it works for me" isn't a good excuse. Remember that Pawn is handled server-side not client-side. It will not take care of your code itself, instead you have to make the way out yourself.

Anyway, make a 33 slots boolean array and respectively store "Air" value in it (per player).

Last edited by thEsp; 06-02-2020 at 04:31.
thEsp is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-02-2020 , 08:59   Re: how to execute a function if player is in air?
Reply With Quote #3

Quote:
Originally Posted by thEsp View Post
In coding world "it works for me" isn't a good excuse. Remember that Pawn is handled server-side not client-side. It will not take care of your code itself, instead you have to make the way out yourself.

Anyway, make a 33 slots boolean array and respectively store "Air" value in it (per player).
Well, I figured that how (id) on client_putinserver works is that it graps "id" from player on server join and replaces it in functions. Is it just my mistake, I tried with more players and it worked.

How I see it is that I don't need 33 slot array, because he doesnt want that command to happen for everyone when player jumps?

Please tell me if I'm wrong.
supertrio17 is offline
thEsp
BANNED
Join Date: Aug 2017
Old 06-02-2020 , 10:12   Re: how to execute a function if player is in air?
Reply With Quote #4

I already told that you are wrong and why. Try having multiple players jump at different intervals and see what happens.
thEsp is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-02-2020 , 10:47   Re: how to execute a function if player is in air?
Reply With Quote #5

I can't say much without know what you're trying to do, but I guess you can do it by hooking Ham_Player_Jump.
__________________








CrazY. is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-02-2020 , 10:48   Re: how to execute a function if player is in air?
Reply With Quote #6

Quote:
Originally Posted by CrazY. View Post
I can't say much without know what you're trying to do, but I guess you can do it by hooking Ham_Player_Jump.
He is trying to execute command every time player is in air.
supertrio17 is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-02-2020 , 10:51   Re: how to execute a function if player is in air?
Reply With Quote #7

In this case, client_PreThink or set_task.
__________________








CrazY. is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-02-2020 , 12:27   Re: how to execute a function if player is in air?
Reply With Quote #8

I already did that, I posted code to.
supertrio17 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-02-2020 , 20:01   Re: how to execute a function if player is in air?
Reply With Quote #9

Not perfect but it may work for you. When transitioning from flat land to a slope you are technically in the for a split second and it will trigger the function. Also, if someone spams the jump button it may not always catch it.
PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

const GroundFlags = ( FL_ONGROUND FL_PARTIALGROUND FL_INWATER FL_CONVEYOR FL_FLOAT FL_FLY );

new 
g_CurrentFlagsMAX_PLAYERS ];

public 
plugin_init() 
{
    
RegisterHamHam_Spawn "player" "HamSpawn" true );
    
    
set_task0.1 "CheckPlayers" , .flags="b" );
}

PlayerInAirid )
{
    
client_printid print_chat "I am in the air" );
}

public 
HamSpawniPlayer )
{
    if ( 
is_user_aliveiPlayer ) )
    {
        
g_CurrentFlagsiPlayer ] &= ~GroundFlags ;
    }
}

public 
CheckPlayers()
{
    static 
iPlayers32 ] , iNum iPlayer iFlags;
    
    
get_playersiPlayers iNum "a" );
    
    for ( 
iNum i++ )
    {
        
iPlayer iPlayers];
        
        
iFlags peviPlayer pev_flags );
        
        if ( ( 
g_CurrentFlagsiPlayer ] & GroundFlags ) && !( iFlags GroundFlags ) )
        {
            
PlayerInAiriPlayer );    
        }
        
        
g_CurrentFlagsiPlayer ] = iFlags;
    }

__________________

Last edited by Bugsy; 06-02-2020 at 20:03.
Bugsy 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