Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[EE 2.7] Anti-speed hack


Godlord
 Share

Recommended Posts

**Anti-speed hack**

**Introduction**
Hello, this is a code snippet for anti-speed hacks. The code modifications are entirely written by me, but aren't really tested yet, only basically.

This code is for EE 2.7 only as in, the code modifications should be on other locations when using TE or something similar.

This code modification allows a prevention for speed hacks. There are some things you might want to add though. The default speed is set to 100ms (Packet_PlayerMove), you can increase or decrease this. You might want to add some code to kick the player or something. You might want to modify the client so the packets are more likely send at the same speed as the interval, but this would usually fail.

**Code modifications**

**ModHandleData.base (Server)**:

Change:

> Public Sub Packet_PlayerMove(ByVal Index As Long, ByVal Dir As Long, ByVal Movement As Long)
>     If Player(Index).GettingMap = YES Then
>         Exit Sub
>     End If
>
>     If Dir < DIR_UP Or Dir > DIR_RIGHT Then
>         Call HackingAttempt(Index, "Invalid Direction")
>         Exit Sub
>     End If
>
>     If Movement <> 1 And Movement <> 2 Then
>         Call HackingAttempt(Index, "Invalid Movement")
>         Exit Sub
>     End If
>
>     If Player(Index).CastedSpell = YES Then
>         If GetTickCount > Player(Index).AttackTimer + 1000 Then
>             Player(Index).CastedSpell = NO
>         Else
>             Call SendPlayerXY(Index)
>             Exit Sub
>         End If
>     End If
>
>     If Player(Index).Locked = True Then
>         Call SendPlayerXY(Index)
>         Exit Sub
>     End If
>
>     Call PlayerMove(Index, Dir, Movement)
> End Sub

To:

> Public Sub Packet_PlayerMove(ByVal Index As Long, ByVal Dir As Long, ByVal Movement As Long)
>     If Player(Index).GettingMap = YES Then
>         Exit Sub
>     End If
>
>     If Dir < DIR_UP Or Dir > DIR_RIGHT Then
>         Call HackingAttempt(Index, "Invalid Direction")
>         Exit Sub
>     End If
>
>     If Movement <> 1 And Movement <> 2 Then
>         Call HackingAttempt(Index, "Invalid Movement")
>         Exit Sub
>     End If
>
>     If GetTickCount < Player(Index).MoveTimer + 100 Then
>         Exit Sub
>     End If
>
>     Player(Index).MoveTimer = GetTickCount
>
>     If Player(Index).CastedSpell = YES Then
>         If GetTickCount > Player(Index).AttackTimer + 1000 Then
>             Player(Index).CastedSpell = NO
>         Else
>             Call SendPlayerXY(Index)
>             Exit Sub
>         End If
>     End If
>
>     If Player(Index).Locked = True Then
>         Call SendPlayerXY(Index)
>         Exit Sub
>     End If
>
>     Call PlayerMove(Index, Dir, Movement)
> End Sub

**ModTypes.bas (Server)**:

Change:

> Public Type AccountRec
>     ' Account
>     Login As String * NAME_LENGTH
>     Password As String * NAME_LENGTH
>     Email As String
>
>     ' Some error here that needs to be fixed. [Mellowz]
>     Char(0 To MAX_CHARS) As PlayerRec
>
>     ' None saved local vars
>     Buffer As String
>     IncBuffer As String
>     CharNum As Byte
>     InGame As Boolean
>     AttackTimer As Long
>     DataTimer As Long
>     DataBytes As Long
>     DataPackets As Long
>
>     PartyPlayer As Long
>     InParty As Boolean
>     TargetType As Byte
>     Target As Byte
>     CastedSpell As Byte
>
>     SpellTime As Long
>     SpellVar As Long
>     SpellDone As Long
>     SpellNum As Long
>
>     PartyStarter As Byte
>     GettingMap As Byte
>     Party As PartyRec
>     InvitedBy As Byte
>
>     Emoticon As Long
>
>     InTrade As Boolean
>     TradePlayer As Long
>     TradeOk As Byte
>     TradeItemMax As Byte
>     TradeItemMax2 As Byte
>     Trading(1 To MAX_PLAYER_TRADES) As PlayerTradeRec
>
>     InChat As Byte
>     ChatPlayer As Long
>
>     Mute As Boolean
>     Locked As Boolean
>     LockedSpells As Boolean
>     LockedItems As Boolean
>     LockedAttack As Boolean
>     TargetNPC As Long
>
>     Pet As Long
>     HookShotX As Byte
>     HookShotY As Byte
>
>     ' MENUS
>     CustomMsg As String
>     CustomTitle As String
> End Type

To:

> Public Type AccountRec
>     ' Account
>     Login As String * NAME_LENGTH
>     Password As String * NAME_LENGTH
>     Email As String
>
>     ' Some error here that needs to be fixed. [Mellowz]
>     Char(0 To MAX_CHARS) As PlayerRec
>
>     ' None saved local vars
>     Buffer As String
>     IncBuffer As String
>     CharNum As Byte
>     InGame As Boolean
>     AttackTimer As Long
>     MoveTimer As Long
>     DataTimer As Long
>     DataBytes As Long
>     DataPackets As Long
>
>     PartyPlayer As Long
>     InParty As Boolean
>     TargetType As Byte
>     Target As Byte
>     CastedSpell As Byte
>
>     SpellTime As Long
>     SpellVar As Long
>     SpellDone As Long
>     SpellNum As Long
>
>     PartyStarter As Byte
>     GettingMap As Byte
>     Party As PartyRec
>     InvitedBy As Byte
>
>     Emoticon As Long
>
>     InTrade As Boolean
>     TradePlayer As Long
>     TradeOk As Byte
>     TradeItemMax As Byte
>     TradeItemMax2 As Byte
>     Trading(1 To MAX_PLAYER_TRADES) As PlayerTradeRec
>
>     InChat As Byte
>     ChatPlayer As Long
>
>     Mute As Boolean
>     Locked As Boolean
>     LockedSpells As Boolean
>     LockedItems As Boolean
>     LockedAttack As Boolean
>     TargetNPC As Long
>
>     Pet As Long
>     HookShotX As Byte
>     HookShotY As Byte
>
>     ' MENUS
>     CustomMsg As String
>     CustomTitle As String
> End Type

**modDatabase.bas (Server)**:

Change:

> Sub ClearPlayer(ByVal Index As Long)
>     Dim I As Long
>     Dim n As Long
>
>     Player(Index).Login = vbNullString
>     Player(Index).Password = vbNullString
>     For I = 1 To MAX_CHARS
>         Player(Index).Char(I).Name = vbNullString
>         Player(Index).Char(I).Class = 0
>         Player(Index).Char(I).LEVEL = 0
>         Player(Index).Char(I).Sprite = 0
>         Player(Index).Char(I).Exp = 0
>         Player(Index).Char(I).Access = 0
>         Player(Index).Char(I).PK = NO
>         Player(Index).Char(I).POINTS = 0
>         Player(Index).Char(I).Guild = vbNullString
>
>         Player(Index).Char(I).HP = 0
>         Player(Index).Char(I).MP = 0
>         Player(Index).Char(I).SP = 0
>
>         Player(Index).Char(I).MAXHP = 0
>         Player(Index).Char(I).MAXMP = 0
>         Player(Index).Char(I).MAXSP = 0
>
>         Player(Index).Char(I).STR = 0
>         Player(Index).Char(I).DEF = 0
>         Player(Index).Char(I).Speed = 0
>         Player(Index).Char(I).Magi = 0
>
>         For n = 1 To MAX_INV
>             Player(Index).Char(I).Inv(n).num = 0
>             Player(Index).Char(I).Inv(n).Value = 0
>             Player(Index).Char(I).Inv(n).Dur = 0
>         Next n
>         For n = 1 To MAX_BANK
>             Player(Index).Char(I).Bank(n).num = 0
>             Player(Index).Char(I).Bank(n).Value = 0
>             Player(Index).Char(I).Bank(n).Dur = 0
>         Next n
>         For n = 1 To MAX_PLAYER_SPELLS
>             Player(Index).Char(I).Spell(n) = 0
>         Next n
>
>         Player(Index).Char(I).ArmorSlot = 0
>         Player(Index).Char(I).WeaponSlot = 0
>         Player(Index).Char(I).HelmetSlot = 0
>         Player(Index).Char(I).ShieldSlot = 0
>         Player(Index).Char(I).LegsSlot = 0
>         Player(Index).Char(I).RingSlot = 0
>         Player(Index).Char(I).NecklaceSlot = 0
>
>         Player(Index).Char(I).Map = 0
>         Player(Index).Char(I).X = 0
>         Player(Index).Char(I).Y = 0
>         Player(Index).Char(I).Dir = 0
>
>         Player(Index).Locked = False
>         Player(Index).LockedSpells = False
>         Player(Index).LockedItems = False
>         Player(Index).LockedAttack = False
>
>         ' Temporary vars
>         Player(Index).Buffer = vbNullString
>         Player(Index).IncBuffer = vbNullString
>         Player(Index).CharNum = 0
>         Player(Index).InGame = False
>         Player(Index).AttackTimer = 0
>         Player(Index).DataTimer = 0
>         Player(Index).DataBytes = 0
>         Player(Index).DataPackets = 0
>         Player(Index).PartyPlayer = 0
>         Player(Index).InParty = False
>         Player(Index).Target = 0
>         Player(Index).TargetType = 0
>         Player(Index).CastedSpell = NO
>         Player(Index).PartyStarter = NO
>         Player(Index).GettingMap = NO
>         Player(Index).Emoticon = -1
>         Player(Index).InTrade = False
>         Player(Index).TradePlayer = 0
>         Player(Index).TradeOk = 0
>         Player(Index).TradeItemMax = 0
>         Player(Index).TradeItemMax2 = 0
>         For n = 1 To MAX_PLAYER_TRADES
>             Player(Index).Trading(n).InvName = vbNullString
>             Player(Index).Trading(n).InvNum = 0
>         Next n
>         Player(Index).ChatPlayer = 0
>     Next I
>
> End Sub

To:

> Sub ClearPlayer(ByVal Index As Long)
>     Dim I As Long
>     Dim n As Long
>
>     Player(Index).Login = vbNullString
>     Player(Index).Password = vbNullString
>     For I = 1 To MAX_CHARS
>         Player(Index).Char(I).Name = vbNullString
>         Player(Index).Char(I).Class = 0
>         Player(Index).Char(I).LEVEL = 0
>         Player(Index).Char(I).Sprite = 0
>         Player(Index).Char(I).Exp = 0
>         Player(Index).Char(I).Access = 0
>         Player(Index).Char(I).PK = NO
>         Player(Index).Char(I).POINTS = 0
>         Player(Index).Char(I).Guild = vbNullString
>
>         Player(Index).Char(I).HP = 0
>         Player(Index).Char(I).MP = 0
>         Player(Index).Char(I).SP = 0
>
>         Player(Index).Char(I).MAXHP = 0
>         Player(Index).Char(I).MAXMP = 0
>         Player(Index).Char(I).MAXSP = 0
>
>         Player(Index).Char(I).STR = 0
>         Player(Index).Char(I).DEF = 0
>         Player(Index).Char(I).Speed = 0
>         Player(Index).Char(I).Magi = 0
>
>         For n = 1 To MAX_INV
>             Player(Index).Char(I).Inv(n).num = 0
>             Player(Index).Char(I).Inv(n).Value = 0
>             Player(Index).Char(I).Inv(n).Dur = 0
>         Next n
>         For n = 1 To MAX_BANK
>             Player(Index).Char(I).Bank(n).num = 0
>             Player(Index).Char(I).Bank(n).Value = 0
>             Player(Index).Char(I).Bank(n).Dur = 0
>         Next n
>         For n = 1 To MAX_PLAYER_SPELLS
>             Player(Index).Char(I).Spell(n) = 0
>         Next n
>
>         Player(Index).Char(I).ArmorSlot = 0
>         Player(Index).Char(I).WeaponSlot = 0
>         Player(Index).Char(I).HelmetSlot = 0
>         Player(Index).Char(I).ShieldSlot = 0
>         Player(Index).Char(I).LegsSlot = 0
>         Player(Index).Char(I).RingSlot = 0
>         Player(Index).Char(I).NecklaceSlot = 0
>
>         Player(Index).Char(I).Map = 0
>         Player(Index).Char(I).X = 0
>         Player(Index).Char(I).Y = 0
>         Player(Index).Char(I).Dir = 0
>
>         Player(Index).Locked = False
>         Player(Index).LockedSpells = False
>         Player(Index).LockedItems = False
>         Player(Index).LockedAttack = False
>
>         ' Temporary vars
>         Player(Index).Buffer = vbNullString
>         Player(Index).IncBuffer = vbNullString
>         Player(Index).CharNum = 0
>         Player(Index).InGame = False
>         Player(Index).AttackTimer = 0
>         Player(Index).MoveTimer = 0
>         Player(Index).DataTimer = 0
>         Player(Index).DataBytes = 0
>         Player(Index).DataPackets = 0
>         Player(Index).PartyPlayer = 0
>         Player(Index).InParty = False
>         Player(Index).Target = 0
>         Player(Index).TargetType = 0
>         Player(Index).CastedSpell = NO
>         Player(Index).PartyStarter = NO
>         Player(Index).GettingMap = NO
>         Player(Index).Emoticon = -1
>         Player(Index).InTrade = False
>         Player(Index).TradePlayer = 0
>         Player(Index).TradeOk = 0
>         Player(Index).TradeItemMax = 0
>         Player(Index).TradeItemMax2 = 0
>         For n = 1 To MAX_PLAYER_TRADES
>             Player(Index).Trading(n).InvName = vbNullString
>             Player(Index).Trading(n).InvNum = 0
>         Next n
>         Player(Index).ChatPlayer = 0
>     Next I
> End Sub
Link to comment
Share on other sites

@The:

> well, it says in the first post that it hasn't been tested.

Well the code hasn't been tested by using some "cheating" application as I do not own such thing nor do I want to download one just for testing it at the moment. But it works though. It's mainly implemented like in the World of Glory server, so it's supposed to work. You can mainly see that I didn't test it with some "cheating" application because I used 100ms which isn't exact enough.

Regards,
  Godlord.
Link to comment
Share on other sites

Its good, but it work only for playermove:)
And its hard to set ms limit, because on faster computers players in eclipse engines moves faster than on slow computers.

@Tyr:

> lol i didn't even thought bout a speed hack for eclipse ^^
> quite handy tho. thx!

o_O Speedhack in eclipse its pain, you will see it when your game will be released. I banned alot speedhack in AO, but i have other system to catch them.
Link to comment
Share on other sites

@pheXion:

> And lag everyone with fast computer ;f

No, clearly seems that you don't know how time-based movement works.

Pseudocode of frame-independent or time-based movement:

> int DrawFrame() {
>     iDelay = GetTickCount() - iLastFrame;
>
>     fDelta = (float)(iDelay) * 0.001;
>
>     // Other stuff…
>
>     // Moving forward.
>     objPlayer.iX += 50 /* amount of pixels to walk per frame */ * fDelta;
>     objPlayer.iY += 50 /* amount of pixels to walk per frame */ * fDelta;
>
>     // Other stuff...
>
>     // Draw player @ x/y
>     // Draw game world and such.
>
>     SwapBuffers();
>
>     iLastFrame = GetTickCount();
>
>     // Calculate other things, perhaps the FPS.
> }

If you have 20FPS or 2000FPS, you'll walk at the same speed.

Regards,
  Godlord.
Link to comment
Share on other sites

  • 1 month later...
@•RЧĐIИØPHØR•:

> no offense but i'm going to regret putting this in my game, i walk so slow wen i'm admin but when i'm on local host i can run :S.

Even when you change the microseconds? If you try a way bigger value and it still is slow, then it might just be Eclipse.

Regards,
  Godlord.
Link to comment
Share on other sites

  • 1 month later...
Its no too good. It causing lags because timing of packet are different. So people have wrong coordinates in your client on the maps. You can incrase ms value but this will be no antispeedhack then.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...