PDA

View Full Version : Latency?


Raeiphon
06-01-2006, 09:48 AM
I've wondered how to do this, and there doesnt appear to be any functions in gscript which return a ping or a latency value, so it appears i'd have to do it manually.

What would I have to do to get a function that returns a latency value? I was thinking along the lines of timing a file request through a for with a sleep .001 in it, and once the request is completed, the for would end and return the value. Not sure if this'd work with gscript though, as I think file requests are cached and I intend to use this alot.

Omini
06-01-2006, 06:51 PM
I'm pretty sure it's possible - but how, I'm afraid I can't help you there.

Reason I think it's possible is that Atrius has it (bottom right), it reads it from a client.string (or maybe a clientr.string, I can't remember). How they did it though I don't know. Although yeah, it's possible.

Andy0687
06-01-2006, 08:09 PM
You could try using timevar2, sending a triggeraction to the serverside, and comparing the timevars when it returns.

There used to be a decent Free script on graal.net I think Cybnext or someone made it.

xXziroXx
06-01-2006, 08:16 PM
http://www.graal.net/snippet/detail.php?type=snippet&id=13

Raeiphon
06-02-2006, 12:51 AM
All that for a latency script? Wow. That'd be smaller in gs2, definately. I'll get working on coding my own function, and i'll post it when i'm done

ApothiX
06-02-2006, 03:16 PM
That script is horribly formatted :x

Could probably have the same effect with something like:

function onActionServerside() {
if(params[0] == "ping") {
player.triggerclient("gui", "WEAPONNAME", "pingreturn");
}
}

//#CLIENTSIDE
function onActionClientside() {
if(params[0] == "pingreturn") {
client.ping = timevar2 - this.ping_sendtime;
}
}

public function GetPing() {
this.ping_sendtime = timevar2;
triggerserver("gui", "WEAPONNAME", "ping");
}

This sets the client.ping to their ping time. Untested, but should work.

Admins
06-02-2006, 03:21 PM
Yes Okiesmokie script looks best, you can also type this.name instead of "WEAPONNAME" to make it easy to use.
Such pings are not very accurate though, since the scripts are only executed each 0.05 seconds on clientside (50 milliseconds), so you will never get higher or lower ping. But it is planned that we add a pinging funtion to clientside and serverside, to detect if something is too slow, to compare servers etc. The client will need to be modified to answer the ping immediatelly though.

xXziroXx
06-02-2006, 10:36 PM
Yes Okiesmokie script looks best, you can also type this.name instead of "WEAPONNAME" to make it easy to use.
Such pings are not very accurate though, since the scripts are only executed each 0.05 seconds on clientside (50 milliseconds), so you will never get higher or lower ping. But it is planned that we add a pinging funtion to clientside and serverside, to detect if something is too slow, to compare servers etc. The client will need to be modified to answer the ping immediatelly though.


Or to save space, just write 'name' instead of 'this.name'! :D

ApothiX
06-03-2006, 05:44 AM
Or to save space, just write 'name' instead of 'this.name'! :D
Better hope you don't have any global variables called 'name' >: P

xXziroXx
06-03-2006, 06:00 AM
Better hope you don't have any global variables called 'name' >: P

Horrible thought!