From 33f643642aaf424ae21d775d60382c05e2414a11 Mon Sep 17 00:00:00 2001 From: catvayor Date: Sun, 11 Jun 2023 17:42:48 +0200 Subject: [PATCH] vieux receive state change from admin --- traque.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/traque.js b/traque.js index 3252146..f6dce87 100644 --- a/traque.js +++ b/traque.js @@ -2,10 +2,11 @@ { "id" : string, "pos" : [lat : float, long : float], + "vieux": bool, "state" : { "shown" : bool, "tracker" : bool, - "npc" : bool + "npc" : int } } @@ -182,6 +183,7 @@ function default_team(team_id, valid) { state.tracker = false; state.npc = valid; equipe.state = state; + equipe.vieux = valid == 1; equipe.pos = [0,0]; equipe.id = team_id; return equipe; @@ -261,7 +263,9 @@ io.on('connection', function(socket){ socket.on('setState', function(d){ equipes[d.id].state = d.state; - emit_update(d.id);//TODO update vieux + emit_update(d.id); + if(equipes[d.id].vieux) + io.to(d.id).emit('newState', d.state); }); for(i in equipes){