39dll V2.5
#61
Posted 12 July 2005 - 12:15 PM
if(!global.master)exit;
Now do the same thing for paddle two but change it to:
if(global.master)exit;
#62
Posted 12 July 2005 - 12:20 PM
Edited by matu666, 12 July 2005 - 12:25 PM.
#63
Posted 12 July 2005 - 12:35 PM
And with player 2 you aren't even sending the data that he moved. :/
#64
Posted 12 July 2005 - 12:37 PM
#65
Posted 12 July 2005 - 12:42 PM
if (!global.master)
{
y+=4;
clearbuffer();
writebyte(0); // We call this message ID 0.
writeshort(x);
writeshort(y);
sendmessage(global.otherplayer);
}Since there are only 2 players it doesn't really matter how much data you send. 5 bytes every packet. So 5 * 30 = 150 bytes per second. Download en upload means 300 bytes. That's about 0.3kb.
#66
Posted 12 July 2005 - 01:35 PM
The tutorial said nothing about it was for creating a pong game. I said i was using pong as an example.well i followed the exapmle none of that was in it as i say im new to this, so what has to go in player 2
#67
Posted 12 July 2005 - 02:52 PM
#68
Posted 12 July 2005 - 03:44 PM
Edit: Alright, here it is, it isn't really that good, it's pretty simple, though.
Download here:
Winsockets DLL tutorial.
I won't be able to host it 24/7 though. The server will be offline some times.
Jochem.
Edited by Jochem, 12 July 2005 - 05:47 PM.
#69
Posted 12 July 2005 - 07:37 PM
Could you post here some kind of tutorial, please?
thanks.
^^
#70
Posted 12 July 2005 - 07:43 PM
Make the server do stuff that the monster is supposed to do. Then send the monsters data to all players able to see it.
Monster data contains x and y. Some times even direction, speed and sprite_index.
Jochem.
#71
Posted 13 July 2005 - 02:29 PM
A monster? That's easy. There needs to be one controller-application, the server.
Make the server do stuff that the monster is supposed to do. Then send the monsters data to all players able to see it.
Monster data contains x and y. Some times even direction, speed and sprite_index.
Jochem.
In some Future update, it will be added to 39ster's Zelda game?
Im just learning how to use this dll ^^
anyway, if someone want help me to make a monster.
wsaenotsock@hotmail.com
add me on msn ^^
#72
Posted 13 July 2005 - 10:56 PM
Just let the server act like a monster should do. Like it isn't even multiplayer. Then every 5 steps, update his position, or something. (You'll get the idea.)
clearbuffer(); writebyte(0); // Message ID 0. writeshort(x); // X position on the map. writeshort(y); // Y position on the map. sendmessage(global.player); // Send the message to the player.
This is really basic, you just have to tweak it a little, and add some stuff to it. If you still don't know how to do it, I suggest starting with something more simple first...
Jochem.
Edited by Jochem, 13 July 2005 - 10:57 PM.
#73
Posted 14 July 2005 - 11:59 PM
#74
Posted 16 July 2005 - 04:21 PM
For example, if you wanted to move in 8 directions, you have the direction right-up (North-east), which is the number 45. If you divide 45 by 2, it would be 22,5, which doesn't work with writebyte(). Make sure the number is 44. You don't notice any difference within the game.
This is very simple, but I think some people won't have thought of this.
Jochem.
#75
Posted 17 July 2005 - 09:46 AM
This is the code with what i want to send message to other player:
clearbuffer();
writebyte(10);
writestring(get_string("Write message to send to other player" ,""));
sendmessage(global.otherplayer);And i am receiving it with this: mid = readbyte(); //Read the message id
switch(mid) //Test the message id
{
case 10:
tekst = readbyte(); break;
}And in draw event i just draw text with a variable "text".But when i send the tekst, then other player only gets numbers? How to fix it?
#76
Posted 17 July 2005 - 10:17 PM
Its because when your sending you have:Hi i am having a problem:
This is the code with what i want to send message to other player:clearbuffer(); writebyte(10); writestring(get_string("Write message to send to other player" ,"")); sendmessage(global.otherplayer);And i am receiving it with this:mid = readbyte(); //Read the message id switch(mid) //Test the message id { case 10: tekst = readbyte(); break; }And in draw event i just draw text with a variable "text".
But when i send the tekst, then other player only gets numbers? How to fix it?
writebyte();
writestring();
but when you recieved the message you have
readbyte();
readbyte(); //why is this readbyte() when its a string?
Change your code to this:
clearbuffer();
writebyte(10);
writestring(get_string("Write message to send to other player" ,""), true); //i also added true in the second argument of writestring() which you should most of the time use.
sendmessage(global.otherplayer);Recieving mid = readbyte(); //Read the message id
switch(mid) //Test the message id
{
case 10:
tekst = readstring();
break;
}Thats a good idea but you can get the number to be more exact to the original direction if you divide it by 1.41 instead of 2.I've got a (working) idea to utilize only one byte for direction, rather than two bytes. writebyte() can be a number from 0 - 255. And direction can be 0 - 360. You just have to divide the direction by 2 and make sure that you aren't sending 'broken' numbers, like 7,5; 210,5 etc.
For example, if you wanted to move in 8 directions, you have the direction right-up (North-east), which is the number 45. If you divide 45 by 2, it would be 22,5, which doesn't work with writebyte(). Make sure the number is 44. You don't notice any difference within the game.
This is very simple, but I think some people won't have thought of this.
Jochem.
e.g
//send
writebyte(round(direction/1.41));
sendmessage(socket);
//recv
recievemessage(socket);
direction = round(readbyte()*1.41);
You can get 1.41 by doing 360/256
Edited by 39ster, 17 July 2005 - 10:45 PM.
#77
Posted 18 July 2005 - 10:59 PM
When I try to synchronize the players in my game, all they do is 'jump'. I know why this is caused, I've searched for the bug. I'm pretty close to knowing what could have been caused this. Speed somehow messes up, and only a 0 is send. Results in not moving, and only updating the position of the other players some times, which results in 'jumping'.
Edit: Never mind, it was just a silly error of mine. I used receiveshort before the readbyte() while I should've used readbyte(). :/
Jochem.
Edited by Jochem, 18 July 2005 - 11:03 PM.
#78
Posted 19 July 2005 - 06:20 AM
Infact, heres a quote of what I've said in the past
I'm so impressed, so impressed, that I have come back from VB6, and started using GM for all my applications. I love you 39ster(in a brotherly way).
#79
Posted 19 July 2005 - 10:20 PM
- Make sure that the write() functions are in the same order as the read() functions are.
- Make sure that you aren't trying to send a string via writebyte() or sending a real number via writestring().
- If your string doesn't have a fixed size, make sure that that argument1 in writestring() is set to true.
- Make sure that you aren't writing a number bigger than is allowed for a certain write() function, for example, don't send the number 301 via writebyte(). You may think that you have not done this, but some times this happens, even though you were really really sure it shouldn't have happened.
Well, that's all for now. I'll probably add more things later on.
Edit: I also made a simple script to pack & unpack multiple true/false variables (booleans) into a single byte. You can pack a maximum of 3 variables.
Download: Ultra pack scripts
Jochem.
Edited by Jochem, 22 July 2005 - 02:34 PM.
#80
Posted 30 July 2005 - 12:09 PM
//Wait for receiving a message
//Argument0=Socket to check
//Argument1=ID, -1 if anny message.
//Argument2=Timeout time(How long it should wait for a message) 1000=1 second(if you run i 30FPS)
//Return=The message received, or "" if no message found.
var timeout, mesid, temp;
clearbuffer();
timeout=current_time;
while(true)
{
mesid=peekmessage(argument0);
if(mesid>0) //Check if we got message
{
if(readbyte()==argument1 or argument1==-1)//Check if it is the ID we want
{
temp=readstring(mesid-1); //Return the message
recievemessage(); //Get the message(So it's not recieved again
clearbuffer();
return temp;
}
}
if(current_time>=timeout+argument2) //Check for timeout
{
return ""; //Timeout/No message found
exit;
}
}EDIT: And a question: What does it mean to Terminate the string, in writestring(); ?
Edited by krstjern, 30 July 2005 - 12:13 PM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users









