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

[EO2] Server Status Checker


Me Gusta
 Share

Recommended Posts

This is a tutorial to bring back a feature from EE/ES for EO2\. That feature would be the server status checker. What this does(if it isn't obvious to you) is tells you whether the games server is online or offline. Now to begin.

**Client**
*This is all client sided

Form
Okay open up your source and go to frmMenu and create 2 labels and a timer:
Timer:
Name: tmrStatus
Top: 0
Left: 0
Interval: 2000

Label 1:
Place anywhere you want
label name: lblWTF(name whatever)
Caption: The Server is:
Font: Georgia
Font style: bold
Color: White

Label 2:
Place next to label 1
label name: lblOnline
Caption: Checking…
Font: Georgia
Font style: bold
Color: White

Code

Okay now that the form work is done open up the frmMenu code and create a private sub called: tmrStatus_Timer
it should look like this
```
Private Sub tmrStatus_Timer()

End Sub
```
in  the sub put:
```
    If ConnectToServer(1) Then
        lblOnline.Caption = "Online"
        lblOnline.ForeColor = vbGreen
    Else
        lblOnline.Caption = "Offline"
        lblOnline.ForeColor = vbRed
    End If
```This will check if the server is online. If it is then it'll say Online in green. If not it'll say offline in red.

After all this your code in Private Sub tmrStatus_Timer should look like this:
```
Private Sub tmrStatus_Timer()
    If ConnectToServer(1) Then
        lblOnline.Caption = "Online"
        lblOnline.ForeColor = vbGreen
    Else
        lblOnline.Caption = "Offline"
        lblOnline.ForeColor = vbRed
    End If
End Sub
```
Credit goes to:
Nickpop123
For helping me figure this out.

I've tested this it works.
Link to comment
Share on other sites

You can use 1 label also.
put 1 of the labels
and in the Timer, the Sub should look like this

```
Private Sub tmrStatus_Timer()
    If ConnectToServer(1) Then
        lblOnline.Caption = "The server is currently Online"
        lblOnline.ForeColor = vbGreen
    Else
        lblOnline.Caption = "The server is currently Offline"
        lblOnline.ForeColor = vbRed
    End If
End Sub
```
Link to comment
Share on other sites

@Domino_:

> Isnt there a way to do without timer? Like he checks server status when you press login so there under username text is displayed server status?

I'll look at it

@Wilfre:

> You can use 1 label also.
> put 1 of the labels
> and in the Timer, the Sub should look like this
>
> ```
> Private Sub tmrStatus_Timer()
>     If ConnectToServer(1) Then
>         lblOnline.Caption = "The server is currently Online"
>         lblOnline.ForeColor = vbGreen
>     Else
>         lblOnline.Caption = "The server is currently Offline"
>         lblOnline.ForeColor = vbRed
>     End If
> End Sub
> ```

Then it would be one ugly blotch of color
Link to comment
Share on other sites

@Me:

> I'll look at it

@Me:

> I'll look at it

Change login code (case 1 ) to
```
        Case 1
            If Not picLogin.Visible Then
                ' destroy socket, change visiblity
                DestroyTCP
                picCredits.Visible = False
                picLogin.Visible = True
                picRegister.Visible = False
                picCharacter.Visible = False
                picMain.Visible = False

                'Login checks server status
                If ConnectToServer(1) Then
                        lblSStatus.Caption = "Server status: Online"
                        lblSStatus.ForeColor = vbGreen
                    Else
                        lblSStatus.Caption = "Server status: Offline"
                        lblSStatus.ForeColor = vbRed
                End If

                ' play sound
                PlaySound Sound_ButtonClick
            End If

```and make label where you want to.. I added it in login area so before login you can see status. You can also add it somewhere else.

>! ![](http://www.freemmorpgmaker.com/files/imagehost/pics/d42bd868677c0d560486a90abbf0a9b5.PNG)
Link to comment
Share on other sites

  • 8 months later...
> I get an error here```
>
> frmMain.Socket.RemoteHost = Options.IP
>
> ```
> Invalid operation at current state
>
> error number 40020

To fix this first delete those 2 lines

```
frmMain.Socket.RemoteHost = Options.IP
```
```
frmMain.Socket.RemotePort = Options.PORT
```

Then go to frmMain find Socket and in Properties find RemoteHost and Remote Port and put

"127.0.0.1" or your IP

"7001" or your Port
Link to comment
Share on other sites

> How'd you get the menu translucency Domino

He did it in his graphic.

> To fix this first delete those 2 lines
>
> ```
> frmMain.Socket.RemoteHost = Options.IP
> ```
> ```
> frmMain.Socket.RemotePort = Options.PORT
> ```
>
> Then go to frmMain find Socket and in Properties find RemoteHost and Remote Port and put
>
> "127.0.0.1" or your IP
>
> "7001" or your Port

That's doing the same thing. Error 40020 generally occurs when you are trying to send/receive data while the socket is disconnected.
Link to comment
Share on other sites

  • 4 weeks later...
> ```
> [color]pic1[/color][color].[/color][color]visible [/color][color]=[/color] [color][font]ConnectedToServer[/font][/color][color][font]([/font][/color][color][font]1[/font][/color][color][font])[/font][/color]
>
> [color]pic2[/color][color].[/color][color]visible [/color][color]= Not[/color][color] [/color][color][font]ConnectedToServer[/font][/color][color][font]([/font][/color][color][font]1[/font][/color][color][font])[/font][/color]
> ```
>
> I think it's Not, I forget VB

Holy shit eclipse what did you do to my post O.o
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...