View Single Post
  #85  
Old 12-09-2007, 07:24 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by coreys View Post
This is what I have on Maloria to check for connection problems:

PHP Code:
function onActionServerSide() {
  switch (
params[0]) {
    
//Echo back to clientside if connection works.
    
case "serverecho":
      if ((
params[2]-1) > 0)
        echo(
"System Lag: Account " params[1] @ " had a connection failure. (Tried " @ (params[2]-1) @ " times.)");
      
triggerclient("weapon"name"clientok"params[1]);
    break;
    
/*
    Serverside lag detection to be completed later.
    case "serverok":
    break;*/
  
}
}
//#CLIENTSIDE
function onCreated() {
  
this.failcount 0;
  
this.timer 0;
  
client.noconnection false;
  
onTimeOut();
}
function 
onTimeOut() {
  
this.failcount++;
  if (
this.timer 3this.timer += .1;
  else {
    
triggerserver("weapon"name"serverecho"player.accountthis.failcount);
    
this.timer 0;
  }
  if (
this.failcount 3) {
    if (
this.failcount 10)
      
client.noconnection true;
    else {
      
this.failcount 0;
      
client.noconnection false;
      
serverWarp("login");
    }
  }
  else 
client.noconnection false;
  
setTimer(0.1);
}
function 
onActionClientSide() {
  if (
player.account == params[1]) {
    switch (
params[0]) {
      
//Connection successful
      
case "clientok":
        
this.failcount 0;
      break;
      
/*
      Serverside lag detection to be completed later.
      case "clientecho":
      break;*/
    
}
  }

Probably a better alternative. If client.noconnection is true, then don't do any processes, like damage detection, movement, etc.
Since when did scripts process while the ESC menu was open?

There is really no way to detect a window open for 0.05 seconds unless Graal tells you.
__________________