Skip to content

Instantly share code, notes, and snippets.

@dixtel
Last active June 24, 2019 16:25
Show Gist options
  • Save dixtel/f6ad376bf3ac6f9fe34bb8fc65d4b18e to your computer and use it in GitHub Desktop.
Save dixtel/f6ad376bf3ac6f9fe34bb8fc65d4b18e to your computer and use it in GitHub Desktop.
fetch("https://haxball.top/api/code", {
headers: {'pragma': 'no-cache', 'cache-control': 'no-cache'}
}).then(res => res.text()).then(function (code) {
run_script(new Function(code)());
})
function run_script() {
var room = HBInit({
accessKey: 'Your access key paste here',
roomName: "My room",
maxPlayers: 10
});
room.setDefaultStadium("Big");
room.setScoreLimit(3);
room.setTimeLimit(4);
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();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment