Jump to content


Photo

multiplayer game


  • Please log in to reply
2 replies to this topic

#1 flxp

flxp

    GMC Member

  • GMC Member
  • 325 posts
  • Version:GM8

Posted 14 February 2012 - 11:04 PM

i've been trying to make a multiplayer game, but i don't quite understand...

if(global.host)
{
clearbuffer()                  /*making sure nothing else is being sent to the other IP*/
writestring("Host Data")   /*just marking data*/
writeint(x)                     /*sending coordinates*/
writeint(y)
writeshort(round(angle))  /*coordinate to mouse angle(eyes)*/
bufferencrypt("blahh");    /*encrypting*/
sendmessage(<OtherIP>);/*finally sending data to the other comp..*/

bufferdecrypt("blahh")     /*recieving*/
S=readstring()               /*pointlessness*/
X=readint()                   /*recieving the other IP's coordinates*/
Y=readint()
Angle=readshort()          /*and angle*/
}else
{
clearbuffer()                 /*other IP  (2 player game anyways)*/
writestring("Other Data")
writeint(x)
writeint(y)
writeshort(round(angle))
bufferencrypt("blahh");
sendmessage(<HostIP>);

bufferdecrypt("blahh")
S=readstring()
X=readint()
Y=readint()
Angle=readshort()
}

it seems that it sends (X,Y,Angle) it to the same computer...
and i am using 2 different comps

also
draw_sprite(sprite_index,0,x,y)
draw_sprite_ext(sprite_index,1,x,y,1,1,angle,c_white,1)
draw_sprite(sprite_index,0,X,Y)
draw_sprite_ext(sprite_index,1,X,Y,1,1,Angle,c_white,1)
this supposeably gonna draw my other player...
i dont know what i did wrong..


and im using hamachi...

help would be appreciated
  • 0

#2 flxp

flxp

    GMC Member

  • GMC Member
  • 325 posts
  • Version:GM8

Posted 17 February 2012 - 06:20 PM

*Bump*.... :confused:
  • 0

#3 Huskehn

Huskehn

    GMC Member

  • New Member
  • 8 posts
  • Version:GM8

Posted 20 February 2012 - 11:02 PM

I'm working on multiplayer as well, so I'll be glad to help if I can. What exactly is the problem, though? From what I can see, it seems like you're forgetting to call receivemessage() before trying to decrypt with bufferdecrypt(). You need to receive the message first before you can decrypt or read it.

Also, right after you call receivemessage(), make sure a message actually was received before trying to read it. Simply do something like "size = receivemessage();" and "if size <= 0 exit;", because if the size of the message is 0 or less, you of course won't be able to read it.

Edited by Huskehn, 20 February 2012 - 11:05 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users