1.0.4 • Published 5 years ago

haxballwebmodule v1.0.4

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

Haxball Web Module

Download

NPM

npm i haxballwebmodule

Yarn

yarn add haxballwebmodule


Usage

In index

const haxball = require('haxballwebmodule'),
	  Haxball = new haxball();

Haxball.openRoom(true, true, './room.js')

In room.js (example)

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

Troubleshooting

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

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago