Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[FEATURE] Lock Movement on Tab
#1
Alright, so this is a pretty simple feature. It's basically like a Caps Lock, except instead of Caps, you run Tongue

Difficulty : 1 / 5

ModGlobals

In modGlobals, look for

Code:
' Game direction vars

And in that little section, add :
Code:
Public IsUserTabbed As Boolean
.

In modConstants, look for :
Code:
Public Const VK_CONTROL As Long = &H11

And under it add :
Code:
Public Const VK_TAB as long = &H9

Now, in modGameLogic, look for sub GameLoop. Add the following variable at the top, inside that sub :

Code:
Dim TabTimer as long

and then look for the following snippet :

Code:
If GetAsyncKeyState(VK_CONTROL) >= 0 Then
            If ControlDown = True Then
            ControlDown = False
            End If
        End If

and add this under :

Code:
If GetAsyncKeyState(VK_TAB)  0 Then
            If TabTimer + 1000 < GetTickCount Then
                IsUserTabbed = Not IsUserTabbed
                TabTimer = GetTickCount
            End If
        End If

Now, what this code does is, each time you press tab, it will turn the IsUserTabbed boolean on and off, so you just have to press it once and it'll turn on Smile. The reason for the TabTimer is because, with that function, it is processed very quickly, and if you hold tab it will mess up. You cannot do this with the CheckInput sub because the Tab key code is basically 'removed' by VB6 since you use tab to go through controls.

Now, in modGameLogic, look for sub CheckMovement. Now, look at the part that says :

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

And replace it with :

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

This will check whether you are pressing shift or you pressed tab to turn on the Auto-Run Smile And there you go, wasn't that simple? Big Grin
Reply
#2
Didn't work for me. I press tab, but it doesn't do anything. Maybe I did the tut wrong.
Reply
#3
Sorry about that, updated it now Big Grin
Reply
#4
Works now. Awesome job dude.
Reply
#5
I added this feature into my client good job.
Reply
#6
Dude nice. Big Grin This will save people like me who suffer from carpal tunnel. Lets us not hold a key down all day when it already hurts to type a lot.
Reply
#7
Kind of an off/on-topic note:

Code:
Public Const VK_CONTROL As Long = &H11

how do you get the &H11? Just make it up?
Reply
#8
I found this snippet of code awhile ago:

Code:
' Used so we can actually use the tab key ingame
    For i = 0 To Controls.Count - 1
       Controls(i).TabStop = False
       ' Has to be used for controls that don't have tabstop
       On Error Resume Next
    Next

This will allow you use tabkey without any problems. It would get added Form_Load().
Reply
#9
Mattyw Wrote:Kind of an off/on-topic note:

Code:
Public Const VK_CONTROL As Long = &H11

how do you get the &H11? Just make it up?

Nah, &H11 is the hexadecimal value for that Key Wink

Dugor Wrote:I found this snippet of code awhile ago:

Code:
' Used so we can actually use the tab key ingame
    For i = 0 To Controls.Count - 1
       Controls(i).TabStop = False
       ' Has to be used for controls that don't have tabstop
       On Error Resume Next
    Next

This will allow you use tabkey without any problems. It would get added Form_Load().

Ah nice, I modify it to use that Smile Thanks mate =]
Reply
#10
JokeofWeek Wrote:
Mattyw Wrote:Kind of an off/on-topic note:

Code:
Public Const VK_CONTROL As Long = &H11

how do you get the &H11? Just make it up?

Nah, &H11 is the hexadecimal value for that Key Wink

Dugor Wrote:I found this snippet of code awhile ago:

Code:
' Used so we can actually use the tab key ingame
    For i = 0 To Controls.Count - 1
       Controls(i).TabStop = False
       ' Has to be used for controls that don't have tabstop
       On Error Resume Next
    Next

This will allow you use tabkey without any problems. It would get added Form_Load().

Ah nice, I modify it to use that Smile Thanks mate =]

So how do I find the Hex value of keys. :S
Reply
#11
Google them.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)