Skip to content

Commit 838e2ac

Browse files
broadcast msg function
1 parent 9f91b92 commit 838e2ac

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Game.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export default class GameServer {
147147
this.arena = new ArenaClass(this);
148148

149149
this._tickInterval = setInterval(() => {
150-
if (this.clients.size) this.tickLoop();
150+
if (this.clients.size) this.tickLoop(); // Don't tick empty games
151151
}, config.mspt);
152152
}
153153

@@ -159,6 +159,10 @@ export default class GameServer {
159159
public broadcastPlayerCount() {
160160
this.broadcast().vu(ClientBound.PlayerCount).vu(GameServer.globalPlayerCount).send();
161161
}
162+
/** Sends a notification to all clients connected to this game server. */
163+
public broadcastMessage(text: string, color = 0x000000, time = 5000, id = "") {
164+
this.broadcast().u8(ClientBound.Notification).stringNT(text).u32(color).float(time).stringNT(id).send();
165+
}
162166

163167
/** Ends the game instance. */
164168
public end() {

0 commit comments

Comments
 (0)