Last active
June 24, 2019 16:25
-
-
Save dixtel/f6ad376bf3ac6f9fe34bb8fc65d4b18e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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