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

[EO 2.0] Disconnect Inactive Users


Matt
 Share

Recommended Posts

This is a pretty easy edit, and it's all server-sided.

First, go to modConstants and chuck this anywhere.

```

Public Const TIMEOUT_DURATION As Long = 5000 ' 5 seconds

```
Now, go to modTypes and look for TempPlayerRec. Add this at the bottom.

```

LastActive As Long

```
Look for the sub "HandleData(ByVal index As Long, ByRef Data() As Byte)"

Right before

```

CallWindowProc HandleDataSub(MsgType), index, Buffer.ReadBytes(Buffer.Length), 0, 0

```
put there

```

TempPlayer(index).LastActive = GetTickCount

```
Finally, go to your gameloop and look for the lines

```

        ' Check for disconnections every half second
        If Tick > tmr500 Then
            For i = 1 To MAX_PLAYERS

```
Put this right after it.

```

                If IsPlaying(i) Then
                    ' Check to see if they've been inactive for too long.
                    If Tick - TempPlayer(i).LastActive > TIMEOUT_DURATION And TempPlayer(i).LastActive <> 0 Then Call CloseSocket(i)
                End If

```
Save, and compile; you're done!
Link to comment
Share on other sites

It's just a simple check inside a pre-existing for statement, so it won't really make a visible difference on performance. But, I suppose it would be proper to make it every second. I'll update the tutorial.

EDIT: Actually, every half a second should be better. I updated the tutorial.
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...