forked from Crown-Studio/roblox-ts-template
feat(chat): show welcome message and fix runtime dependency layout
This commit is contained in:
parent
db79746209
commit
ce9a6b2d85
|
|
@ -4,7 +4,8 @@
|
|||
"identifiers": {
|
||||
"crownstudio-roblox-ts-template:out/server/services/startup-service@StartupService": "server/services/startup-service@StartupService",
|
||||
"crownstudio-roblox-ts-template:out/client/controllers/cmdr-controller@CmdrController": "client/controllers/cmdr-controller@CmdrController",
|
||||
"crownstudio-roblox-ts-template:out/server/services/cmdr-service@CmdrService": "server/services/cmdr-service@CmdrService"
|
||||
"crownstudio-roblox-ts-template:out/server/services/cmdr-service@CmdrService": "server/services/cmdr-service@CmdrService",
|
||||
"crownstudio-roblox-ts-template:out/client/controllers/welcome-chat-controller@WelcomeChatController": "client/controllers/welcome-chat-controller@WelcomeChatController"
|
||||
},
|
||||
"metadata": {}
|
||||
}
|
||||
|
|
@ -1,3 +1,6 @@
|
|||
nodeLinker: hoisted
|
||||
shamefullyHoist: true
|
||||
|
||||
minimumReleaseAgeExclude:
|
||||
- "@typescript-eslint/eslint-plugin@8.71.2"
|
||||
- "@typescript-eslint/parser@8.71.2"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
import { Controller, OnStart } from "@flamework/core";
|
||||
import Log from "@rbxts/log";
|
||||
import { TextChatService } from "@rbxts/services";
|
||||
import { WELCOME_CHAT, WELCOME_CHAT_MESSAGE } from "shared/welcome-chat";
|
||||
|
||||
@Controller()
|
||||
export class WelcomeChatController implements OnStart {
|
||||
public onStart(): void {
|
||||
task.delay(WELCOME_CHAT.delaySeconds, () => this.displayWelcome());
|
||||
}
|
||||
|
||||
private displayWelcome(): void {
|
||||
const deadline = os.clock() + WELCOME_CHAT.channelTimeoutSeconds;
|
||||
const channels = TextChatService.WaitForChild(
|
||||
"TextChannels",
|
||||
WELCOME_CHAT.channelTimeoutSeconds,
|
||||
);
|
||||
const channel = channels?.WaitForChild("RBXGeneral", math.max(deadline - os.clock(), 0));
|
||||
|
||||
if (!channel?.IsA("TextChannel")) {
|
||||
Log.Warn("Welcome chat unavailable: RBXGeneral did not become ready before the timeout");
|
||||
return;
|
||||
}
|
||||
|
||||
channel.DisplaySystemMessage(WELCOME_CHAT_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
export const WELCOME_CHAT = {
|
||||
delaySeconds: 2,
|
||||
channelTimeoutSeconds: 30,
|
||||
colors: {
|
||||
heading: "#FFD166",
|
||||
text: "#F1F5FF",
|
||||
liked: "#5DE4A8",
|
||||
follow: "#74C7FF",
|
||||
hint: "#BDC6DC",
|
||||
},
|
||||
};
|
||||
|
||||
const colors = WELCOME_CHAT.colors;
|
||||
|
||||
export const WELCOME_CHAT_MESSAGE =
|
||||
`<font color="${colors.heading}"><b>✨ SUPPORT THE GAME ✨</b></font>\n` +
|
||||
`<font color="${colors.text}">If you like the game </font>` +
|
||||
`<font color="${colors.liked}"><b>👍 LIKED</b></font>` +
|
||||
`<font color="${colors.text}"> and </font>` +
|
||||
`<font color="${colors.follow}"><b>🔔 FOLLOW</b></font>\n`;
|
||||
Loading…
Reference in New Issue