Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Security] Stop Speedhacking Once and For all
#1
Ok so I am just going to port over the code I used for firecaster (the closed beta version of which has lagless and completely secure movement). Hopefully you all can follow along with what I am doing.

All of this should be serverside (hopefully)

First add these values to tempplayerrec
Code:
MovesLeft As Byte
    MovesRight As Byte
    MovesUp As Byte
    MovesDown As Byte
    CanMoveWhen As Long
They will come into use later, but you might as well do them all at once.

At the bottom of modServerLoop add
Code:
Private Sub UpdatePlayerMovement()
Dim i As Integer
    For i = 1 To High_Index
        With TempPlayer(i)
            If .CanMoveWhen  0 Then
                .CanMoveWhen = .CanMoveWhen - 1
                If .CanMoveWhen = 0 Then
                    If .MovesDown > 0 Then
                        Call PlayerMove(i, DIR_DOWN, MOVING_RUNNING)
                        .MovesDown = .MovesDown - 1
                    ElseIf .MovesUp > 0 Then
                        Call PlayerMove(i, DIR_UP, MOVING_RUNNING)
                        .MovesUp = .MovesUp - 1
                    ElseIf .MovesLeft > 0 Then
                        Call PlayerMove(i, DIR_LEFT, MOVING_RUNNING)
                        .MovesLeft = .MovesLeft - 1
                    ElseIf .MovesRight > 0 Then
                        Call PlayerMove(i, DIR_RIGHT, MOVING_RUNNING)
                        .MovesRight = .MovesRight - 1
                    End If
                End If
            End If
        End With
    Next i
End Sub

In sub ServerLoop under
Code:
Dim LastUpdatePlayerVitals As Long
add
Code:
Dim LastUpdatePlayerMovement As Long

under
Code:
' Checks to save players every 10 minutes - Can be tweaked
        If Tick > LastUpdateSavePlayers Then
            UpdateSavePlayers
            LastUpdateSavePlayers = GetTickCount + 600000
        End If
Put
Code:
If Tick > LastUpdatePlayerMovement Then
            UpdatePlayerMovement
            LastUpdatePlayerMovement = GetTickCount + 30
        End If

The 30 value corresponds to the walktimer section of the client. If you don't know what that is, then do not change the 30.

Now in sub PlayerMove
under
Code:
' Check for subscript out of range
    If IsPlaying(Index) = False Or Dir < DIR_UP Or Dir > DIR_RIGHT Or Movement < 1 Or Movement > 2 Then
        Exit Sub
    End If
put
Code:
If TempPlayer(Index).CanMoveWhen > 0 Then
        If Dir = DIR_RIGHT Then TempPlayer(Index).MovesRight = TempPlayer(Index).MovesRight + 1
        If Dir = DIR_DOWN Then TempPlayer(Index).MovesDown = TempPlayer(Index).MovesDown + 1
        If Dir = DIR_LEFT Then TempPlayer(Index).MovesLeft = TempPlayer(Index).MovesLeft + 1
        If Dir = DIR_UP Then TempPlayer(Index).MovesUp = TempPlayer(Index).MovesUp + 1
        Exit Sub
    End If
    'lets set their movement timer
    TempPlayer(Index).CanMoveWhen = 4
The 4 is gotten by dividing the tile size, 32, by the runspeed (we use run speed to give players the benefit of the doubt) which by default is 8
32/8=4

This code is currently being tested, but if you can find bugs before I do that would be greatly appreciated.

Ok put this last fix and it should be good
find
Code:
Call HackingAttempt(Index, "Position Modification")
replace it with
Code:
Call SendPlayerXY(Index)
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)