Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mapreport Upgrade
#1
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:
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.
Reply
#2
I love you.

Much.
Reply
#3
You forgot to include the Sub SendMapList
Reply
#4
Updated the tutorial with the missing sub
Reply
#5
Wow.. that's very useful. I just started re-mapping Winds Whisper so this'll be very useful.

Thanks Ruggles
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#6
Works perfectly. Thanks.
Reply
#7
Little old I guess... but oh well. In one of your packet's it did not have "z" as a variable. It gave me an error on the line, "z = val(parse(1))". Not sure if this matters, but this is how I managed to easily fix it (assuming it works). I'm using the newest version of MS out right now.

Code:
' ::::::::::::::::::
    ' :: Get Map List ::
    ' ::::::::::::::::::
    Dim z As Integer
    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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)