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

Kick AFK members in your game


Officer Johnson
 Share

Recommended Posts

Hi everyone,

This short tutorial will give you an easy way to kick those AFK members from your game. (Assuming they've been gone for a long time, or for whatever reason) anyways lets get to it.

All Server Sided:

Go to modConstants and add:

`Public Const INACTIVE_DURATION As Long = 10000 ' This is 10 seconds. (This is how long before kicked for being inactive) `

Now go to modTypes and at `TempPlayerRec` add at the bottom:

```
LastActive As Long
```

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

Before `CallWindowProc HandleDataSub(MsgType), index, Buffer.ReadBytes(Buffer.Length), 0, 0` put there:

```
TempPlayer(Index).LastActive = GetTickCount
```

Finally head over to gameloop and look for `' Check for disconnections every half second`

right after
```
If Tick > tmr500 Then
For i = 1 To MAX_PLAYERS
```
add:

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

That should be it make sure to test this one is working properly (I may have forgotten something but i think i got everything) let me know if any questions.

Enjoy.
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...