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

Timer ListBox


balliztik1
 Share

Recommended Posts

I wanted to make something on the server that would allow me to see what timers were running, and allow me to remove and add them from outside the client, so I made a ListBox within the server that allows me to do that.

Here's how I have it set up.

![](http://www.freemmorpgmaker.com/Hosting/balliztik/frmserver.GIF)

I added a new tab to the server. Change the _Tabs_ and _TabsPerRow_ properties of _frmServer_ to 5 each, and you can change the caption of the new tab to suit you (I used "Timers").

Now, on this new tab, add the _ListBox_, two _TextBox_es, and the _Command Button_ shown above, making sure you use the names provided.

View the code of _frmServer_ and add these subs in.

```
Private Sub cmdTimerAdd_Click()
Call AddNewTimer(txtTmrName.text, Int(txtTmrInt.text))
End Sub

Private Sub lstTimers_DblClick()
    Call GetRidOfTimer(lstTimers.List(lstTimers.ListIndex))
    lstTimers.RemoveItem lstTimers.ListIndex
End Sub

Private Sub txtTmrInt_Click()
If txtTmrInt.text = "Interval" Then
txtTmrInt.text = ""
End If
End Sub

Private Sub txtTmrName_Click()
If txtTmrName.text = "Timer Name" Then
txtTmrName.text = ""
End If
End Sub
```
Finally, open up _modGameLogic_ and find the subs _AddNewTimer_ and _GetRidOfTimer_. Replace them with these modified subs.

```
Sub AddNewTimer(ByVal Name As String, ByVal Interval As Long)
On Error Resume Next
  Dim TmpTimer As clsCTimers
  Set TmpTimer = New clsCTimers
  TmpTimer.Name = Name
  TmpTimer.Interval = Interval
  TmpTimer.tmrWait = GetTickCount + Interval
  CTimers.add TmpTimer, Name
  frmServer.lstTimers.AddItem Name
  If Err.number > 0 Then
    Debug.Print "Err: " & Err.number
    CTimers.item(Name).Name = Name
    CTimers.item(Name).Interval = Interval
    CTimers.item(Name).tmrWait = GetTickCount + Interval
    Err.Clear
  End If
End Sub

Sub GetRidOfTimer(ByVal Name As String)
    Call CTimers.Remove(Name)
End Sub
```
And there you have it. When you run a timer, it will show up on the list now. Double clicking the timer name will remove the timer (I added this just in case a timer is being troublesome), and you can add a timer yourself by filling in the two fields and clicking the Add Timer button.

Enjoy.  :-)
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...