Best way to block cheat flying.
#1
Hey,

I want to make people unable to fly unless they have access to creative.
Now i created a piece of code for this.
But when i JUMP down it detects me as flying.
When i fall i don't have this problem.
Also when he does "hover". as i have to allow a range for jumping.
he can fly @ that height as long as he doesnt go up.
I want this to be fixed as well.

I use this piece of code
function OnPlayerMove( Player )
    local World = Player:GetWorld()
    local PlayerPos = Player:GetPosition()
    local Height = World:GetHeight( math.floor(PlayerPos.x), math.floor(PlayerPos.z) )
    
	if( (Player:GetPosY()-4) > Height and Player:GetGameMode() == 0 ) then
        if (playerHeight[Player:GetName()] < Player:GetPosY()) then
		Player:SendMessage( "You\'r not allowed to fly!." )
		Player:TeleportTo( Player:GetPosX(), Height+1, Player:GetPosZ() )
        end
	end
        playerHeight[Player:GetName()] = Player:GetPosY()
end

Is there a better way ?
This is the basic code later the player will be kicked when he tries to often.
Ofcourse when all is fixed.
Reply
Thanks given by:
#2
This piece of code won't work in underground caverns.

I don't think any of us want to tackle the problem of hacked clients who allow things normal MC doesn't - MCServer is full of holes thereTongue
Reply
Thanks given by:
#3
People that fly often fly long distances on the same altitude. Why not check if the altitude stays the same for a second while the player is not on the ground. I think there's a function in cPlayer that tells whether the player is on the ground
Reply
Thanks given by:
#4
Uhm, i guess xoft is right it wont work underground.
But there are other ways to check it i guess :p.
Checking if the block under the user is air or not.

Will rethink this and come up with a better plan.
Reply
Thanks given by:
#5
(10-25-2012, 12:21 AM)ThuGie Wrote: Uhm, i guess xoft is right it wont work underground.
But there are other ways to check it i guess :p.
Checking if the block under the user is air or not.

Will rethink this and come up with a better plan.

Did you consider my method?
Reply
Thanks given by:
#6
I did.
I mean if the attitude stays the same i would have to check if the person is on the ground even when in a cave.
I the way i do it at this moment is getting the highest tile.
Meaning it wont work underground.
So i asume i will have to check if the person is standing on a block or not.
Reply
Thanks given by:
#7
I think FakeTruth's method might not work for highly hacked clients - the IsOnGround bit is sent by the client and the server doesn't check it in any way, only stores that in the cPlayer object
If you want to be bullet-proof, you need to fully simulate the physics for each player, and compare the simulated and client positions; if they differ to much, make them reset (that's what causes the occasional jerks in the official server). Don't be too tough, though, because lag can do bad things to this kind of simulation.
Reply
Thanks given by:
#8
Then instead of checking the IsOnGround bit, do a trace from the player to the ground. If the player stays on the same altitude/height for a second and according to the trace the player is not on the ground, the player is flying. Simple as that.

Of course hacked clients can work around this by moving the player up/down slightly and such things, but there are clients that do such thing
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)