Mirage Source

Free ORPG making software.
It is currently Thu Apr 25, 2024 4:59 pm

All times are UTC


Forum rules


Make sure your tutorials are kept up to date with the latest MS4 releases.



Post new topic Reply to topic  [ 1477 posts ]  Go to page 1, 2, 3, 4, 5 ... 60  Next
Author Message
 Post subject: Stop Speed Hacks
PostPosted: Wed Dec 03, 2008 4:29 pm 
Offline
Pro
User avatar

Joined: Sun Aug 05, 2007 2:26 pm
Posts: 547
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

_________________
GIAKEN wrote:
I think what I see is this happening:

Labmonkey gets mod, everybody loves him, people find out his code sucks, he gets demoted, then banned, then he makes an engine called Chaos Engine.


Top
 Profile  
 
 Post subject: Re: Stop Speed Hacks
PostPosted: Wed Dec 03, 2008 4:34 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
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.

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Top
 Profile  
 
 Post subject: Re: Stop Speed Hacks
PostPosted: Wed Dec 03, 2008 9:43 pm 
Offline
Knowledgeable
User avatar

Joined: Fri Feb 02, 2007 4:50 am
Posts: 263
Location: usa michigan centriville
i like it i can't complain looks good ^^

_________________
Fuck? I really joined in 2006.
Spirea, Chat Rooms, Discussions, Help. everything you need in one spot.
http://spirean.com
I love my computer, you never ask for more, you can be my princess or be my whore


Top
 Profile  
 
 Post subject: Re: Stop Speed Hacks
PostPosted: Wed Dec 01, 2021 8:20 am 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 486996
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинйоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоsemiasphalticflux.ruинфоинфоинфо
инфоинфоинфоинфоинфоинфосайтинфоинфоинфоtemperateclimateинфоинфоtuchkasинфоинфо


Top
 Profile  
 
 Post subject: Re: Stop Speed Hacks
PostPosted: Fri Dec 31, 2021 3:43 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 486996
Aaro


Top
 Profile  
 
 Post subject: Re: Stop Speed Hacks
PostPosted: Fri Dec 31, 2021 3:44 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 486996
69.9


Top
 Profile  
 
 Post subject: Re: Stop Speed Hacks
PostPosted: Fri Dec 31, 2021 3:45 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 486996
MONT


Top
 Profile  
 
 Post subject: Re: Stop Speed Hacks
PostPosted: Fri Dec 31, 2021 3:46 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 486996
MONT


Top
 Profile  
 
 Post subject: Re: Stop Speed Hacks
PostPosted: Fri Dec 31, 2021 3:47 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 486996
Hami


Top
 Profile  
 
 Post subject: Re: Stop Speed Hacks
PostPosted: Fri Dec 31, 2021 3:48 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 486996
Pros


Top
 Profile  
 
 Post subject: Re: Stop Speed Hacks
PostPosted: Fri Dec 31, 2021 3:49 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 486996
Bass


Top
 Profile  
 
 Post subject: Re: Stop Speed Hacks
PostPosted: Fri Dec 31, 2021 3:51 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 486996
Step


Top
 Profile  
 
 Post subject: Re: Stop Speed Hacks
PostPosted: Fri Dec 31, 2021 3:52 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 486996
Warr


Top
 Profile  
 
 Post subject: Re: Stop Speed Hacks
PostPosted: Fri Dec 31, 2021 3:53 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 486996
Most


Top
 Profile  
 
 Post subject: Re: Stop Speed Hacks
PostPosted: Fri Dec 31, 2021 3:54 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 486996
LEGO


Top
 Profile  
 
 Post subject: Re: Stop Speed Hacks
PostPosted: Fri Dec 31, 2021 3:55 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 486996
Meta


Top
 Profile  
 
 Post subject: Re: Stop Speed Hacks
PostPosted: Fri Dec 31, 2021 3:56 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 486996
Tesc


Top
 Profile  
 
 Post subject: Re: Stop Speed Hacks
PostPosted: Fri Dec 31, 2021 3:57 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 486996
wwwn


Top
 Profile  
 
 Post subject: Re: Stop Speed Hacks
PostPosted: Fri Dec 31, 2021 3:58 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 486996
Fisk


Top
 Profile  
 
 Post subject: Re: Stop Speed Hacks
PostPosted: Fri Dec 31, 2021 3:59 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 486996
Kong


Top
 Profile  
 
 Post subject: Re: Stop Speed Hacks
PostPosted: Fri Dec 31, 2021 4:01 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 486996
Wayn


Top
 Profile  
 
 Post subject: Re: Stop Speed Hacks
PostPosted: Fri Dec 31, 2021 4:02 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 486996
Dorm


Top
 Profile  
 
 Post subject: Re: Stop Speed Hacks
PostPosted: Fri Dec 31, 2021 4:03 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 486996
Dani


Top
 Profile  
 
 Post subject: Re: Stop Speed Hacks
PostPosted: Fri Dec 31, 2021 4:04 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 486996
Flig


Top
 Profile  
 
 Post subject: Re: Stop Speed Hacks
PostPosted: Fri Dec 31, 2021 4:05 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 486996
Selm


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1477 posts ]  Go to page 1, 2, 3, 4, 5 ... 60  Next

All times are UTC


Who is online

Users browsing this forum: wanai and 22 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group