• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Ping

Status
Not open for further replies.
Level 24
Joined
Jun 26, 2006
Messages
3,406
there's probably a way to detect if a user has pinged. every time somebody pings, you can just store that to a variable. hooray for the Ephy Way Out
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Should be something along the lines of;

JASS:
globals
    timer gameTime
endglobals

function someInitFunction takes nothing returns nothing
    set gameTime = CreateTimer()
    call TimerStart( t, 999999999999, false, null )
endfunction

function GetPing takes nothing returns nothing
    local real i = TimerGetElapsed(gameTime)
    call TriggerSynchStart()
    call TriggerSynchReady()
    call BJDebugMsg( "Latency is: " + R2S( TimerGetElapsed(gameTime) - i )
endfunction

I'm not sure if that exact code works, but that's something along the lines of it (synch the game, then see how much time that took)
 
Level 36
Joined
Mar 15, 2006
Messages
7,945
Well, I know jack all about JASS, so if I could find some working code for me to copy and paste, I would totally appreciate it. Credit, rep and the laughter of a child would be at your feet if you worked out the exact code for me.








Note: I can't guarantee that a laughing child will show up at your feet. Sorry for any disappointment this may cause.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
The exact code is - make a global timer called gameTime

then, put

Custom Script: set udg_gameTime = CreateTimer()
Custom Script: call TimerStart( udg_gameTime, 99999999, false, null )

in a Map Initialization trigger, and leave this in your Map's header

JASS:
function GetPing takes nothing returns real
     local real i = TimerGetElapsed( udg_gameTime )
     call TriggerSynchStart()
     call TriggerSynchReady()
     return TimerGetElapsed( udg_gameTime ) - i
endfunction

Notes:
-it will make the calling trigger 'wait' for the duration of the latency
-I haven't had an opportunity to test this, so there could be an error.

Finally, use it with a global real called "something" (change this), then

Custom Script: set udg_something = GetPing()
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
something was just a random real for you to dump the ping in.

You could rename it to w/e you want, and it would just be

udg_(new name)

Map Init -- make a new trigger that fires on Map Initialization?
Custom Script bits -- the one with 'something' would be what you would call to get the ping, the other 2 go in a map init trigger, and they initialize the game timer.

Finally, if you click on your "map" in the Trigger Editor, you'll get a space to dump Jass. Put the GetPing function posted above there.
 
Status
Not open for further replies.
Top