Justn Posted March 27, 2014 Author Share Posted March 27, 2014 Hello I have have a question hopefully someone can answer. This code is suppose to keep players in-game to prevent a player from logging out in order to survive an attack. It does that but completely breaks the "Safe Zone" map moral.. as in when I set the map editor setting to "safe zone" and click save it disconnects me from the server (no error msg and server continues to run) and from then on that map causes crashes until deleted. I have tried a couple things but it just seems to make the issues worse. Here is the code for the logout timer:Note: Everything is server-side.First find:```Public Type TempPlayerRec```Just before the "End Type" add this:```' logging outlogout As BooleanlogoutTmr As Long```Next, find:```' Check for disconnections every half secondIf Tick > tmr500 Then```Replace that entire block of code with this{```' Check for disconnections every half second If Tick > tmr500 Then For i = 1 To MAX_PLAYERS If Player(i).Map > 0 Then If Map(Player(i).Map).Moral = MAP_MORAL_NONE Then If frmServer.Socket(i).State > sckConnected And TempPlayer(i).logout = False Then TempPlayer(i).logout = True TempPlayer(i).logoutTmr = timeGetTime + 10000 End If Else CloseSocket (i) End If End If Next tmr500 = timeGetTime + 500 End If```Under that, add this block of code:```' 10 second logout For i = 1 To MAX_PLAYERS If Tick > TempPlayer(i).logout Then If TempPlayer(i).logoutTmr Then TempPlayer(i).logout = False TempPlayer(i).logoutTmr = 0 CloseSocket (i) End If End If Next```Finally, find:```Private Sub Socket_Close(index As Integer)```And replace the entire sub with this:```Private Sub Socket_Close(index As Integer) If Map(Player(index).Map).Moral = MAP_MORAL_NONE Then TempPlayer(index).logout = True TempPlayer(index).logoutTmr = timeGetTime + 10000 Else Call CloseSocket(index) End IfEnd Sub```And that should do it. Link to comment Share on other sites More sharing options...
abhi2011 Posted March 27, 2014 Share Posted March 27, 2014 How about I make a tutorial for this tmmrw? Link to comment Share on other sites More sharing options...
Justn Posted March 27, 2014 Author Share Posted March 27, 2014 > How about I make a tutorial for this tmmrw?Well that would be awesome. Did you have a chance to look at the above code? Was it completely wrong? I tried debugging it by following the moral variable around it sends from client to server correctly but then when sends data back to client it is when its messed up and server variable is "safe" but client reads it as "none".. Thought it was the map morals that were bugged but after doing some research I found the issue to be the logout timer above cause I removed it and morals worked again :/EDIT: OMG I have the fix thanks to the great Sekaru! thanks for looking into it Abhi2011! Link to comment Share on other sites More sharing options...
BeNjO Posted March 28, 2014 Share Posted March 28, 2014 Just for the record, the above doesn't work. Thought i'd try it for the sakes of it but when logging out it jumps right to:```' 10 second logout For i = 1 To MAX_PLAYERS If Tick > TempPlayer(i).logout Then If TempPlayer(i).logoutTmr Then TempPlayer(i).logout = False TempPlayer(i).logoutTmr = 0 CloseSocket (i) End If End If Next```rather than check the timer. Link to comment Share on other sites More sharing options...
Justn Posted March 28, 2014 Author Share Posted March 28, 2014 Yes I'll post the fix for you Link to comment Share on other sites More sharing options...
SpiceyWolf Posted March 31, 2014 Share Posted March 31, 2014 Why are you making a check for map moral on this? Its one easier, and 2 more efficient / harder to screw up or cause bugs if you make it time based logouts anywhere, liek 10 seconds without interuption by any character interaction. the Camp on Everquest could be a good reference to a simple design. 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