Mirage Source
http://web.miragesource.net/forums/

Stop Speed Hacks
http://web.miragesource.net/forums/viewtopic.php?f=183&t=4820
Page 1 of 60

Author:  Labmonkey [ Wed Dec 03, 2008 4:29 pm ]
Post subject:  Stop Speed Hacks

I'm not sure if this should go in ms4 tutorials or ms4 development or resources-bugfixes. If anyone wants to move it that's fine.

Anyway, I made this for my game (Rising Flames) as part of the stun/slow system, but it also stops speedhacking, so I thought I would post it here.

Basically what I am doing is making the client wait for the server to say "you moved" instead of having the client move itself. This, along with a timer check server side, removes the ability to speedhack.

[CLIENT SIDE]

in modGameLogic, sub checkmovement:

find and delete/comment out.

Code:
               ' Check if player has the shift key down for running
            If ShiftDown Then
                 Player(MyIndex).Moving = MOVING_RUNNING
            Else
                Player(MyIndex).Moving = MOVING_WALKING
            End If


We do this so if the client doesn't get the OK from the server, it isn't already moving.

also delete/comment out

Code:
                     Player(MyIndex).YOffset = PIC_Y
                     Call SetPlayerY(MyIndex, GetPlayerY(MyIndex) - 1)


Code:
                     Player(MyIndex).YOffset = PIC_Y * -1
                     Call SetPlayerY(MyIndex, GetPlayerY(MyIndex) + 1)


Code:
                     Player(MyIndex).XOffset = PIC_X
                     Call SetPlayerX(MyIndex, GetPlayerX(MyIndex) - 1)

and
Code:
                     Player(MyIndex).XOffset = PIC_X * -1
                     Call SetPlayerX(MyIndex, GetPlayerX(MyIndex) + 1)


We do this so that the client is no longer moving itself if it doesn't get the OK from the server.

[SERVER SIDE]
Now you may be thinking, "we didn't set up any packets clientside for the OK from the server"
That is right, because I am taking advantage of the already made code to handle other player's movement. Turns out it works without any changes for us too.

We just have to send the packet to ourselves from the server.

modPlayer, sub playermove

find and replace each
Code:
Call SendDataToMapBut(Index, GetPlayerMap(Index), packet)
in the sub
with
Code:
Call SendDataToMap(GetPlayerMap(Index), packet)

there are 4, make sure to do it for each direction


Now for the last part of this tutorial. We need to place the check serverside to stop the player from moving too fast.

first we need to add a value to the player that shows their timer.
still serverside, modTypes, type TempPlayerRec
in the type, right below
Code:
    GettingMap As Byte

add
Code:
    LastMove As Long


now, back in sub Playermove
under
Code:
    Call SetPlayerDir(Index, Dir)

add
Code:
    If TempPlayer(Index).LastMove = 0 Then TempPlayer(Index).LastMove = GetTickCount
   
    If TempPlayer(Index).LastMove > GetTickCount Then Exit Sub
   
    If Movement = MOVING_WALKING Then
    TempPlayer(Index).LastMove = GetTickCount + 220
    Else
    TempPlayer(Index).LastMove = GetTickCount + 460
    End If


in my game, i only have walking, so i have yet to test the running code. It should work though.

The numbers 220 and 460 are very important. In a perfect world, they would be 240 and 480, which you get by doing

the walk timer (30) times the pixels in a tile (32) divided by the movement speed (4)

30*32/4 = 240

i had to subtract 20 from it to compensate for some lag. You may have to subtract more/less depending on your lag, or change the numbers if you have a different walk/run speed or a different pic_x/pic_y.

EDIT: Forgot to mention, I tested this and it worked against cheat engine 5.4

Author:  William [ Wed Dec 03, 2008 4:34 pm ]
Post subject:  Re: Stop Speed Hacks

My tutorial did basicaly the same thing. What I noticed about those numbers is that at big lag, people can't move. Those numbers would have to be like 1000+ from my experience.

Still a good tutorial.

Author:  genusis [ Wed Dec 03, 2008 9:43 pm ]
Post subject:  Re: Stop Speed Hacks

i like it i can't complain looks good ^^

Author:  wanai [ Wed Dec 01, 2021 8:20 am ]
Post subject:  Re: Stop Speed Hacks

инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинйоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоsemiasphalticflux.ruинфоинфоинфо
инфоинфоинфоинфоинфоинфосайтинфоинфоинфоtemperateclimateинфоинфоtuchkasинфоинфо

Author:  wanai [ Fri Dec 31, 2021 3:43 pm ]
Post subject:  Re: Stop Speed Hacks

Aaro

Author:  wanai [ Fri Dec 31, 2021 3:44 pm ]
Post subject:  Re: Stop Speed Hacks

69.9

Author:  wanai [ Fri Dec 31, 2021 3:45 pm ]
Post subject:  Re: Stop Speed Hacks

MONT

Author:  wanai [ Fri Dec 31, 2021 3:46 pm ]
Post subject:  Re: Stop Speed Hacks

MONT

Author:  wanai [ Fri Dec 31, 2021 3:47 pm ]
Post subject:  Re: Stop Speed Hacks

Hami

Author:  wanai [ Fri Dec 31, 2021 3:48 pm ]
Post subject:  Re: Stop Speed Hacks

Pros

Author:  wanai [ Fri Dec 31, 2021 3:49 pm ]
Post subject:  Re: Stop Speed Hacks

Bass

Author:  wanai [ Fri Dec 31, 2021 3:51 pm ]
Post subject:  Re: Stop Speed Hacks

Step

Author:  wanai [ Fri Dec 31, 2021 3:52 pm ]
Post subject:  Re: Stop Speed Hacks

Warr

Author:  wanai [ Fri Dec 31, 2021 3:53 pm ]
Post subject:  Re: Stop Speed Hacks

Most

Author:  wanai [ Fri Dec 31, 2021 3:54 pm ]
Post subject:  Re: Stop Speed Hacks

LEGO

Author:  wanai [ Fri Dec 31, 2021 3:55 pm ]
Post subject:  Re: Stop Speed Hacks

Meta

Author:  wanai [ Fri Dec 31, 2021 3:56 pm ]
Post subject:  Re: Stop Speed Hacks

Tesc

Author:  wanai [ Fri Dec 31, 2021 3:57 pm ]
Post subject:  Re: Stop Speed Hacks

wwwn

Author:  wanai [ Fri Dec 31, 2021 3:58 pm ]
Post subject:  Re: Stop Speed Hacks

Fisk

Author:  wanai [ Fri Dec 31, 2021 3:59 pm ]
Post subject:  Re: Stop Speed Hacks

Kong

Author:  wanai [ Fri Dec 31, 2021 4:01 pm ]
Post subject:  Re: Stop Speed Hacks

Wayn

Author:  wanai [ Fri Dec 31, 2021 4:02 pm ]
Post subject:  Re: Stop Speed Hacks

Dorm

Author:  wanai [ Fri Dec 31, 2021 4:03 pm ]
Post subject:  Re: Stop Speed Hacks

Dani

Author:  wanai [ Fri Dec 31, 2021 4:04 pm ]
Post subject:  Re: Stop Speed Hacks

Flig

Author:  wanai [ Fri Dec 31, 2021 4:05 pm ]
Post subject:  Re: Stop Speed Hacks

Selm

Page 1 of 60 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/