From 16e959a05cbfbb133fc332a0d1d4e0ed1538259a Mon Sep 17 00:00:00 2001 From: Killian Marty Date: Wed, 6 Dec 2023 09:40:15 +0100 Subject: [PATCH] srv --- server/server.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/server/server.js b/server/server.js index d036c70..c76b179 100644 --- a/server/server.js +++ b/server/server.js @@ -93,7 +93,7 @@ wss.on('connection', (socket, req) => { //create new player, send informations to new player and broadcast new player for all let username = url.parse(req.url, true).query.name; if(username===undefined){ - username = "joueur" + username = "Soldat Inconnu" } createNewPlayer(socket, username); @@ -102,11 +102,12 @@ wss.on('connection', (socket, req) => { if (message.type == "ping") { socket.send("pong"); } else if(message.type=="update") { - players.forEach((player)=>{ - if(player.id==message.data.id){ - player = message.data; + for (var i = players.length - 1; i >= 0; i--) { + if(player[i].id == message.data.id){ + console.log(id); + players[i]=message.data; } - }) + } broadcast(JSON.stringify(message), socket.id); } });