09-05-2008, 08:02 PM
This tutorial adds a form for your /mapreport command. This form allows you to view a list of your maps, warp to them, and edit them.
Client Side
Start by adding a new form, called frmMapReport. To this form, add the following:
3 command buttons: cmdGoTo, cmdEdit, cmdCancel
1 list box: lstMaps
1 text box: txtMap
1 scroll bar: scrlMapNum
Now add this code to frmMapReport:
Now add this to Sub HandleData:
Add this anywhere (I put it in modGameLogic along with the other editor inits):
Server Side
In Sub HandleData, find the Map Report Packet, and paste this at the bottom, but before the exit sub:
And add this somewhere in modServerTCP:
And lastley, right under this Map Report Packet, paste this packet:
Been a while since I added this to my game, so I'm not sure if I including everything that needs to be there. Let me know if it doesn't work, and I'll update the tutorial.
Client Side
Start by adding a new form, called frmMapReport. To this form, add the following:
3 command buttons: cmdGoTo, cmdEdit, cmdCancel
1 list box: lstMaps
1 text box: txtMap
1 scroll bar: scrlMapNum
Now add this code to frmMapReport:
Code:
Private Sub Form_Load()
Dim Packet As String
Packet = "REQUESTMAPLIST" & SEP_CHAR & END_CHAR
Call SendData(Packet)
End Sub
Private Sub lstMaps_Click()
txtMap.Text = lstMaps.ListIndex + 1
End Sub
Private Sub scrlMapNum_Change()
txtMap.Text = scrlMapNum.Value
End Sub
Private Sub cmdGoTo_Click()
If txtMap.Text > 0 Then
lstMaps.ListIndex = txtMap.Text - 1
scrlMapNum.Value = txtMap.Text
Call WarpTo(scrlMapNum.Value)
End If
End Sub
Private Sub cmdEdit_Click()
Call SendRequestEditMap
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Now add this to Sub HandleData:
Code:
' ::::::::::::::::::
' :: Get Map List ::
' ::::::::::::::::::
If LCase(Parse(0)) = "maplist" Then
frmMapReport.lstMaps.Clear
n = 2
z = Val(Parse(1))
For X = n To (z + 1)
If Trim(Parse(n)) vbNullString Then
frmMapReport.lstMaps.AddItem "Map # " & (X - 1) & ": " & Trim(Parse(n))
Else
frmMapReport.lstMaps.AddItem "Map # " & (X - 1) & ": Free Map"
End If
n = n + 2
Next X
Exit Sub
End If
' :::::::::::::::::::::
' :: Edit map packet ::
' :::::::::::::::::::::
If (LCase(Parse(0)) = "mapreport") Then
Call MapReportInit
Exit Sub
End If
Add this anywhere (I put it in modGameLogic along with the other editor inits):
Code:
Public Sub MapReportInit()
frmMapReport.Show
End Sub
Server Side
In Sub HandleData, find the Map Report Packet, and paste this at the bottom, but before the exit sub:
Code:
Call SendDataTo(Index, "MAPREPORT" & SEP_CHAR & END_CHAR)
And add this somewhere in modServerTCP:
Code:
Sub SendMapList(ByVal Index As Long)
Dim Packet As String
Dim I As Long
Dim n As Long
Packet = ""
n = 0
For I = 1 To MAX_MAPS
Packet = Packet & SEP_CHAR & MAP(I).Name & SEP_CHAR
n = n + 1
Next I
Packet = "MAPLIST" & SEP_CHAR & n & Packet & END_CHAR
Call SendDataTo(Index, Packet)
End Sub
And lastley, right under this Map Report Packet, paste this packet:
Code:
' :::::::::::::::::::::::::::::
' :: Request Map List Packet ::
' :::::::::::::::::::::::::::::
If LCase(Parse(0)) = "requestmaplist" Then
' Prevent hacking
If GetPlayerAccess(Index) < ADMIN_MAPPER Then
Call HackingAttempt(Index, "Admin Cloning")
Exit Sub
End If
Call SendMapList(Index)
End If
Been a while since I added this to my game, so I'm not sure if I including everything that needs to be there. Let me know if it doesn't work, and I'll update the tutorial.