03-12-2006, 06:08 AM
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:
:: CLIENT SIDE ::
In modGameLogic, under "' Used for atmosphere" add:Under "' Checking fps" add:Under "' Blit the text they are putting in" add:Under "' Calculate fps" add: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:In modHandleData, add:That's all!
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
Code:
' Checking lag
If LCase$(Mid$(MyText, 1, 4)) = "/lag" Then
LAGYN = Not LAGYN
MyText = vbNullString
Exit Sub
End If
Code:
If LAGYN = True Then
Call DrawText(TexthDC, 5, 5, "Lag: " & GameLAG, RGB(255, 255, 255))
End If
Code:
If LAGYN = True Then
If GetTickCount > TickLAG + 5000 Then
TickLAG = GetTickCount
Call SendData("lag" & END_CHAR)
End If
End If
In modGlobals:, under "Public GameFPS As Long" add:
Code:
Public GameLAG As Long
Code:
' ::::::::::::::::
' :: Lag Packet ::
' ::::::::::::::::
If LCase(Parse(0)) = "lag" Then
GameLAG = GetTickCount - TickLAG
Exit Sub
End If