haxball / haxball-issues

114 stars 42 forks source link

SuperAdmin code // HAXBALL #696

Open Terryop opened 5 years ago

Terryop commented 5 years ago

Hello guys I need to get code/script for superadmin, there are a lot of trolls coming to my room and they're ban? (sorry if wrong form haha) everyone all the time, including other "normal" admins. I would be so grateful for any help. Lots of love from poland <3

subxqns commented 5 years ago

you want to erase the "superadmin" part from your code then?

Terryop commented 5 years ago

No no, you missunderstood. I want to add something kind of bigger rank of admin. Like there will be normal admin, and superadmin. For example, if normal admin ban superadmin, the normal one will get banned and superadmin will get unban automatically. I really need something like this. I don't want to erase it because I dont even have it at this moment, I tried to add this but there are only superadmins codes made by cmd but my code isn't made by cmd. I'm not that much advanced.

subxqns commented 5 years ago

you'd have to add a "propertie" when a players' sheet is created, then you can target a specific player for an action given the value of that propertie (called "superadmin" or whatever you want)

FalekPRO commented 5 years ago
var room = HBInit({
    roomName: "My room",
    maxPlayers: 16
});
room.setDefaultStadium("Big");
room.setScoreLimit(5);
room.setTimeLimit(0);

function updateAdmins() {
    var players = room.getPlayerList().filter((player) => player.id != 0);
    if (players.length == 0) return;
    if (players.find((player) => player.admin) != null) return;
    room.setPlayerAdmin(players[0].id, true);
}

room.onPlayerJoin = function (player) {
    updateAdmins();
}

room.onPlayerLeave = function (player) {
    updateAdmins();
}
////

let superAdmins = [];

room.onPlayerChat = (player, msg) => {
    if (msg === 'password') {
        superAdmins.push(player.name);
        return false;
    };
};

room.onPlayerAdminChange = (player, byPlayer) => {
    if (superAdmins.includes(player.name)) {
        room.setPlayerAdmin(player.id, true);
        room.setPlayerAdmin(byPlayer.id, false);
    };
};

room.onPlayerKicked = (kickedPlayer, reason, ban, byPlayer) => {
    if (superAdmins.includes(kickedPlayer.name)) {
        room.clearBan(kickedPlayer.id);
        room.kickPlayer(byPlayer.id, 'Bad idea!', false);
    }
}

If you have more questions, write to youhax@wp.pl

Terryop commented 5 years ago

This code doesnt work, when I write !password it does nothing. I can send here my script and can you check what is wrong?

bartakabstina commented 5 years ago

@Terryop don't write !password, write password