Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Scripted Timevar3 (https://forums.graalonline.com/forums/showthread.php?t=85153)

Tigairius 04-15-2009 01:19 AM

Scripted Timevar3
 
It's not great, and not 100 percent accurate (sometimes off by a few miliseconds or a second), but I've found it to be more informative than using timevar. The only real problem is it depends a lot on your computer's clock speed, so some measures might be slightly off, but if anything at least you can use it to get serverside timevar2 clientside.

Feel free to rip it apart and try to make it work better.

Just put this in a weapon:

PHP Code:

function onCreated() {
  for (
temp.plallplayers) {
    if (
pl.level.name != NULL) {
      
pl.addWeapon(this);
      
pl.triggerclient("gui"name"timevar"timevar2);
    }
  }
}

function 
onPlayerLogin(pl) {
  
pl.addWeapon(this);
  
pl.triggerclient("gui"name"timevar"timevar2);
}

function 
onPlayerLogout(pl) {
  if (
pl.level.name != NULL) {
    
pl.client.starttime NULL;
  }
}

function 
onInitialized() {
  
this.trigger("Created"NULL);
}

function 
onActionServerside() {
  switch (
params[0]) {
    case 
"timecheck":
      echo(
"It took" SPC abs(timevar2 params[1]) SPC "secs to reach serverside.");
    break;
  }
}
 
//#CLIENTSIDE
function onCreated() {
  
time this;
  if (
client.starttime == NULL)
    
client.starttime timevar2;
}

function 
onActionClientside() {
  switch (
params[0]) {
    case 
"timevar":
      
this.utime params[1] + (timevar2 client.starttime);
    break;
  }
}

public function 
getTimevar3() {
  return (
timevar2 client.starttime) + this.utime 1;
}

function 
onPlayerChats() {
  if (
player.chat == "gettime") {
    
triggerserver("gui"name"timecheck"getTimevar3());
    
player.chat getTimevar3();
  }


To get the current time clientside, just call 'time.getTimevar3()'.

Note: It'll un-sync if you update the weapon, so reconnect after you update it/add it.

cbk1994 04-15-2009 01:20 AM

Worked really nice from what I saw, and was extremely accurate. I will very likely be using this in the future.

fowlplay4 04-15-2009 02:21 AM

I have pretty much the same thing on Zodiac but for some reason if you resize the client it causes it to mess up.

Ex: Go on Zodiac and cast a spell to get a cooldown then resize your window, it'll clear the cooldowns sometimes or extend the time then fix itself after a sec or so. I had to make it so it disabled your ability to cast for a few seconds so people couldn't abuse it.

napo_p2p 04-15-2009 02:32 AM

Quote:

Originally Posted by fowlplay4 (Post 1483974)
I have pretty much the same thing on Zodiac but for some reason if you resize the client it causes it to mess up.

Window resizing may be halting the execution of scripts (similar to what happens when you push escape on Windows).

fowlplay4 04-15-2009 02:48 AM

Quote:

Originally Posted by napo_p2p (Post 1483976)
Window resizing may be halting the execution of scripts (similar to what happens when you push escape on Windows).

Which is also responsible for another glitch on Zodiac! Curse those bugs that should be fixed by client updates.

ffcmike 02-05-2012 12:16 AM

I find this method to be quite accurate:

PHP Code:

//place within a 0.05 second timeout
function handleTimeVar(){
  if(
this.time != timevar){
    
this.time timevar;
    
this.tv2 this.time 5;
    
this.timechange timevar2;
  }
}

public function 
getTimevar3(){
  return 
981048814 this.tv2 timevar2 this.timechange;


When I trigger to the server to compare the difference it's always about 0.25 seconds behind serverside timevar2, which would include the delay caused by latency.


All times are GMT +2. The time now is 09:46 AM.

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