Harv Opublikowano 28 Marca 2008 Opublikowano 28 Marca 2008 Pomyśl logicznie. Tam gdzie masz ruch, dodajesz direction.
Crackkk-GM Opublikowano 29 Marca 2008 Opublikowano 29 Marca 2008 alarm[0] playerow: GML //Update position. alarm is called in obj_client clearbuffer(); writebyte(2); writebyte(global.myid); writeshort(x); writeshort(y); writeshort(sprite_index); writeshort(image_speed); writeshort(image_index); writeshort(image_angle); //tutaj poprostu bylo wpisac image_angle :P sendmessage(global.clienttcp); //Redo it alarm[0] = 1; Step clienta: GML /* ==================== */ /* -START- */ /* ==================== */ /* Receiving Messages */ /* ==================== */ //Create the variables to be used var messagesize, messageid; //Check for messages while(1) { //Receive the message using TCP messagesize = receivemessage(global.clienttcp); //If no message was received, break if (messagesize <= 0) break; //If a message was received, get the message ID... messageid = readbyte(); //Set the ping to 0 because we got a message ping = 0; //...and then use it to check what message it was switch(messageid) { //If the message ID is 1 case 1: //Store the message as our player ID global.myid = readbyte(); if end_game = true { clearbuffer(); writebyte(4); writestring(global.username+" can not join.",true); sendmessage(global.clienttcp); scr_online_gameend(); exit; } else { obj_player_self.alarm[0] = 1; } //And then break from the loop. If you forget this part then you might get errors. break; case 2: //Server is full message show_message("Sorry! The server is full."); if end_game = true { scr_online_gameend(); exit; } break; case 3: //New Player (create) var userid, name, user; userid = readbyte(); user = instance_create(obj_player_self.xstart,obj_player_self.ystart,obj_player_other); user.pid = userid; name = readstring(); user.username = name; players[userid] = user; script_addline(name + " has joined.",c_black); break; case 4: //New Player (chat message) var name, userid; userid = readbyte(); name = readstring(); user = players[userid]; user.username = name; script_addline(name + " has joined.",c_black); break; case 5: //Update other players' positions value = readbyte(); player = players[value]; player.x = readshort(); player.y = readshort(); player.sprite_index = readshort(); player.image_speed = readshort(); player.image_index = readshort(); player.image_angle = readshort(); // MUSISZ WYSYLAC I ODBIERAC WIADOMOSCI :P break; case 6: //Player left var playerid, username; playerid = readbyte(); username = readstring(); script_addline(username + " has left.",c_black); with(players[playerid]) { instance_destroy(); } players[playerid] = -1; break; case 7: //The server has shut down show_message("The server has shut down."); game_end(); break; case 8: //Chat message script_addline(readstring(),c_black); break; case 9: //Server message script_addline("Server: " + readstring(),c_red); break; } }
Yoda Opublikowano 29 Marca 2008 Opublikowano 29 Marca 2008 Hmmm to teraz powiedz mi dlaczego nagłówek wysyłanej wiadomości jest inny niż ten którym odbierasz te zmienne? ;>
Rekomendowane odpowiedzi
Jeśli chcesz dodać odpowiedź, zaloguj się lub zarejestruj nowe konto
Jedynie zarejestrowani użytkownicy mogą komentować zawartość tej strony.
Zarejestruj nowe konto
Załóż nowe konto. To bardzo proste!
Zarejestruj sięZaloguj się
Posiadasz już konto? Zaloguj się poniżej.
Zaloguj się