| Mirage Source http://www.miragesource.net/forums/ |
|
| /Lag Command (Ping) http://www.miragesource.net/forums/viewtopic.php?f=210&t=791 |
Page 1 of 1 |
| Author: | Tutorial Bot [ Sun Dec 03, 2006 6:08 am ] |
| Post subject: | /Lag Command (Ping) |
Author: Dragoons Master Difficulty: 1/5 "That's pretty simple thing but I think it's pretty cool/useful stuff. It's nothing but a little ping command, just like that, it sends a packet to the server and then the server answer your ping packet with an other packet. When the client first sends the packet it stores the time value (GetTickCount) and when the client receives the packet from the server it stores this value on a variable and shows it on screen for the user. Pretty simple." :: SERVER SIDE :: In modHandleData, add: Code: ' :::::::::::::::: ' :: Lag Packet :: ' :::::::::::::::: If LCase(Parse(0)) = "lag" Then Call SendDataTo(Index, "lag" & END_CHAR) Exit Sub End If :: CLIENT SIDE :: In modGameLogic, under "' Used for atmosphere" add: Code: Public LAGYN As Boolean Public TickLAG As Long Under "' Checking fps" add: Code: ' Checking lag If LCase$(Mid$(MyText, 1, 4)) = "/lag" Then LAGYN = Not LAGYN MyText = vbNullString Exit Sub End If Under "' Blit the text they are putting in" add: Code: If LAGYN = True Then Call DrawText(TexthDC, 5, 5, "Lag: " & GameLAG, RGB(255, 255, 255)) End If Under "' Calculate fps" add: Code: If LAGYN = True Then If GetTickCount > TickLAG + 5000 Then TickLAG = GetTickCount Call SendData("lag" & END_CHAR) End If End If OBS: Change the 5000 to the Interval you want the client to update the Lag, I set 5000 because I think 5 seconds it pretty enough. In modGlobals:, under "Public GameFPS As Long" add: Code: Public GameLAG As Long In modHandleData, add: Code: ' :::::::::::::::: ' :: Lag Packet :: ' :::::::::::::::: If LCase(Parse(0)) = "lag" Then GameLAG = GetTickCount - TickLAG Exit Sub End If That's all! |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|