Advertisement
Guest User

Untitled

a guest
Jun 11th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Banchojs = require("bancho.js");
  2. const client = new Banchojs.BanchoClient(require("./config.json"));
  3.  
  4. const beatmaps = [1262832, 1378285, 1385398, 1373950];
  5. let currentBeatmapIndex = 0;
  6. let lobby;
  7.  
  8. client.connect().then(async () => {
  9.     console.log("We're online!");
  10.     const channel = await client.createLobby("Multiplayer rotator "+Math.random().toString(36).substring(8));
  11.     lobby = channel.lobby;
  12.     const password = Math.random().toString(36).substring(8);
  13.     await Promise.all([lobby.setPassword(password), lobby.setMap(beatmaps[currentBeatmapIndex])]);
  14.     console.log("Lobby created! Name: "+lobby.name+", password: "+password);
  15.     console.log("Multiplayer link: https://osu.ppy.sh/mp/"+lobby.id);
  16.  
  17.     // This is the key line:
  18.     lobby.setSettings(Banchojs.BanchoLobbyTeamModes.TeamVs, Banchojs.BanchoLobbyWinConditions.Score);
  19.  
  20.     lobby.on("playerJoined", (obj) => {
  21.         if(obj.player.user.isClient())
  22.             lobby.setHost("#"+obj.player.user.id);
  23.     });
  24.     lobby.on("matchFinished", () => {
  25.         currentBeatmapIndex++;
  26.         if(currentBeatmapIndex == beatmaps.length)
  27.             currentBeatmapIndex = 0;
  28.         lobby.setMap(beatmaps[currentBeatmapIndex]);
  29.     });
  30. }).catch(console.error);
  31.  
  32. process.on("SIGINT", async () => {
  33.     console.log("Closing lobby and disconnecting...");
  34.     await lobby.closeLobby();
  35.     await client.disconnect();
  36. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement