-- isNearStore() -> Returns nearby store table from Config.Stores within 10.0 units, otherwise nil. -- playMusic(url, volume) -> Tries to start music on server. -- pauseMusic() -> Tries to pause current store song. -- resumeMusic() -> Tries to resume current store song. -- stopMusic() -> Tries to stop current store song. -- getMusic() -> Returns current song data { id, url, volume, store, loop } for nearby store, otherwise nil. -- changeColor(color) -> Tries to update LED color. if not Config.EnableMusicModule and not Config.EnableLEDModule then return end local options = {} if Config.EnableMusicModule then table.insert(options, { label = "Play music", icon = "fas fa-music", args = "playMusic" }) end if Config.EnableLEDModule then table.insert(options, { label = "Change LED color", icon = "fas fa-lightbulb", args = "changeColor" }) end lib.registerMenu({ id = "ifruit_store_main", title = "iFruit Store", position = "top-right", options = options }, function(selected, scrollIndex, args) if args == "playMusic" then lib.showMenu("ifruit_store_music") elseif args == "changeColor" then lib.showMenu("ifruit_store_led") end end) lib.registerMenu({ id = "ifruit_store_music", title = "Music Manager", position = "top-right", options = { { label = "Play Music", icon = "fas fa-play", args = "play" }, { label = "Pause Music", icon = "fas fa-pause", args = "pause", close = false }, { label = "Resume Music", icon = "fas fa-play-circle", args = "resume", close = false }, { label = "Stop Music", icon = "fas fa-stop", args = "stop", close = false } } }, function(selected, scrollIndex, args) if args == "play" then if exports["cfx_vello_ifruit_store"]:getMusic() then return lib.notify({ title = "iFruit Store", description = "A song is already playing. Please stop the current song before playing a new one.", type = "error" }) end local input = lib.inputDialog("Play Music", { { type = "input", label = "YouTube URL", placeholder = "https://www.youtube.com/watch?v=...", required = true }, { type = "number", label = "Volume", default = 0.5, min = 0, max = Config.MaxVolume or 1, required = false } }) if input then exports["cfx_vello_ifruit_store"]:playMusic(input[1], input[2] or 0.5) end elseif args == "pause" then exports["cfx_vello_ifruit_store"]:pauseMusic() elseif args == "resume" then exports["cfx_vello_ifruit_store"]:resumeMusic() elseif args == "stop" then exports["cfx_vello_ifruit_store"]:stopMusic() end end) lib.registerMenu({ id = "ifruit_store_led", title = "LED Manager", position = "top-right", options = { { label = "Red", icon = "fas fa-square", args = "red", close = false }, { label = "Green", icon = "fas fa-square", args = "green", close = false }, { label = "Blue", icon = "fas fa-square", args = "blue", close = false }, { label = "Yellow", icon = "fas fa-square", args = "yellow", close = false }, { label = "Purple", icon = "fas fa-square", args = "purple", close = false }, { label = "White", icon = "fas fa-square", args = "white", close = false }, { label = "Off", icon = "fas fa-square", args = "off", close = false }, } }, function(selected, scrollIndex, args) exports["cfx_vello_ifruit_store"]:changeColor(args) end) RegisterCommand("ifruitstore", function() if not exports["cfx_vello_ifruit_store"]:isNearStore() then return lib.notify({ title = "iFruit Store", description = "You must be near an iFruit Store to access this menu.", type = "error" }) end if not lib.callback.await("glynt_ifruit_store:server:hasAccess", false) then return lib.notify({ title = "iFruit Store", description = "You do not have access to this menu.", type = "error" }) end lib.showMenu("ifruit_store_main") end)