Nothing Posted March 20, 2012 Author Share Posted March 20, 2012 12345678 Link to comment Share on other sites More sharing options...
Ruins of Hell Posted March 20, 2012 Share Posted March 20, 2012 If by "tick" you mean the result returned by "GetTickCount" then:1 tick = 1/1000th of a second1000 ticks = 1 second60000 ticks = 1 minuteHow to do it:* Add a new variable to TempPlayerRec called LastActive as Long* Every time the player "does something" set TempPlayer(index).LastActive = GetTickCount + 600000 (that's 10 minutes).* In ServerLoop, every second (tmr1000) or half second (tmr500) or whatever you decide (I would do every 30 seconds, considering that a difference of 30 seconds in respect to 10 minutes doesn't matter). Loop through all currently online players. If their LastActive timer is less than the current time, send them an alert message saying they were kicked for inactivity. Link to comment Share on other sites More sharing options...
Nothing Posted March 20, 2012 Author Share Posted March 20, 2012 12345678 Link to comment Share on other sites More sharing options...
Nothing Posted March 20, 2012 Author Share Posted March 20, 2012 12345678 Link to comment Share on other sites More sharing options...
Ruins of Hell Posted March 20, 2012 Share Posted March 20, 2012 Yes, there's some errors with your code. First, is the design error. tmr1000 means that the code runs every 1000 ticks (or 1 second!). This means that second the code adds 1 to LastActive, which would be OK if you did it in terms of seconds, but now you do it in terms of ticks. So instead of 10 minutes, you're doing 10000 minutes because you switched from seconds to ticks.Then, you keep switching between n and index. Index is not defined here (I simply use index to detonate that a parameter index belongs in that slot). n is not defined depending on where you are.Next, you attempt to use "HandleKickPlayer". HandleKickPlayer is triggered when an administrator kicks the player. The key is that it attempts to read a long from the packet. You send no packet though, so it leaves the server confused.You also used AlertMsg after HandleKickPlayer, which is not needed because AlertMsg actually _does_ the kicking!You don't reset the value to the next appropriate tick trigger after you are done with it (see the other ticks).You don't follow my design, which isn't really an error, it's just how Eclipse does everything else and it's best to stay consistent.* * *I decided to write up an example timer to show you how to do it:First, under:```Dim tmr25 As Long, tmr500 As Long, tmr1000 As Long```add:```Dim KickTimer As Long ' declare the new timer```Then find:```If Not CPSUnlock Then Sleep 1```and _above_ it add:```If Tick > KickTimer Then ' is it time to check for kicking people? For i = 1 To Player_HighIndex ' go through all the active players If TempPlayer(i).LastActive < Tick Then ' have they been active recently? Call AlertMsg(i, "You have been kicked for inactivity!") ' kick them End If Next KickTimer = Tick + 30000 ' CHECK if we should kick them again in 30 secondsEnd If```* * *Please note that the player is not always index (it could be Attacker, for attacking a player). Different "activity" resets might need different variable names.```TempPlayer(Index).LastActive = GetTickCount + 600000```Note that 600000 is equal to 10 minutes. Link to comment Share on other sites More sharing options...
Nothing Posted March 21, 2012 Author Share Posted March 21, 2012 12345678 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now