Jump to content


Photo

[39dll] reducing lag in movement


  • Please log in to reply
4 replies to this topic

#1 oslash

oslash

    GMC Member

  • GMC Member
  • 32 posts

Posted 15 January 2012 - 07:40 PM

hi guys

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.

  • 0

#2 2DLuis

2DLuis

    Graphic Designer

  • GMC Member
  • 2493 posts
  • Version:GM8

Posted 16 January 2012 - 12:27 AM

Receive your movement messages and execute them with a slight delay (based on your ping) so that it does not look jumpy.
  • 0

#3 oslash

oslash

    GMC Member

  • GMC Member
  • 32 posts

Posted 24 February 2012 - 04:33 PM

Receive your movement messages and execute them with a slight delay (based on your ping) so that it does not look jumpy.

sorry for reviving this thread, i hasnt work on this since...

could you tell me how can i do that?
  • 0

#4 xEePiiCzZ

xEePiiCzZ

    GMC Member

  • New Member
  • 1 posts
  • Version:GM8

Posted 19 May 2012 - 03:34 PM

The fault might be in receiving the messages?
  • 0

#5 RevenantGhost

RevenantGhost

    GMC Member

  • GMC Member
  • 106 posts
  • Version:GM8

Posted 19 May 2012 - 06:00 PM

As lag you mean that the player "teleports" or that the messages are received too late?
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users