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 < 3) this.timer += .1;
else {
triggerserver("weapon", name, "serverecho", player.account, this.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.