- Joined
- Jun 23, 2007
- Messages
- 4,066
Use the function to find out how long it takes for a player to communicate with the host (ping).
I really need someone to test this online, I'm not 100% sure it works.
JASS:
library GetLatency requires TimerUtils
globals
private gamecache Cache = InitGameCache(SCOPE_PREFIX)
endglobals
function GetLatency takes nothing returns integer
local timer t = NewTimer()
local real elapsed
call TimerStart(t, 0.006, true, null)
call FlushGameCache(Cache)
call StoreInteger (Cache, "0", "0", GetPlayerId(GetLocalPlayer()))
call TriggerSyncStart()
call SyncStoredInteger(Cache, "0", "0")
call TriggerSyncReady()
call GetStoredInteger (Cache, "0", "0")
call FlushStoredMission(Cache ,"0")
set elapsed = TimerGetElapsed(t)
call ReleaseTimer(t)
return R2I(elapsed * 1000)
endfunction
endlibrary
I really need someone to test this online, I'm not 100% sure it works.
Last edited: