1.0.1 • Published 4 years ago

haxballwebmodule-firebase v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

Haxball Web Module (Firebase)

Download

NPM

npm i haxballwebmodule-firebase

Yarn

yarn add haxballwebmodule-firebase


Usage

In index

const haxball = require('haxballwebmodule-firebase'),
	  Haxball = new haxball('./room.js');

Haxball.openRoom()

In room.js (example)

var firebaseConfig = {
    apiKey: "",
    authDomain: "",
    databaseURL: "",
    projectId: "",
    storageBucket: "",
    messagingSenderId: "",
    appId: ""
};

firebase.initializeApp(firebaseConfig)

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();
}

Linux(Debian) - Commands

  • sudo apt install xfce4
  • sudo npm i puppeteer

Troubleshooting

  • Haxball API May Be OFFLINE
  • Room file not found
  • Machine without internet connection
  • If you get another error, install chromium: Download
1.0.1

4 years ago

1.0.0

4 years ago