PDA

View Full Version : Best way to detect if player is in air


NucL3ra
06-20-2010, 16:47
Which one of those is better (lower CPU usage)

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

if ( (velocity[2]!=0) )
ColorChat(id ,GREEN, "You are in air")
2.

const FL_ONGROUND2 = ( FL_ONGROUND | FL_PARTIALGROUND | FL_INWATER | FL_CONVEYOR | FL_FLOAT );

if( !( pev( id, pev_flags ) & FL_ONGROUND2 )
ColorChat( id, GREEN, "You are in air")
1st uses engine modules
2nd uses amxmodx only, but it detects players on ladders as being in air

wrecked_
06-20-2010, 16:52
Then use the engine one if the second one is not getting the correct answer every time. It's extremely trivial.

JaGareN
06-20-2010, 22:02
I have a question...
Which of those tow are better (lower cpu) or faster?

Engine:

new Float:velocity[3];
entity_get_vector( id, EV_VEC_velocity, velocity );

Fakemeta:

new Float:velocity[3];
pev( id, pev_velocity, velocity );

Emp`
06-20-2010, 22:54
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.

ConnorMcLeod
06-21-2010, 00:56
Velocity check is also false if you run on a non-flat ground.

grimvh2
06-21-2010, 04:14
Velocity check is also false if you run on a non-flat ground.

surf parts also.

ConnorMcLeod
06-21-2010, 13:38
surf parts also.

I guess he doesn't want to allow checkpoints on surf parts.

NucL3ra
06-21-2010, 17:09
Ok so i will remain with the first one.

And ehh, I didn't know pev native is from fakemeta

Hawk552
06-21-2010, 22:46
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.

ConnorMcLeod
06-22-2010, 00:53
Ok so i will remain with the first one.

And ehh, I didn't know pev native is from fakemeta

oO, use the 2nd one and read post #4

Emp`
06-22-2010, 02:23
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.

NucL3ra
09-16-2010, 11:43
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?