View Single Post
  #58  
Old 12-08-2007, 09:41 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
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.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts