haxball / haxball-issues

115 stars 43 forks source link

Problem with authentification (room.onPlayerJoin) #1099

Open ARLIIIND opened 4 years ago

ARLIIIND commented 4 years ago

Hello everyone, i need ur help. I made an authentication system by CLUB for a room between friends, I put several French clubs like Paris, Marseille, and others (a small example)

else if (["!setgdb", "!setgdb"].includes(message[0].toLowerCase())) { if (localStorage.getItem(getAuth(player)) && JSON.parse(localStorage.getItem(getAuth(player)))[Ss.RL] == "master") { if (message.length >= 2 && message[1][0] == "#") { message[1] = message[1].substring(1, message[1].length); if (!Number.isNaN(Number.parseInt(message[1])) && room.getPlayer(Number.parseInt(message[1])) != null) { var stats; localStorage.getItem(getAuth(room.getPlayer(Number.parseInt(message[1])))) ? stats = JSON.parse(localStorage.getItem(getAuth(room.getPlayer(Number.parseInt(message[1]))))) : stats = [0, 0, 0, 0, "0.00", 0, 0, 0, 0, "0.00", "player", room.getPlayer(Number.parseInt(message[1])).name]; if (stats[Ss.RL] == "player") { stats[Ss.RL] = "gdb"; localStorage.setItem(getAuth(room.getPlayer(Number.parseInt(message[1]))), JSON.stringify(stats)); room.sendAnnouncement(room.getPlayer(Number.parseInt(message[1])).name + " est maintenant un joueur de Bordeaux !", null, "0x16b77ff", "normal", 1); } } } } }

with this code i put an player on "Bordeaux" team, now the problem is the authentification (room.onplayerJoin) i have put this code:

`room.onPlayerJoin = function (player) {

extendedP.push([player.id, player.auth, player.conn, false, 0, 0, false]);

room.sendAnnouncement("⚽●▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬●●▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬●⚽", player.id, "0x48ff00", "bold", 1); room.sendAnnouncement("👋 wesh " + player.name + ", bienvenue dans ma room que g payé! Écris !help si tu veux de l'aide", player.id, "0x48ff00", "bold", 1); room.sendAnnouncement("🙌 Supporte ma room en installant tiktok avec mon lien pour que je la renouvelle:", player.id, "0x48ff00", "bold", 1); room.sendAnnouncement("➡️ https://vm.tiktok.com/J1gVnv3 (j'y gagne 5€ et toi t'y payes rien)", player.id, "0x48ff00", "small", 1); room.sendAnnouncement("⚽●▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬●●▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬●⚽", player.id, "0x48ff00", "bold", 1); if (localStorage.getItem(player.auth) != null) {

if (JSON.parse(localStorage.getItem(player.auth))[Ss.RL] != "player" && JSON.parse(localStorage.getItem(player.auth))[Ss.RL] != "master") { room.sendAnnouncement((JSON.parse(localStorage.getItem(player.auth))[Ss.RL] == "master" ? "Le chef " : "Le chef ") + player.name + " du VPS est là !", null, "0x16b77ff", "normal", 1);

} else if (JSON.parse(localStorage.getItem(player.auth))[Ss.RL] != "player" && JSON.parse(localStorage.getItem(player.auth))[Ss.RL] != "losc") { room.sendAnnouncement((JSON.parse(localStorage.getItem(player.auth))[Ss.RL] == "losc" ? "Le joueur " : "Le joueur ") + player.name + " de LOSC est arrivé !", null, "0x16b77ff", "normal", 1);

} else if (JSON.parse(localStorage.getItem(player.auth))[Ss.RL] != "player" && JSON.parse(localStorage.getItem(player.auth))[Ss.RL] != "psg") { room.sendAnnouncement((JSON.parse(localStorage.getItem(player.auth))[Ss.RL] == "psg" ? "Le joueur " : "Le joueur ") + player.name + " du PSG est arrivé !", null, "0x16b77ff", "normal", 1);

} else if (JSON.parse(localStorage.getItem(player.auth))[Ss.RL] != "player" && JSON.parse(localStorage.getItem(player.auth))[Ss.RL] != "om") { room.sendAnnouncement((JSON.parse(localStorage.getItem(player.auth))[Ss.RL] == "om" ? "Le joueur " : "Le joueur ") + player.name + " de l'OM est arrivé !", null, "0x16b77ff", "normal", 1);

} else if (JSON.parse(localStorage.getItem(player.auth))[Ss.RL] != "player" && JSON.parse(localStorage.getItem(player.auth))[Ss.RL] != "gdb") { room.sendAnnouncement((JSON.parse(localStorage.getItem(player.auth))[Ss.RL] == "gdb" ? "Le joueur " : "Le joueur ") + player.name + " de Bordeaux est arrivé !", null, "0x16b77ff", "normal", 1);

} else if (JSON.parse(localStorage.getItem(player.auth))[Ss.RL] != "player" && JSON.parse(localStorage.getItem(player.auth))[Ss.RL] != "tfc") { room.sendAnnouncement((JSON.parse(localStorage.getItem(player.auth))[Ss.RL] == "tfc" ? "Le joueur " : "Le joueur ") + player.name + " de Toulouse est arrivé !", null, "0x16b77ff", "normal", 1);

} else if (JSON.parse(localStorage.getItem(player.auth))[Ss.RL] != "player" && JSON.parse(localStorage.getItem(player.auth))[Ss.RL] != "nimes") { room.sendAnnouncement((JSON.parse(localStorage.getItem(player.auth))[Ss.RL] == "nimes" ? "Le joueur " : "Le joueur ") + player.name + " de Nimes est arrivé !", null, "0x16b77ff", "normal", 1);

} else if (JSON.parse(localStorage.getItem(player.auth))[Ss.RL] != "player" && JSON.parse(localStorage.getItem(player.auth))[Ss.RL] != "asm") { room.sendAnnouncement((JSON.parse(localStorage.getItem(player.auth))[Ss.RL] == "asm" ? "Le joueur " : "Le joueur ") + player.name + " de Monaco est arrivé !", null, "0x16b77ff", "normal", 1);

} else if (JSON.parse(localStorage.getItem(player.auth))[Ss.RL] != "player" && JSON.parse(localStorage.getItem(player.auth))[Ss.RL] != "asse") { room.setPlayerAdmin(player.id, true); room.sendAnnouncement((JSON.parse(localStorage.getItem(player.auth))[Ss.RL] == "asse" ? "Le joueur " : "Le joueur ") + player.name + " de l'ASSE est arrivé !", null, "0x16b77ff", "normal", 1); }

    }

}`

The problem is this:

When a master joins the room, instead of displaying the following message for him: "Le chef " + player.name + " du VPS est là !" the bot sends the club's message just below the "master" in the code "lille", so instead of saying that the chief is there, he's saying the message that the Lille player has arrived when he's not

And when a player from any club arrives, the bot says that the boss has arrived, (it sends the message from the master).

screenshots: (For a player who joins who is in a CLUB) https://prnt.sc/t730tv https://prnt.sc/t731gm

(For a room manager (master)) https://prnt.sc/t732cq https://prnt.sc/t733au <- example in my code

WARNING: When I put a player in a club (like in the screen with the ASM club), it works perfectly, it's just the welcome message that announces that the player from a club has arrived that doesn't work, that bugs: (for example The ARLIND player from monaco has just arrived)

It's a rather delicate problem, thanks to those who will help, I'm listening to you now.

ARLIIIND commented 4 years ago

@wohSi its okay