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

Check if player in air


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
keygens
Senior Member
Join Date: Mar 2010
Location: Somewhere
Old 11-13-2014 , 12:43   Check if player in air
Reply With Quote #1

Hello. I have small question, about how i can check player if he in air right now.
I know about code like this for it:
Code:
(!(GetEntityFlags(client) & FL_ONGROUND))
But, how we can check it by other way/other code? Thanks in advance

Last edited by keygens; 11-14-2014 at 11:03.
keygens is offline
Ibanezez
SourceMod Donor
Join Date: Aug 2014
Location: Earth
Old 11-13-2014 , 13:28   Re: Check if player in air
Reply With Quote #2

Not sure if this is what you're looking for, but there's this:
https://forums.alliedmods.net/showthread.php?t=151142

Basically it would look like this in a script:
PHP Code:
#include <sourcemod>
#include <sdktools>
#define MAX_BUTTONS 26
new g_LastButtons[MAXPLAYERS+1];

public 
OnClientDisconnect_Post(client)
{
    
g_LastButtons[client] = 0;
}

public 
Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)
{
    for (new 
0MAX_BUTTONSi++)
    {
        new 
button = (<< i);
        
        if ((
buttons button))
        {
            if (!(
g_LastButtons[client] & button))
            {
                
OnButtonPress(clientbutton);
            }
        }
        else if ((
g_LastButtons[client] & button))
        {
            
OnButtonRelease(clientbutton);
        }
    }
    
    
g_LastButtons[client] = buttons;
    
    return 
Plugin_Continue;
}

OnButtonPress(clientbutton)
{
    if (
button == IN_JUMP//Insert some code here
}

OnButtonRelease(clientbutton)
{
    if (
button == IN_JUMP//Insert some code here

Put the code into if(button == IN_JUMP) on OnButtonpress and OnButtonRelease.

(OnButtonPress is while in the air, OnButtonRelease is when they hit the ground again, I think)

Not sure if that's what you were looking for, but I hope I helped.
__________________
Hello
Ibanezez is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 11-13-2014 , 14:09   Re: Check if player in air
Reply With Quote #3

Use entity flags
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
The1Speck
SourceMod Donor
Join Date: Oct 2014
Location: USA
Old 11-13-2014 , 17:23   Re: Check if player in air
Reply With Quote #4

Another option would be to use trace-rays. Angle it downwards from the player and calculate the distance from the player and the ground.
__________________

Add me on Steam for personal inquiries or direct assistance.
The1Speck is offline
keygens
Senior Member
Join Date: Mar 2010
Location: Somewhere
Old 11-14-2014 , 02:56   Re: Check if player in air
Reply With Quote #5

Quote:
Originally Posted by The1Speck View Post
Another option would be to use trace-rays. Angle it downwards from the player and calculate the distance from the player and the ground.
Can you give me example of it?
keygens is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 11-14-2014 , 03:03   Re: Check if player in air
Reply With Quote #6

What is the problem with the method that you mentioned in the first post?
__________________
ddhoward is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 11-14-2014 , 03:15   Re: Check if player in air
Reply With Quote #7

See the code in red here https://forums.alliedmods.net/showpo...1&postcount=44
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.

Franc1sco is offline
Send a message via MSN to Franc1sco
thecount
Veteran Member
Join Date: Jul 2013
Old 11-14-2014 , 20:32   Re: Check if player in air
Reply With Quote #8

Quote:
Originally Posted by friagram View Post
Use entity flags
^
thecount is offline
keygens
Senior Member
Join Date: Mar 2010
Location: Somewhere
Old 11-15-2014 , 03:50   Re: Check if player in air
Reply With Quote #9

Quote:
Originally Posted by thecount View Post
^
Entity flags? m_fFlags? Or what?
keygens is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 11-15-2014 , 03:55   Re: Check if player in air
Reply With Quote #10

I would assume something like this:

PHP Code:
if (!(GetEntityFlags(client) & FL_ONGROUND)) {
    
//client is not on the ground

__________________
ddhoward 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 21:29.


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