Raised This Month: $ Target: $400
 0% 

Best way to detect if player is in air


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NucL3ra
Veteran Member
Join Date: Sep 2008
Location: Bucuresti , Romania
Old 06-20-2010 , 16:47   Best way to detect if player is in air
Reply With Quote #1

Which one of those is better (lower CPU usage)

1.
PHP Code:
new Float:velocity[3]
entity_get_vector(id,EV_VEC_velocity,velocity)

 if ( (
velocity[2]!=0) ) 
   
ColorChat(id ,GREEN"You are in air"
2.
PHP Code:
const FL_ONGROUND2 = ( FL_ONGROUND FL_PARTIALGROUND FL_INWATER |  FL_CONVEYOR FL_FLOAT );

if( !( 
pevidpev_flags ) & FL_ONGROUND2 
   
ColorChatidGREEN"You are in air"
1st uses engine modules
2nd uses amxmodx only, but it detects players on ladders as being in air
NucL3ra is offline
Send a message via Yahoo to NucL3ra
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 06-20-2010 , 16:52   Re: Best way to detect if player is in air
Reply With Quote #2

Then use the engine one if the second one is not getting the correct answer every time. It's extremely trivial.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
JaGareN
Senior Member
Join Date: Mar 2009
Old 06-20-2010 , 22:02   Re: Best way to detect if player is in air
Reply With Quote #3

I have a question...
Which of those tow are better (lower cpu) or faster?

Engine:
PHP Code:
new Float:velocity[3];
entity_get_vectoridEV_VEC_velocityvelocity ); 
Fakemeta:
PHP Code:
new Float:velocity[3];
pevidpev_velocityvelocity ); 

Last edited by JaGareN; 06-20-2010 at 22:13.
JaGareN is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 06-20-2010 , 22:54   Re: Best way to detect if player is in air
Reply With Quote #4

The difference is very small. You should just use whichever one you are more comfortable with.

Btw, in your second example, the pev native is from fakemeta and not amxmodx.

IIRC, when on a ladder you are given the flag FL_FLY, you can add it to the bitsum to get rid of your bug.

Additionally, your velocity check will return that they are on the ground at the max height of their jump.

Last edited by Emp`; 06-20-2010 at 22:57.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-21-2010 , 00:56   Re: Best way to detect if player is in air
Reply With Quote #5

Velocity check is also false if you run on a non-flat ground.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
grimvh2
Veteran Member
Join Date: Nov 2007
Location: Fishdot Nation
Old 06-21-2010 , 04:14   Re: Best way to detect if player is in air
Reply With Quote #6

Quote:
Originally Posted by ConnorMcLeod View Post
Velocity check is also false if you run on a non-flat ground.
surf parts also.
__________________
I am out of order!
grimvh2 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-21-2010 , 13:38   Re: Best way to detect if player is in air
Reply With Quote #7

Quote:
Originally Posted by grimvh2 View Post
surf parts also.
I guess he doesn't want to allow checkpoints on surf parts.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 06-21-2010 , 22:46   Re: Best way to detect if player is in air
Reply With Quote #8

Quote:
Originally Posted by Emp` View Post
The difference is very small. You should just use whichever one you are more comfortable with.
Floating point math is insanely expensive, especially compared to bit operations. The difference is not even close to being small. If you're referring to JaGareN's post, then nevermind.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 06-22-2010 , 02:23   Re: Best way to detect if player is in air
Reply With Quote #9

Quote:
Originally Posted by Hawk552 View Post
Floating point math is insanely expensive, especially compared to bit operations. The difference is not even close to being small. If you're referring to JaGareN's post, then nevermind.
I was.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
NucL3ra
Veteran Member
Join Date: Sep 2008
Location: Bucuresti , Romania
Old 09-16-2010 , 11:43   Re: Best way to detect if player is in air
Reply With Quote #10

Quote:
Originally Posted by Emp` View Post

IIRC, when on a ladder you are given the flag FL_FLY, you can add it to the bitsum to get rid of your bug.
I've just restarted working on this plugin and I saw the when adding FL_FLY into the const I still can't make a checkpoint on a ladder, isn't there other way?
NucL3ra is offline
Send a message via Yahoo to NucL3ra
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 14:42.


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