i'm trying to reduce lag on my mmo but no matter how hard i try i always get a lot of lag, even on a local network
i tried to send the less amount of packets possible this is what i got (the game has a 8-way movement system)
step event
if global.pause=false
if global.battle=false
if global.chatting=false{
if keyboard_check(global.k_up){
dv=1;
}else if keyboard_check(global.k_down){
dv=2;
}else{
dv=0;
}
if keyboard_check(global.k_left){
dh=10;
}else if keyboard_check(global.k_right){
dh=20;
}else{
dh=0;
}
}
dir=dv+dh
if dirtemp != dir{ //if button conbination changes
dirtemp = dir;
stat=1
switch(dir){
case 0: d=0; //----stop----
case 1: d=1; //----move up----
case 2: d=2; //----move down----
case 10: d=3; //----move left----
case 11: d=4; //----move up-left----
case 12: d=5; //----move down-left----
case 20: d=6; //----move right----
case 21: d=7; //----move up-right----
case 22: d=8; //----move down-right----
}
clearbuffer();;
writebyte(M_MOVE);
writeshort(x);
writeshort(y); //refresh position
writebyte(d) //move direction
sendmessage(global.socket);
}so this code uses 6 bytes and only send packets when you press or release buttons
when i test on localhost it runs great but even on a local network it gets laggy
any suggestions?
Edited by oslash, 15 January 2012 - 11:54 PM.











