Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


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 07:15 AM.


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