Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-15-2009, 01:19 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
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.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #2  
Old 04-15-2009, 01:20 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Worked really nice from what I saw, and was extremely accurate. I will very likely be using this in the future.
__________________
Reply With Quote
  #3  
Old 04-15-2009, 02:21 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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.
__________________
Quote:
Reply With Quote
  #4  
Old 04-15-2009, 02:32 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by fowlplay4 View Post
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).
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #5  
Old 04-15-2009, 02:48 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by napo_p2p View Post
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.
__________________
Quote:
Reply With Quote
  #6  
Old 02-05-2012, 12:16 AM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:15 PM.


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