View Single Post
  #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