• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Ping

Status
Not open for further replies.
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
 
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)
 
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.
 
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()
 
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.
Back
Top