-- name: Announcements v1.0 -- description: use /a (text) for custom announcements for your server By: \\#00faf6\\k\\#00b3fa\\i\\#0075fa\\k\\#af00fa\\w\\#cc00fa\\e\\#f200fa\\e --sync-- if not gGlobalSyncTable.announcementTimer then gGlobalSyncTable.announcementTimer = 0 end if not gGlobalSyncTable.announcementMessage then gGlobalSyncTable.announcementMessage = "Test Announcement!" end --variables-- local POPUP_DURATION = 6 * 60 -- 15 seconds at 60 FPS local D_JPAD = 0x0400 --command-- local function mario_update(m) if m.playerIndex ~= 0 then return end if (m.controller.buttonPressed & D_JPAD) ~= 0 then gGlobalSyncTable.announcementMessage = "Test Announcement!" gGlobalSyncTable.announcementTimer = POPUP_DURATION end end local function on_announcement_command(msg) local text = string.sub(msg, 1) if text and text ~= "" then gGlobalSyncTable.announcementMessage = text gGlobalSyncTable.announcementTimer = POPUP_DURATION return true else djui_chat_message_create("Usage: /a (your message here)") return true end end --timer+hud-- local function on_hud_render() if gGlobalSyncTable.announcementTimer > 0 then djui_hud_set_resolution(RESOLUTION_N64) djui_hud_set_font(FONT_MENU) djui_hud_set_color(255, 255, 255, 255) -- White text local text = gGlobalSyncTable.announcementMessage local text_width = djui_hud_measure_text(text) * 0.1 local screen_center_x = 420 / 2 -- 160 local x = screen_center_x - (text_width / 2) local y = 50 -- Distance from top of screen djui_hud_print_text(text, x, y, 0.1) if network_is_server() then gGlobalSyncTable.announcementTimer = gGlobalSyncTable.announcementTimer - 1 end end end --hooks-- hook_event(HOOK_MARIO_UPDATE, mario_update) hook_event(HOOK_ON_HUD_RENDER, on_hud_render) hook_chat_command("a", "Display a custom announcement message", on_announcement_command)