Created
October 12, 2025 13:37
-
-
Save VapidLinus/e8595e9ef26d244d9787a82c21f425a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import InventorySlots = mod.InventorySlots; | |
| let now = 0; | |
| const tickRate = 0.032; | |
| export async function OnGameModeStarted() { | |
| TickUpdate(); | |
| } | |
| async function TickUpdate() { | |
| while (true) { | |
| await mod.Wait(tickRate); | |
| now = new Date().getTime() / 1000; | |
| } | |
| } | |
| let nextCheckTime = 0; | |
| const checkInterval = 6; | |
| export function OngoingPlayer(player: mod.Player) { | |
| // Throttle messages so an infinite queue isn't built up | |
| if (now < nextCheckTime) return; | |
| nextCheckTime = now + checkInterval; | |
| const slot = getActiveInventorySlots(player); | |
| if (slot !== null) { | |
| const slotName = getInventorySlotName(slot); | |
| const msg = mod.Message(slotName); | |
| mod.DisplayNotificationMessage(msg); | |
| } else { | |
| mod.ForceSwitchInventory(player, InventorySlots.MeleeWeapon); | |
| } | |
| } | |
| function getActiveInventorySlots(player: mod.Player): InventorySlots | null { | |
| if (mod.IsInventorySlotActive(player, InventorySlots.ClassGadget)) | |
| return InventorySlots.ClassGadget; | |
| if (mod.IsInventorySlotActive(player, InventorySlots.GadgetOne)) | |
| return InventorySlots.GadgetOne; | |
| if (mod.IsInventorySlotActive(player, InventorySlots.GadgetTwo)) | |
| return InventorySlots.GadgetTwo; | |
| if (mod.IsInventorySlotActive(player, InventorySlots.MeleeWeapon)) | |
| return InventorySlots.MeleeWeapon; | |
| if (mod.IsInventorySlotActive(player, InventorySlots.MiscGadget)) | |
| return InventorySlots.MiscGadget; | |
| if (mod.IsInventorySlotActive(player, InventorySlots.PrimaryWeapon)) | |
| return InventorySlots.PrimaryWeapon; | |
| if (mod.IsInventorySlotActive(player, InventorySlots.SecondaryWeapon)) | |
| return InventorySlots.SecondaryWeapon; | |
| if (mod.IsInventorySlotActive(player, InventorySlots.Throwable)) | |
| return InventorySlots.Throwable; | |
| return null; | |
| } | |
| function getInventorySlotName(slot: InventorySlots): any { | |
| switch (slot) { | |
| case InventorySlots.ClassGadget: | |
| return mod.stringkeys.slots.class_gadget; | |
| case InventorySlots.GadgetOne: | |
| return mod.stringkeys.slots.gadget_one; | |
| case InventorySlots.GadgetTwo: | |
| return mod.stringkeys.slots.gadget_two; | |
| case InventorySlots.MeleeWeapon: | |
| return mod.stringkeys.slots.melee_weapon; | |
| case InventorySlots.MiscGadget: | |
| return mod.stringkeys.slots.misc_gadget; | |
| case InventorySlots.PrimaryWeapon: | |
| return mod.stringkeys.slots.primary_weapon; | |
| case InventorySlots.SecondaryWeapon: | |
| return mod.stringkeys.slots.secondary_weapon; | |
| case InventorySlots.Throwable: | |
| return mod.stringkeys.slots.throwable; | |
| default: | |
| return mod.stringkeys.slots.unknown; | |
| } | |
| } | |
| // strings | |
| { | |
| "slots": { | |
| "class_gadget": "Class Gadget", | |
| "gadget_one": "Gadget One", | |
| "gadget_two": "Gadget Two", | |
| "melee_weapon": "Melee Weapon", | |
| "misc_gadget": "Misc Gadget", | |
| "primary_weapon": "Primary Weapon", | |
| "secondary_weapon": "Secondary Weapon", | |
| "throwable": "Throwable", | |
| "unknown": "Unknown" | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment