Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Latency? (https://forums.graalonline.com/forums/showthread.php?t=66385)

Raeiphon 06-01-2006 08:48 AM

Latency?
 
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 05: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 07: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 07:16 PM

http://www.graal.net/snippet/detail....=snippet&id=13

Raeiphon 06-01-2006 11:51 PM

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 02:16 PM

That script is horribly formatted :x

Could probably have the same effect with something like:

PHP Code:

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 02: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 09:36 PM

Quote:

Originally Posted by Stefan
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 04:44 AM

Quote:

Originally Posted by xXziroXx
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 05:00 AM

Quote:

Originally Posted by ApothiX
Better hope you don't have any global variables called 'name' >: P

Horrible thought!


All times are GMT +2. The time now is 07:23 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.