multiplayer gamego to layout

0 favourites
  • 11 posts
From the Asset Store
Template for a multiplayer card game, fully documented in comments and code
  • Hi all,

    I would like to ask you something, in my game I need to change layout with one click and enter another map. I modified the server as follows, except that it does not work. there is no way I tried endless possibilities, everything works fine in the first game layouts but if I change the map I can not see the movement of ships in the new map

    how can I do?

    /////////////////////////////////////////////

    var entities = [], count = 0;

    var io = require("socket.io").listen(8099);

    var INITIAL_X = 500;

    var INITIAL_Y = 500;

    var VITA = 20000;

    var SCUDO = 20000;

    var X= 14500;     

    var Y= 14500;

    io.set('log level', 1);

    io.sockets.on("connection", function (socket) {

    var myNumber = count++;

        

    //assegna numero    

        var mySelf = entities[myNumber] = [myNumber, INITIAL_X, INITIAL_Y, VITA, SCUDO,X,Y ];

    // UPDATE MESSAGE

    console.log("BENVENUTO UTENTE" + mySelf[0]);

        socket.on("message", function (data) {

           

           

           

            var new_data = data.split(',');

            if (new_data[0] == 'UM') {

                mySelf[1] = new_data[1];

                mySelf[2] = new_data[2]; //Astronave.X

                mySelf[3] = new_data[3]; //Astronave.Y

                mySelf[4] = new_data[4]; //Astronave.Angle

            mySelf[5] = new_data[5]; // Vita

                mySelf[6] = new_data[6]; // scudo

                mySelf[7] = new_data[7];

                mySelf[8] = new_data[8];

                mySelf[9] = new_data[9];

                mySelf[10] = new_data[10];

                mySelf[11] = new_data[11];

                mySelf[12] = new_data[12];

                mySelf[13] = new_data[14];

                //Update all the other clients about my update

                socket.broadcast.emit("message",

                   'UM,' + mySelf[0] + ',' + mySelf[1] + ',' + mySelf[2] + ',' + mySelf[3] + ',' + mySelf[4] + ',' + mySelf[5]

    + ',' + mySelf[6]+ ',' + mySelf[7]+ ',' + mySelf[8]);

    }

    // ENTRA IN MAPPA VRU

        if (new_data[0] == 'CAMBIOMAPPA') {

                

    //invia posizione inizale e ID ai nuovi utenti

                //Update all the other clients about my update

                socket.send('I,' + mySelf[0] + ',' + mySelf[1] + ',' + mySelf[2] +','+ mySelf[3] +','+ mySelf[4]+','+ mySelf[5] +','+ mySelf[6]);

    console.log('I,' + mySelf[0] + ',' + mySelf[1] + ',' + mySelf[2] +','+ mySelf[3] +','+ mySelf[4]+','+ mySelf[5] +','+ mySelf[6]);

    for (var entity_idx = 0; entity_idx < entities.length; entity_idx++) { //invia aggiornamento iniziale

            if (entity_idx != myNumber) {

                entity = entities[entity_idx];

                if (typeof (entity) != "undefined" && entity != null) {

                   socket.send('C,' + entity[0] + ',' + entity[1] + ',' + entity[2]   +','+ mySelf[3] +','+ mySelf[4]);

                     //inviare al client che si ? appena collegato la posizione di tutti gli altri client

               

    }

            }

        }

    socket.broadcast.emit("message",'C,' + mySelf[0] + ',' + mySelf[1] + ',' + mySelf[2] +','+ mySelf[3] +','+ mySelf[4]);

    console.log("message",'C,' + mySelf[0] + ',' + mySelf[1] + ',' + mySelf[2] +','+ mySelf[3] +','+ mySelf[4]);

    }

    // ENTRA IN MAPPA EIC

       if (new_data[0] == 'CAMBIOMAPPA2') {

                

    //invia posizione inizale e ID ai nuovi utenti

                //Update all the other clients about my update

                socket.send('I1,' + mySelf[0] + ',' + mySelf[1] + ',' + mySelf[2] +','+ mySelf[3] +','+ mySelf[4]+','+ mySelf[5] +','+ mySelf[6]);

    console.log('I1,' + mySelf[0] + ',' + mySelf[1] + ',' + mySelf[2] +','+ mySelf[3] +','+ mySelf[4]+','+ mySelf[5] +','+ mySelf[6]);

    for (var entity_idx = 0; entity_idx < entities.length; entity_idx++) { //invia aggiornamento iniziale

            if (entity_idx != myNumber) {

                entity = entities[entity_idx];

                if (typeof (entity) != "undefined" && entity != null) {

                   socket.send('C1,' + entity[0] + ',' + entity[1] + ',' + entity[2]   +','+ mySelf[3] +','+ mySelf[4]);

                     //inviare al client che si ? appena collegato la posizione di tutti gli altri client

               

    }

            }

        }

    socket.broadcast.emit("message",'C1,' + mySelf[0] + ',' + mySelf[1] + ',' + mySelf[2] +','+ mySelf[3] +','+ mySelf[4]);

    console.log("message",'C1,' + mySelf[0] + ',' + mySelf[1] + ',' + mySelf[2] +','+ mySelf[3] +','+ mySelf[4]);

    }

        var new_data = data.split(',');

           if (new_data[0] == 'UM2') {

                var io = [];

                io[1] = new_data[1]; //ID

                io[2] = new_data[2]; //Astronave.X

                io[3] = new_data[3]; //Astronave.Y

                io[4] = new_data[4]; //Astronave.Angle

            io[5] = new_data[5]; // Vita

                io[6] = new_data[6]; // scudo

                io[7] = new_data[7];

                io[8] = new_data[8];

                io[9] = new_data[9];

                io[10] = new_data[10];

                io[11] = new_data[11];

                io[12] = new_data[12];

                io[13] = new_data[14];

                //Update all the other clients about my update

    for (var entity_idx = 0; entity_idx < entities.length; entity_idx++) { //invia aggiornamento iniziale

            if (entity_idx != myNumber) {

                entity = entities[entity_idx];

                if (typeof (entity) != "undefined" && entity != null) {

                   socket.send('UM2,' + mySelf[0] + ',' + io[1] + ',' + io[2]   +','+ io[3] +','+ io[4]+ ',' + io[5]

    + ',' + io[6]+ ',' + io[7]+ ',' + io[8]);

                     //inviare al client che si ? appena collegato la posizione di tutti gli altri client

               

    }

            }

        }

                socket.broadcast.emit("message",

                   'UM2,'+mySelf[0]+ ',' +   io[1]+ ',' + io[2] + ',' + io[2] + ',' + io[3] + ',' + io[4] + ',' + io[5]

    + ',' + io[6]+ ',' + io[7]+ ',' + io[8]);

    console.log("message",

                   'UM2,'+ mySelf[0]+ ',' + io[1]+ ',' + io[2] + ',' + io[2] + ',' + io[3] + ',' + io[4] + ',' + io[5]

    + ',' + io[6]+ ',' + io[7]+ ',' + io[8]);

    }

        

            else if (new_data[0] == 'S') { // a s message

                var shoot_info = [];

                shoot_info[0] = new_data[1]; //ini x

                shoot_info[1] = new_data[2]; //ini y

                shoot_info[2] = new_data[3]; //degrees

                shoot_info[3] = new_data[4]; //DannoMissili

            shoot_info[4] = new_data[5];//IDTAG

                shoot_info[5] = new_data[6];//IDTAGAVV

                //Update all the other clients about my update

                socket.broadcast.emit("message",

                   'S,' + mySelf[0] + ',' + shoot_info[0] + ',' + shoot_info[1] + ',' + shoot_info[2]+ ',' + shoot_info[3]+ ',' + shoot_info[4]+ ',' + shoot_info[5]);

    console.log("message",

                   'S,' + mySelf[0] + ',' + shoot_info[0] + ',' + shoot_info[1] + ',' + shoot_info[2]+ ',' + shoot_info[3]+ ',' + shoot_info[4]+ ',' + shoot_info[5]);

    }

    else if (new_data[0] == 'DC') { //logout

                

                 socket.broadcast.emit("message",

                   'DC,' + mySelf[0] + ',' + mySelf[1] + ',' + mySelf[2] + ',' + mySelf[3] + ',' + mySelf[4]);

              delete entities[myNumber];

              console.log('>> ' + mySelf[0] + ' disconnected');

    }

    else if (new_data[0] == 'SLASER1') { // a s message

                var shoot_info1 = [];

                shoot_info1[0] = new_data[1]; //ini x

                shoot_info1[1] = new_data[2]; //ini y

                shoot_info1[2] = new_data[3]; //degrees

                shoot_info1[3] = new_data[4]; //DannoLaser

            shoot_info1[4] = new_data[5]; //IDTAG

                shoot_info1[5] = new_data[6]; //IDTAGAVV

                //Update all the other clients about my update

                socket.broadcast.emit("message",

                   'SLASER1,' + mySelf[0] + ',' + shoot_info1[0] + ',' + shoot_info1[1] + ',' + shoot_info1[2]+ ',' + shoot_info1[3]+ ',' + shoot_info1[4]+ ',' + shoot_info1[5]);

    console.log("message",

                   'SLASER1,' + mySelf[0] + ',' + shoot_info1[0] + ',' + shoot_info1[1] + ',' + shoot_info1[2]+ ',' + shoot_info1[3]+ ',' + shoot_info1[4]+ ',' + shoot_info1[5]);

    }

    else if (new_data[0] == 'SLASER2') { // a s message

                var shoot_info2 = [];

                shoot_info2[0] = new_data[1]; //ini x

                shoot_info2[1] = new_data[2]; //ini y

                shoot_info2[2] = new_data[3]; //degrees

                shoot_info2[3] = new_data[4]; //DannoLaser

            shoot_info2[4] = new_data[5]; //IDTAG

                shoot_info2[5] = new_data[6]; //IDTAG

                //Update all the other clients about my update

                socket.broadcast.emit("message",

                   'SLASER2,' + mySelf[0] + ',' + shoot_info2[0] + ',' + shoot_info2[1] + ',' + shoot_info2[2]+ ',' + shoot_info2[3]+ ',' + shoot_info2[4]+ ',' + shoot_info2[5]);

    console.log("message",

                   'SLASER2,' + mySelf[0] + ',' + shoot_info2[0] + ',' + shoot_info2[1] + ',' + shoot_info2[2]+ ',' + shoot_info2[3]+ ',' + shoot_info2[4]+ ',' + shoot_info2[5]);

    }

    else if (new_data[0] == 'SLASER3') { // a s message

                var shoot_info3 = [];

                shoot_info3[0] = new_data[1]; //ini x

                shoot_info3[1] = new_data[2]; //ini y

                shoot_info3[2] = new_data[3]; //degrees

                shoot_info3[3] = new_data[4]; //DannoLaser

            shoot_info3[4] = new_data[5]; //IDTag

                shoot_info3[5] = new_data[6]; //IDTagAVV

                //Update all the other clients about my update

                socket.broadcast.emit("message",

                   'SLASER3,' + mySelf[0] + ',' + shoot_info3[0] + ',' + shoot_info3[1] + ',' + shoot_info3[2]+ ',' + shoot_info3[3]+ ',' + shoot_info3[4]+ ',' + shoot_info3[5]);

    console.log("message",

                   'SLASER3,' + mySelf[0] + ',' + shoot_info3[0] + ',' + shoot_info3[1] + ',' + shoot_info3[2]+ ',' + shoot_info3[3]+ ',' + shoot_info3[4]+ ',' + shoot_info3[5]);

    }

    else if (new_data[0] == 'SLASER4') { // a s message

                var shoot_info4 = [];

                shoot_info4[0] = new_data[1]; //ini x

                shoot_info4[1] = new_data[2]; //ini y

                shoot_info4[2] = new_data[3]; //degrees

                shoot_info4[3] = new_data[4]; //DannoLaser

                shoot_info4[4] = new_data[5]; //idTag

                shoot_info4[5] = new_data[6]; //idTag

           

                //Update all the other clients about my update

                socket.broadcast.emit("message",

                   'SLASER4,' + mySelf[0] + ',' + shoot_info4[0] + ',' + shoot_info4[1] + ',' + shoot_info4[2]+ ',' + shoot_info4[3]+ ',' + shoot_info4[4]+ ',' + shoot_info4[5]);

    console.log("message",

                   'SLASER4,' + mySelf[0] + ',' + shoot_info4[0] + ',' + shoot_info4[1] + ',' + shoot_info4[2]+ ',' + shoot_info4[3]+ ',' + shoot_info4[4]+ ',' + shoot_info4[5]);

    }

    else if (new_data[0] == 'BOX') { // a BOX message

                var Box_info = [];

                Box_info[0] = new_data[1];

                Box_info[1] = new_data[2];

                Box_info[2] = new_data[3];

                Box_info[3] = new_data[4];

    Box_info[4] = new_data[5];

    Box_info[5] = new_data[6];

    Box_info[6] = new_data[7];

    Box_info[7] = new_data[8];

    Box_info[8] = new_data[9];

    Box_info[9] = new_data[10];

    Box_info[10] = new_data[11];

    Box_info[11] = new_data[12];

    Box_info[12] = new_data[13];

    Box_info[13] = new_data[14];

    Box_info[14] = new_data[15];

    Box_info[15] = new_data[16];

    Box_info[16] = new_data[17];

    Box_info[17] = new_data[18];

    Box_info[18] = new_data[19];

    Box_info[19] = new_data[20];

    Box_info[20] = new_data[21];

    Box_info[21] = new_data[22];

    Box_info[22] = new_data[23];

    Box_info[23] = new_data[24];

    Box_info[24] = new_data[25];

    Box_info[25] = new_data[26];

    Box_info[26] = new_data[27];

    Box_info[27] = new_data[28];

    Box_info[28] = new_data[29];

    Box_info[29] = new_data[30];

    Box_info[30] = new_data[31];

    Box_info[31] = new_data[32];

    Box_info[32] = new_data[33];

    Box_info[33] = new_data[34];

    Box_info[34] = new_data[35];

    Box_info[35] = new_data[36];

    Box_info[36] = new_data[37];

    Box_info[37] = new_data[38];

    Box_info[38] = new_data[39];

    Box_info[39] = new_data[40];

                //Update all the other clients about my update

                socket.broadcast.emit("message",

                   'BOX,' + Box_info[0] + ',' + Box_info[1] + ',' + Box_info[2]+ ',' + Box_info[3]+ ',' + Box_info[4]+ ',' + Box_info[5]

    + ',' + Box_info[6]+ ',' + Box_info[7]+ ',' + Box_info[8]+ ',' + Box_info[9]+ ',' + Box_info[10]+ ',' + Box_info[11]+ ',' + Box_info[12]

    + ',' + Box_info[13]+ ',' + Box_info[14]+ ',' + Box_info[15]+ ',' + Box_info[16]+ ',' + Box_info[17]+ ',' + Box_info[18]+ ',' + Box_info[19]

    + ',' + Box_info[20]+ ',' + Box_info[21]+ ',' + Box_info[22]+ ',' + Box_info[23]+ ',' + Box_info[24]+ ',' + Box_info[25]+ ',' + Box_info[26]

    + ',' + Box_info[27]+ ',' + Box_info[28]+ ',' + Box_info[29]+ ',' + Box_info[30]+ ',' + Box_info[31]+ ',' + Box_info[32]+ ',' + Box_info[33]

    + ',' + Box_info[34]+ ',' + Box_info[35]+ ',' + Box_info[36]+ ',' + Box_info[37]+ ',' + Box_info[38]+ ',' + Box_info[39]);

    }

       else if (new_data[0] == 'AlienSparo') { // a s message

                var Alienshoot_info = [];

                Alienshoot_info[0] = new_data[1]; //ini x

                Alienshoot_info[1] = new_data[2]; //ini y

                Alienshoot_info[2] = new_data[3]; //degrees

                Alienshoot_info[3] = new_data[4];

                //Update all the other clients about my update

                socket.broadcast.emit("message",

                   'AlienSparo,' + Alienshoot_info[0] + ',' + Alienshoot_info[1] + ',' + Alienshoot_info[2]+ ',' + Alienshoot_info[3]);

    }

         else if (new_data[0] == 'G') {

            var AlienInfo =[];

            AlienInfo[0] = new_data[1];//X

                AlienInfo[1] = new_data[2];//Y

                AlienInfo[2] = new_data[3];//ANGOLO

                AlienInfo[3] = new_data[4];//VITA

                AlienInfo[4] = new_data[5];//SCUDO

                AlienInfo[5] = new_data[6];//DANNO

                AlienInfo[6] = new_data[7];//ESPERIENZA

                AlienInfo[7] = new_data[8];//CREDITI

                AlienInfo[8] = new_data[9];//FAMA

    //Alieno2

            AlienInfo[9] = new_data[10];

                AlienInfo[10] = new_data[11];

                AlienInfo[11] = new_data[12];

                AlienInfo[12] = new_data[13];       

    //Alieno3

            AlienInfo[13] = new_data[14];

                AlienInfo[14] = new_data[15];

                AlienInfo[15] = new_data[16];

                AlienInfo[16] = new_data[17];

    //Alieno4

            AlienInfo[17] = new_data[18];

                AlienInfo[18] = new_data[19];

                AlienInfo[19] = new_data[20];

                AlienInfo[20] = new_data[21];       

    //Alieno5

            AlienInfo[21] = new_data[22];

                AlienInfo[22] = new_data[23];

                AlienInfo[23] = new_data[24];

                AlienInfo[24] = new_data[25];       

    //Alieno6

            AlienInfo[25] = new_data[26];

                AlienInfo[26] = new_data[27];

                AlienInfo[27] = new_data[28];

                AlienInfo[28] = new_data[29];

    //Alieno7

            AlienInfo[29] = new_data[30];

                AlienInfo[30] = new_data[31];

                AlienInfo[31] = new_data[32];

                AlienInfo[32] = new_data[33];       

    //Alieno8

            AlienInfo[33] = new_data[34];

                AlienInfo[34] = new_data[35];

                AlienInfo[35] = new_data[36];

                AlienInfo[36] = new_data[37];

    //Alieno9

            AlienInfo[37] = new_data[37];

                AlienInfo[38] = new_data[38];

                AlienInfo[39] = new_data[39];

                AlienInfo[40] = new_data[41];

    //Alieno10

            AlienInfo[41] = new_data[42];

                AlienInfo[42] = new_data[43];

                AlienInfo[43] = new_data[44];

                AlienInfo[44] = new_data[45];

    //Alieno11

            AlienInfo[45] = new_data[46];

                AlienInfo[46] = new_data[47];

                AlienInfo[47] = new_data[48];

                AlienInfo[48] = new_data[49];

    //Alieno12

            AlienInfo[49] = new_data[50];

                AlienInfo[50] = new_data[51];

                AlienInfo[51] = new_data[52];

                AlienInfo[52] = new_data[53];

    //Alieno13

            AlienInfo[53] = new_data[54];

                AlienInfo[54] = new_data[55];

                AlienInfo[55] = new_data[56];

                AlienInfo[56] = new_data[57];

    //Alieno14

            AlienInfo[57] = new_data[58];

                AlienInfo[58] = new_data[59];

                AlienInfo[59] = new_data[60];

                AlienInfo[60] = new_data[61];       

    //Alieno15

            AlienInfo[61] = new_data[62];

                AlienInfo[62] = new_data[63];

                AlienInfo[63] = new_data[64];

                AlienInfo[64] = new_data[65];       

    //Alieno16

            AlienInfo[65] = new_data[66];

                AlienInfo[66] = new_data[67];

                AlienInfo[67] = new_data[68];

                AlienInfo[68] = new_data[69];       

    //Alieno17

            AlienInfo[69] = new_data[70];

                AlienInfo[70] = new_data[71];

                AlienInfo[71] = new_data[72];

                AlienInfo[72] = new_data[73];

    //Alieno18

            AlienInfo[73] = new_data[74];

                AlienInfo[74] = new_data[75];

                AlienInfo[75] = new_data[76];

                AlienInfo[76] = new_data[77];

    //Alieno19

            AlienInfo[77] = new_data[78];

                AlienInfo[78] = new_data[79];

                AlienInfo[79] = new_data[80];

                AlienInfo[80] = new_data[81];

    //Alieno20

            AlienInfo[81] = new_data[82];

                AlienInfo[82] = new_data[83];

                AlienInfo[83] = new_data[84];

                AlienInfo[84] = new_data[85];       

           

            AlienInfo[85] = new_data[82];

                AlienInfo[86] = new_data[83];

                AlienInfo[87] = new_data[84];

                AlienInfo[88] = new_data[85];      

           

           

           

            AlienInfo[89] = new_data[90];

                AlienInfo[90] = new_data[91];

                AlienInfo[91] = new_data[92];

                AlienInfo[92] = new_data[93];

            AlienInfo[93] = new_data[94];

                AlienInfo[94] = new_data[95];

                AlienInfo[95] = new_data[96];

                AlienInfo[96] = new_data[97];

            AlienInfo[97] = new_data[98];

                AlienInfo[98] = new_data[99];

                AlienInfo[99] = new_data[100];

                AlienInfo[100] = new_data[101];

            AlienInfo[101] = new_data[102];

                AlienInfo[102] = new_data[103];

                AlienInfo[103] = new_data[104];

    //ID Alieni

                AlienInfo[104] = new_data[105];

                AlienInfo[105] = new_data[106];

                AlienInfo[106] = new_data[107];

                AlienInfo[107] = new_data[108];

                AlienInfo[108] = new_data[109];

                AlienInfo[109] = new_data[110];

                AlienInfo[110] = new_data[111];

                AlienInfo[111] = new_data[112];

                AlienInfo[112] = new_data[113];

                AlienInfo[113] = new_data[114];

                AlienInfo[114] = new_data[115];

                AlienInfo[115] = new_data[116];

                AlienInfo[116] = new_data[117];

                AlienInfo[117] = new_data[118];

                AlienInfo[118] = new_data[119];

                AlienInfo[119] = new_data[120];

                AlienInfo[120] = new_data[121];

                AlienInfo[121] = new_data[122];

                AlienInfo[122] = new_data[123];

                AlienInfo[123] = new_data[124];

           

           

           

           

                socket.broadcast.emit("message",

                   'G,' + AlienInfo[0] + ',' + AlienInfo[1] + ',' + AlienInfo[2]+ ',' + AlienInfo[3]+ ',' + AlienInfo[4]+ ',' + AlienInfo[5]+ ',' + AlienInfo[6]+ ',' + AlienInfo[7]+ ',' + AlienInfo[8]

    + ',' + AlienInfo[9] + ',' + AlienInfo[10]+ ',' + AlienInfo[11]+ ',' + AlienInfo[12]+ ',' + AlienInfo[13]+ ',' + AlienInfo[14]+ ',' + AlienInfo[15]+ ',' + AlienInfo[16]

    + ',' + AlienInfo[17] + ',' + AlienInfo[18]+ ',' + AlienInfo[19]+ ',' + AlienInfo[20]+ ',' + AlienInfo[21]+ ',' + AlienInfo[22]+ ',' + AlienInfo[23]+ ',' + AlienInfo[24]

    + ',' + AlienInfo[25] + ',' + AlienInfo[26]+ ',' + AlienInfo[27]+ ',' + AlienInfo[28]+ ',' + AlienInfo[29]+ ',' + AlienInfo[30]+ ',' + AlienInfo[31]+ ',' + AlienInfo[32]

    + ',' + AlienInfo[33] + ',' + AlienInfo[34]+ ',' + AlienInfo[35]+ ',' + AlienInfo[36]+ ',' + AlienInfo[37]+ ',' + AlienInfo[38]+ ',' + AlienInfo[39]+ ',' + AlienInfo[40]

    + ',' + AlienInfo[41] + ',' + AlienInfo[42]+ ',' + AlienInfo[43]+ ',' + AlienInfo[44]+ ',' + AlienInfo[45]+ ',' + AlienInfo[46]+ ',' + AlienInfo[47]+ ',' + AlienInfo[48]

    + ',' + AlienInfo[49] + ',' + AlienInfo[50]+ ',' + AlienInfo[51]+ ',' + AlienInfo[52]+ ',' + AlienInfo[53]+ ',' + AlienInfo[54]+ ',' + AlienInfo[55]+ ',' + AlienInfo[56]

    + ',' + AlienInfo[57] + ',' + AlienInfo[58]+ ',' + AlienInfo[59]+ ',' + AlienInfo[60]+ ',' + AlienInfo[61]+ ',' + AlienInfo[62]+ ',' + AlienInfo[63]+ ',' + AlienInfo[64]

    + ',' + AlienInfo[65] + ',' + AlienInfo[66]+ ',' + AlienInfo[67]+ ',' + AlienInfo[68]+ ',' + AlienInfo[69]+ ',' + AlienInfo[70]+ ',' + AlienInfo[71]+ ',' + AlienInfo[72]

    + ',' + AlienInfo[73] + ',' + AlienInfo[74]+ ',' + AlienInfo[75]+ ',' + AlienInfo[76]+ ',' + AlienInfo[77]+ ',' + AlienInfo[78]+ ',' + AlienInfo[79]+ ',' + AlienInfo[80]

    + ',' + AlienInfo[81] + ',' + AlienInfo[82]+ ',' + AlienInfo[83]+ ',' + AlienInfo[84]+ ',' + AlienInfo[85] + ',' + AlienInfo[86]+ ',' + AlienInfo[87]+ ',' + AlienInfo[88]

    + ',' + AlienInfo[89] + ',' + AlienInfo[90]+ ',' + AlienInfo[91]+ ',' + AlienInfo[92]+ ',' + AlienInfo[93] + ',' + AlienInfo[94]+ ',' + AlienInfo[95]+ ',' + AlienInfo[96]

    + ',' + AlienInfo[97] + ',' + AlienInfo[98]+ ',' + AlienInfo[99]+ ',' + AlienInfo[100]+ ',' + AlienInfo[101] + ',' + AlienInfo[102]+ ',' + AlienInfo[103]+ ',' + AlienInfo[104]

    + ',' + AlienInfo[105] + ',' + AlienInfo[106]+ ',' + AlienInfo[107]+ ',' + AlienInfo[108]+ ',' + AlienInfo[109] + ',' + AlienInfo[110]+ ',' + AlienInfo[111]+ ',' + AlienInfo[112]

    + ',' + AlienInfo[113] + ',' + AlienInfo[114]+ ',' + AlienInfo[115]+ ',' + AlienInfo[116]+ ',' + AlienInfo[117] + ',' + AlienInfo[118]+ ',' + AlienInfo[119]+ ',' + AlienInfo[120]

    + ',' + AlienInfo[121] + ',' + AlienInfo[122]+ ',' + AlienInfo[123]);

    }

    else if (new_data[0] == 'UV') {

            var AlienInf =[];

            AlienInf[0] = new_data[1];

                AlienInf[1] = new_data[2];

                AlienInf[2] = new_data[3];

                AlienInf[3] = new_data[4];

                AlienInf[4] = new_data[5];

                AlienInf[5] = new_data[6];

                AlienInf[6] = new_data[7];

                AlienInf[7] = new_data[8];

                AlienInf[8] = new_data[9];//FAMA

    //Alieno2

            AlienInf[9] = new_data[10];

                AlienInf[10] = new_data[11];

                AlienInf[11] = new_data[12];

                AlienInf[12] = new_data[13];

                AlienInf[13] = new_data[14];

                

    //Alieno3

                AlienInf[14] = new_data[15];

                AlienInf[15] = new_data[16];

                AlienInf[16] = new_data[17];

                AlienInf[17] = new_data[18];

            AlienInf[18] = new_data[19];

                                

    //Alieno4

            AlienInf[19] = new_data[20];

                AlienInf[20] = new_data[21];

                AlienInf[21] = new_data[22];

                AlienInf[22] = new_data[23];

                AlienInf[23] = new_data[24];

                                

    //Alieno5

                AlienInf[24] = new_data[25];

                AlienInf[25] = new_data[26];

                AlienInf[26] = new_data[27];

            AlienInf[27] = new_data[28];

                AlienInf[28] = new_data[29];

                                

    //Alieno6

                AlienInf[29] = new_data[30];

                AlienInf[30] = new_data[31];

                AlienInf[31] = new_data[32];

                AlienInf[32] = new_data[33];

                AlienInf[33] = new_data[34];

                            

    //Alieno7

                AlienInf[34] = new_data[35];

                AlienInf[35] = new_data[36];

            AlienInf[36] = new_data[37];

                AlienInf[37] = new_data[38];

                AlienInf[38] = new_data[39];

                         

    //Alieno8

                AlienInf[39] = new_data[40];

                AlienInf[40] = new_data[41];

                AlienInf[41] = new_data[42];

                AlienInf[42] = new_data[43];

                AlienInf[43] = new_data[44];

                                

    //Alieno9

                AlienInf[44] = new_data[45];

            AlienInf[45] = new_data[46];

                AlienInf[46] = new_data[47];

                AlienInf[47] = new_data[48];

                AlienInf[48] = new_data[49];

                                

    //Alieno10

                AlienInf[49] = new_data[50];

                AlienInf[50] = new_data[51];

                AlienInf[51] = new_data[52];

                AlienInf[52] = new_data[53];

                AlienInf[53] = new_data[54];     

                               

    //Alieno11

                AlienInf[54] = new_data[55];

                AlienInf[55] = new_data[56];

                AlienInf[56] = new_data[57];

                AlienInf[57] = new_data[58];

                AlienInf[58] = new_data[59];

                                

    //Alieno12

            AlienInf[99] = new_data[100];

                AlienInf[100] = new_data[101];

                AlienInf[101] = new_data[102];

                AlienInf[102] = new_data[103];

                AlienInf[103] = new_data[104];

                AlienInf[104] = new_data[105];

                AlienInf[105] = new_data[106];

                AlienInf[106] = new_data[107];

                AlienInf[107] = new_data[108];                  

    //Alieno13

            AlienInf[108] = new_data[1];

                AlienInf[109] = new_data[2];

                AlienInf[110] = new_data[3];

                AlienInf[111] = new_data[4];

                AlienInf[112] = new_data[5];

                AlienInf[113] = new_data[6];

                AlienInf[114] = new_data[11];

                AlienInf[115] = new_data[118];

                AlienInf[116] = new_data[117];                  

    //Alieno14

            AlienInf[59] = new_data[60];

                AlienInf[60] = new_data[61];

                AlienInf[61] = new_data[62];

                AlienInf[62] = new_data[63];       

            AlienInf[63] = new_data[64];

                         

    //Alieno15

            AlienInf[64] = new_data[65];

                AlienInf[65] = new_data[66];

                AlienInf[66] = new_data[67];

                AlienInf[67] = new_data[68];

                AlienInf[68] = new_data[69];

                                   

    //Alieno16

            AlienInf[69] = new_data[70];

                AlienInf[70] = new_data[71];

                AlienInf[71] = new_data[72];

            AlienInf[72] = new_data[73];

                AlienInf[73] = new_data[74];

                         

    //Alieno17

            AlienInf[74] = new_data[75];

                AlienInf[75] = new_data[76];

                AlienInf[76] = new_data[77];

                AlienInf[77] = new_data[78];

                AlienInf[78] = new_data[79];

                               

    //Alieno18

            AlienInf[79] = new_data[80];

                AlienInf[80] = new_data[81];

            AlienInf[81] = new_data[82];

                AlienInf[82] = new_data[83];

                AlienInf[83] = new_data[84];

                                

    //Alieno19

            AlienInf[84] = new_data[85];

                AlienInf[85] = new_data[86];

                AlienInf[86] = new_data[87];

                AlienInf[87] = new_data[88];

                AlienInf[88] = new_data[89];

                            

    //Alieno20

            AlienInf[89] = new_data[90];

            AlienInf[90] = new_data[91];

                AlienInf[91] = new_data[92];

                AlienInf[92] = new_data[93];

                AlienInf[93] = new_data[94];

                              

                      

                socket.broadcast.emit("message",

                   'UV,' + AlienInf[0] + ',' + AlienInf[1] + ',' + AlienInf[2]+ ',' + AlienInf[3]+ ',' + AlienInf[4]+ ',' + AlienInf[5]

    + ',' + AlienInf[6]+ ',' + AlienInf[7]+ ',' + AlienInf[8]+',' + AlienInf[9]+ ',' + AlienInf[10] + ',' + AlienInf[11]+ ',' + AlienInf[12]+ ',' + AlienInf[13]+ ',' + AlienInf[14]

    + ',' + AlienInf[15]+ ',' + AlienInf[16]+ ',' + AlienInf[17]+',' + AlienInf[18]+ ',' + AlienInf[19] + ',' + AlienInf[20]+ ',' + AlienInf[21]+ ',' + AlienInf[22]+ ',' + AlienInf[23]

    + ',' + AlienInf[24]+ ',' + AlienInf[25]+ ',' + AlienInf[26]+',' + AlienInf[27]+ ',' + AlienInf[28] + ',' + AlienInf[29]+ ',' + AlienInf[30]+ ',' + AlienInf[31]+ ',' + AlienInf[32]

    + ',' + AlienInf[33]+ ',' + AlienInf[34]+ ',' + AlienInf[35]+',' + AlienInf[36]+ ',' + AlienInf[37] + ',' + AlienInf[38]+ ',' + AlienInf[39]+ ',' + AlienInf[40]+ ',' + AlienInf[41]

    + ',' + AlienInf[42]+ ',' + AlienInf[43]+ ',' + AlienInf[44]+',' + AlienInf[45]+ ',' + AlienInf[46] + ',' + AlienInf[47]+ ',' + AlienInf[48]+ ',' + AlienInf[49]+ ',' + AlienInf[50]

    + ',' + AlienInf[51]+ ',' + AlienInf[52]+ ',' + AlienInf[53]+',' + AlienInf[54]+ ',' + AlienInf[55] + ',' + AlienInf[56]+ ',' + AlienInf[57]+ ',' + AlienInf[58]+ ',' + AlienInf[59]

    + ',' + AlienInf[60]+ ',' + AlienInf[61]+ ',' + AlienInf[62]+',' + AlienInf[63]+ ',' + AlienInf[64] + ',' + AlienInf[65]+ ',' + AlienInf[66]+ ',' + AlienInf[67]+ ',' + AlienInf[68]

    + ',' + AlienInf[69]+ ',' + AlienInf[70]+ ',' + AlienInf[71]+',' + AlienInf[72]+ ',' + AlienInf[73] + ',' + AlienInf[74]+ ',' + AlienInf[75]+ ',' + AlienInf[76]+ ',' + AlienInf[77]

    + ',' + AlienInf[78]+ ',' + AlienInf[79]+ ',' + AlienInf[80]+',' + AlienInf[81]+ ',' + AlienInf[82] + ',' + AlienInf[83]+ ',' + AlienInf[84]+ ',' + AlienInf[85]+ ',' + AlienInf[86]

    + ',' + AlienInf[87]+ ',' + AlienInf[88]+ ',' + AlienInf[89]+',' + AlienInf[90]+ ',' + AlienInf[91] + ',' + AlienInf[92]+ ',' + AlienInf[93] );

       

    }     

    else if (new_data[0] == 'UM-BOX') {

            var BOX =[];

            BOX[0] = new_data[1];

                BOX[1] = new_data[2];

                BOX[2] = new_data[3];

                BOX[3] = new_data[4];

                BOX[4] = new_data[5];

                BOX[5] = new_data[6];

                BOX[6] = new_data[7];

                BOX[7] = new_data[8];

                BOX[8] = new_data[9];

                BOX[9] = new_data[10];

                BOX[10] = new_data[11];

                BOX[11] = new_data[12];

                BOX[12] = new_data[13];

                BOX[13] = new_data[14];

                BOX[14] = new_data[15];

                BOX[15] = new_data[16];

                BOX[16] = new_data[17];

                BOX[17] = new_data[18];

                BOX[18] = new_data[19];

                BOX[19] = new_data[20];

                BOX[20] = new_data[21];

                BOX[21] = new_data[22];

                BOX[22] = new_data[23];

                BOX[23] = new_data[24];

            BOX[24] = new_data[25];

                BOX[25] = new_data[26];

                BOX[26] = new_data[27];

                BOX[27] = new_data[28];

                BOX[28] = new_data[29];

                BOX[29] = new_data[30];

                BOX[30] = new_data[31];

                BOX[31] = new_data[32];

            BOX[32] = new_data[33];

                BOX[33] = new_data[34];

                BOX[34] = new_data[35];

                BOX[35] = new_data[36];

                BOX[36] = new_data[37];

                BOX[37] = new_data[38];

                BOX[38] = new_data[39];

                BOX[39] = new_data[40];

                socket.broadcast.emit("message",

                   'UM-BOX,' + BOX[0] + ',' + BOX[1] + ',' + BOX[2]+ ',' + BOX[3]+ ',' + BOX[4]+ ',' + BOX[5]+ ',' + BOX[6]+ ',' +

    BOX[7]+ ',' + BOX[8] + ',' + BOX[9]+ ',' + BOX[10]+ ',' + BOX[11]+ ',' + BOX[12]+ ',' + BOX[13]+ ',' +

    BOX[14]+ ',' + BOX[15] + ',' + BOX[16]+ ',' + BOX[17]+ ',' + BOX[18]+ ',' + BOX[19]+ ',' + BOX[20]+ ',' +

    BOX[21]+ ',' + BOX[22] + ',' + BOX[23]+ ',' + BOX[24]+ ',' + BOX[25]+ ',' + BOX[26]+ ',' + BOX[27]+ ',' +

    BOX[28]+ ',' + BOX[29] + ',' + BOX[30]+ ',' + BOX[31]+ ',' + BOX[32]+ ',' + BOX[33]+ ',' + BOX[34]+ ',' +

    BOX[35]+ ',' + BOX[36] + ',' + BOX[37]+ ',' + BOX[38]+ ',' + BOX[39]);

    }     

        });

    socket.on('disconnect', function (data) {

          

          socket.broadcast.emit("message",'DC,' + mySelf[0] + ',' + mySelf[1] + ',' + mySelf[2]);

          delete entities[myNumber];

    console.log("message",'DC,' + mySelf[0] + ',' + mySelf[1] + ',' + mySelf[2]);

          

    });

    });

    the alien is moved by a simple virtual machine made in c2,

  • any idea on how can I do that or is this a bug in C2

  • i do a simple test.

    i change the event on j click go to layout 5 in:

    on j click restart layout(only for a test)

    and what happens is that: the first client is able to see the second client, while the second one does not see the first one.

    the same thing happens even when changing layout.

    WHY????? <img src="smileys/smiley19.gif" border="0" align="middle" /> <img src="smileys/smiley19.gif" border="0" align="middle" /> <img src="smileys/smiley19.gif" border="0" align="middle" />

    is the most important step of the game, a fact the game is over

    <img src="smileys/smiley7.gif" border="0" align="middle" /> <img src="smileys/smiley7.gif" border="0" align="middle" />

  • I'm afraid the server side programming is out of the scope of these forums.

    If the two clients don't sync, there might be an issue in the code of your server that handles this part, or in the code of the client.

    As far as client (C2) goes, it's impossible to tell as you haven't posted the source (capx) for us to check out.

    You might want to seek help on the official website of your server (node.js I presume) too (especially if the issue is server side).

  • how can i post the capx? it is 16megabyte

  • So at this time I tried to do this: put a variable retrieved from the database in which I point to the company appartanenza the player, click on ok, if diita equals 1 go to mars layout, if the company is 2 go on layout venus, everything works fine, new users must mars mars in layout and are perfectly synchronized, those venus as well.

    No what I can do is: click on j go to layout if you are mars venus,

    changing layout is. what does not happen is that when changing the layout who is already in the map venus or mars sees the new user entered into while the new map does not see those already present in this map.

  • SOLVED <img src="smileys/smiley32.gif" border="0" align="middle" /> <img src="smileys/smiley32.gif" border="0" align="middle" /> <img src="smileys/smiley32.gif" border="0" align="middle" /> <img src="smileys/smiley32.gif" border="0" align="middle" /> <img src="smileys/smiley32.gif" border="0" align="middle" /> <img src="smileys/smiley4.gif" border="0" align="middle" /> <img src="smileys/smiley4.gif" border="0" align="middle" /> <img src="smileys/smiley4.gif" border="0" align="middle" />

  • any idea on how can I do that or is this a bug in C2

    I don't think you can blame Construct 2! The fault must lie in your server-side code. You need to work through standard debugging processes to track down your error.

    BTW, the code you have posted is extremely badly-written! You should be using arrays and loops instead of all those simple repeated assignments - there's plenty of room for errors to creep in there!

  • > any idea on how can I do that or is this a bug in C2

    I don't think you can blame Construct 2! The fault must lie in your server-side code. You need to work through standard debugging processes to track down your error.

    BTW, the code you have posted is extremely badly-written! You should be using arrays and loops instead of all those simple repeated assignments - there's plenty of room for errors to creep in there!

    yes velojet,

    infact i'm a carpenter.

    have you an idea on how can i do that? i solved the problem but it don't work too well.

    can you give me a guide?

    but hey it work....

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • > any idea on how can I do that or is this a bug in C2

    I don't think you can blame Construct 2! The fault must lie in your server-side code. You need to work through standard debugging processes to track down your error.

    BTW, the code you have posted is extremely badly-written! You should be using arrays and loops instead of all those simple repeated assignments - there's plenty of room for errors to creep in there!

    i try to change all on my server and on c2 using only one message for Alien Login and alien update position angle health shield ecc, I use a foreach loop order by Alien ID but I've 60 aliens on one map 60 alien on second map 40 bonus box on first and 40 on second map but all of the alien's movement are very veeeeery slow with the first server code does not happen why????

    this is a simple request i've no problem with the old code

  • We are but on the same boat.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)