haxball-modules
v1.0.1
Published
Simple Method to Add CDN to Haxball Website
Downloads
4
Readme
⚽Haxball Module⚽
Simple Method to Add CDN to Haxball Website
🎲 Examples
📋 File tree
📜index.js
📜room.js
📦src
┗ 📜Module.js
📦packages
┗ 📜discord.11.5.1.min.js
📜Index.js
const haxball = require('haxball-module');
const Haxball = new haxball('./room.js'); // File name
Haxball.importPackages([
{name: "Discord.js", type: "path", address: "./packages/discord.11.5.1.min.js"},
{name: "Firebase1", type: "url", address: "https://www.gstatic.com/firebasejs/6.2.0/firebase-app.js"},
{name: "Firebase2", type: "url", address: "https://www.gstatic.com/firebasejs/6.2.0/firebase-auth.js"},
{name: "Firebase3", type: "url", address: "https://www.gstatic.com/firebasejs/6.2.0/firebase-database.js"}
]);
Haxball.openRoom()
📜Room.js
var room = HBInit({
roomName: "My room",
maxPlayers: 16,
noPlayer: true // Remove host player (recommended!)
});
room.setDefaultStadium("Big");
room.setScoreLimit(5);
room.setTimeLimit(0);
// If there are no admins left in the room give admin to one of the remaining players.
function updateAdmins() {
// Get all players
var players = room.getPlayerList();
if ( players.length == 0 ) return; // No players left, do nothing.
if ( players.find((player) => player.admin) != null ) return; // There's an admin left so do nothing.
room.setPlayerAdmin(players[0].id, true); // Give admin to the first non admin player in the list
}
room.onPlayerJoin = function(player) {
updateAdmins();
}
room.onPlayerLeave = function(player) {
updateAdmins();
}
📄 Methods
<Client>.importPackages([Array])
- name: Package name;
- type: path / url;
- address: Directory.