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

[TUT] Report System


abhi2011
 Share

Recommended Posts

This tutorial will show you how to make a report system. How it works is that you can type "/report" and a form will come where you can choose between player and bug report. Currently only bug report is
supported. When the server receives the reporters name and report it will save them as a text file in the data files of the server. Also if there is already a report from someone and the player reports again the report will not be saved. (something that should also be implemented) If someone finds a way to do so please post is as a comment!

Download and add frmReport to your project!Ā  [http://www.freemmorpgmaker.com/files/imagehost/pics/16549863c6fa5c5faf7c441a362b2384.rar](ftp://www.freemmorpgmaker.com/files/imagehost/pics/16549863c6fa5c5faf7c441a362b2384.rar)

Client Side!

Add
```
CBugReport
```in modEnumerations above
```
' Make sure CMSG_COUNT is below everything else
```
Add
```
Sub sendBugReport(ByVal Name As String, ByVal report As String)
Dim Buffer As New clsBuffer

Ā  Ā  If Options.Debug = 1 Then On Error GoTo errorhandler

Ā  Ā  Set Buffer = New clsBuffer
Ā  Ā  Buffer.WriteLong CBugReport
Ā  Ā  Buffer.WriteString Name
Ā  Ā  Buffer.WriteString report
Ā  Ā  SendData Buffer.ToArray
Ā  Ā  Set Buffer = Nothing

Ā  Ā  'error handler
Ā  Ā  Exit Sub
errorhandler:
Ā  HandleError "sendBugReport", "modClientTCP", Err.Number, Err.Description, Err.Source, Err.HelpContext
Ā  Ā  Err.Clear
Ā  Ā  Exit Sub
End Sub

```At the bottom of modClientTCP.

In modInput find:
```
Case "/stats"
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Set Buffer = New clsBuffer
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Buffer.WriteLong CGetStats
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  SendData Buffer.ToArray()
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Set Buffer = Nothing
```below it add:
```
Case "/report"
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  frmReport.Show
```
END OF CLIENT SIDE! (YEP I KNOW IT IS SMALL!)
ā€“------------------------------------------------------------------------------------------------------------------------------
SERVER SIDE

Add this in modHandleData below the long lines of address!
```
HandleDataSub(CBugReport) = GetAddress(AddressOf HandleBugReport)
```
Add this at the end of the mod :
```
Sub HandleBugReport(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
Dim Buffer As clsBuffer
Dim Name As String
Dim report As String
Dim intFileHandle As Integer

Ā  Ā  Set Buffer = New clsBuffer
Ā  Ā  Buffer.WriteBytes Data
Ā  Ā  Name = Buffer.ReadString
Ā  Ā  report = Buffer.ReadString

Ā  intFileHandle = FreeFile
Ā  Ā  Open (App.Path & "\data\bug reports.txt") For Append As #intFileHandle
Ā  Ā  Print #intFileHandle, vbCrLf & Name & " has reported a bug - " & report
Ā  Ā  Close #intFileHandle

End Sub

```

In modEnumerations above
```
' Make sure CMSG_COUNT is below everything else
```add:
```
CBugReport
```
For those who have added the following piece of code
```
ChkDir App.Path & "\data files\", "Bug Reports"
```remove it as it's not neccesary

Credits go to Me!
Credits also go to zomb88 for helping me figure out how to record multiple reports in the same file!
Link to comment
Share on other sites

The player report system is out.
So before I say anything please download the new frmReport. I have updated the Bug Report system post frmReport also. This is a new frmReport. The old one was glitched.

[http://www.freemmorpgmaker.com/files/imagehost/pics/16549863c6fa5c5faf7c441a362b2384.rar](ftp://www.freemmorpgmaker.com/files/imagehost/pics/16549863c6fa5c5faf7c441a362b2384.rar)

CLIENT SIDE

In modClientTCP add this at the bottom :
```
Sub sendPlayerReport(ByVal Pname As String, ByVal report As String, ByVal RPname As String)
Dim Buffer As New clsBuffer

Ā  Ā  If Options.Debug = 1 Then On Error GoTo errorhandler

Ā  Ā  Set Buffer = New clsBuffer
Ā  Ā  Buffer.WriteLong CPlayerReport
Ā  Ā  Buffer.WriteString Pname
Ā  Ā  Buffer.WriteString report
Ā  Ā  Buffer.WriteString RPname
Ā  Ā  SendData Buffer.ToArray
Ā  Ā  Set Buffer = Nothing

Ā  Ā  'error handler
Ā  Ā  Exit Sub
errorhandler:
Ā  HandleError "sendPlayerReport", "modClientTCP", Err.Number, Err.Description, Err.Source, Err.HelpContext
Ā  Ā  Err.Clear
Ā  Ā  Exit Sub
End Sub

```
In mod enumerations before :
```
' Make sure CMSG_COUNT is below everything else
```add this
```
CPlayerReport
```
CLIENT SIDE DONE

* * *

In mod Enumerations above
```
' Make sure CMSG_COUNT is below everything else
```add this :
```
CPlayerReport
```
In modHandleData at the end of the initMessages() add this
```
HandleDataSub(CPlayerReport) = GetAddress(AddressOf HandleplayerReport)
```and add this at the bottom of the mod
```
Sub HandleplayerReport(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
Dim Buffer As clsBuffer
Dim Pname As String
Dim report As String
Dim RPname As String
Dim intFileHandle As Integer

Ā  Ā  Set Buffer = New clsBuffer
Ā  Ā  Buffer.WriteBytes Data
Ā  Ā  Pname = Buffer.ReadString
Ā  Ā  report = Buffer.ReadString
Ā  Ā  RPname = Buffer.ReadString

Ā  Ā  intFileHandle = FreeFile
Ā  Ā  Open (App.Path & "\data\PlayerReports.txt") For Append As #intFileHandle
Ā  Ā  Print #intFileHandle, vbCrLf & Pname & " Reported " & RPname & " - " & report
Ā  Ā  Close #intFileHandle
End Sub

```
THE END.
If you find any bugs just post them below the community will help you. :D
Link to comment
Share on other sites

I didnt even need to go through it i merely took 5secs to look at it.

1\. Why use a whole new form for the report then use a frame or something that just gets shown.
2\. Look at your File Exists check.
3\. Google vb6 text files.

Very basic tutorial but could be done alot better imo
Link to comment
Share on other sites

@zomb88:

> I didnt even need to go through it i merely took 5secs to look at it.
>
> 1\. Why use a whole new form for the report then use a frame or something that just gets shown.
> 2\. Look at your File Exists check.
> 3\. Google vb6 text files.
>
> Very basic tutorial but could be done alot better imo

1\. I made a frame so that 2 reporting systems can be added Bug and Player. If you want make 2 forms. Bug Report and Player Report. But it will just increase the work. And also the good thing of a frame is that if you make a frame invisible all the controls in the frame will also be invisible. If you were thinking of making both the Bug and Player report in both the same form without the frame, it will take some time to write the code for making each and every wanted control to be visible and also might confuse you.

2\. What is wrong with them?
3\. I will am checking them right now!
Link to comment
Share on other sites

ĆƒĘ’Ć¢ā‚¬Å”ƃā€šĆ‚Ā·Ā  Ā  Ā  Ā  mode is one of the following three keywords: Input, Output, or Append.

When a file is opened for Output, if it does not exist, it will be created; if it does exist, its previous contents will be overwritten.

and if you keep reading you might find your answer to your next step in this.. tutorial
```
When a file is opened for Append, if it does not exist, it will be created, if it does exist, records will be added to the file after the last record in the file (the previous contents of the file will not be overwritten).
```
Btw i ment making a frame on the game formā€¦ not on the form you made.
Link to comment
Share on other sites

When a file is opened for Append, if it does not exist, it will be created, if it does exist, records will be added to the file after the last record in the file (the previous contents of the file will not be overwritten).

If that doesnt make sense there is something wrong.

hint..

>! THERES ONE WORD TO CHANGE

And you still dont get whats wrong with your file exist?
Link to comment
Share on other sites

Solved! : Figure out a way to make multiple reports recorded in the same file

SERVER SIDE
Replace HandleBugReport in modHandleData with
```
Sub HandleBugReport(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
Dim Buffer As clsBuffer
Dim Name As String
Dim report As String
Dim intFileHandle As Integer

Ā  Ā  Set Buffer = New clsBuffer
Ā  Ā  Buffer.WriteBytes Data
Ā  Ā  Name = Buffer.ReadString
Ā  Ā  report = Buffer.ReadString

Ā  intFileHandle = FreeFile
Ā  Ā  Open (App.Path & "\data\bug reports\" & Name & ".txt") For Append As #intFileHandle
Ā  Ā  Print #intFileHandle, report
Ā  Ā  Close #intFileHandle
end sub
```
UPDATED MAIN POST!
Link to comment
Share on other sites

@abhi2011:

> Thx. Culdn't do it without u though! I never fully understood Apend except reocrds will go to the end of the text . never actually thought it will make a text file. I will work on the player report now!

You seem like you have the willingness to learn unlike 90% or more of ppl on this community. Glad you could figure it out with some abrupt direction xD
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...