API

Exports

  • AddVirtualRadio(vector3 coords, string uniqid)

    • uniqid must be same for each client or radio won't be synced

    • Add openable boombox on certain coords: void

  • IsRadioClose() - Check if player has radio closed: boolean

  • IsRadioOnShoulder() - Check if player has radio on his shoulder: boolean

  • DeleteShoulderRadio() - Delete radio on player's shoulder and give it back to his inventory: void

Events

  • AddEventHandler("xradio:menuOpened", function(type) end) - Called when opening menu

  • TriggerEvent("xradio:openRadio") Open radio UI on ground

  • TriggerEvent("xradio:radioOnShoulder") - Equip radio to shoulder

  • TriggerEvent("xradio:deleteRadioOnGround") - Remove radio from ground

  • TriggerEvent("xradio:openShoulderUi") - Open radio UI on shoulder

  • TriggerEvent("xradio:hideShoulderRadio") Remove radio from player's shoulder

  • TriggerEvent("xradio:putRadioBackGround") - Put radio back on the ground

Example

Menu = exports.MenuAPI

AddEventHandler("xradio:menuOpened", function(type)
    if type == "ground" then
        local menu = Menu:CreateMenu("identifier")

        menu.SetMenuTitle("Radio")

        menu.SetProperties(Config.MenuProperties)

        menu.AddItem(1, "open radio", function()
            menu.Close()
            TriggerEvent("xradio:openRadio")
        end)

        menu.AddItem(2, "pick radio", function()
            menu.Close()
            TriggerEvent("xradio:deleteRadioOnGround")
        end)

        if Config.radioOnShoulder then
            menu.AddItem(3, "Radio on shoulder", function()
                menu.Close()
                TriggerEvent("xradio:radioOnShoulder")
            end)
        end
        menu.Open()
    end

    if type == "shoulder" then
        local menu = Menu:CreateMenu("identifier")

        menu.SetMenuTitle("Radio")

        menu.SetProperties(Config.MenuProperties)

        menu.AddItem(1, "open radio", function()
            menu.Close()
            TriggerEvent("xradio:openShoulderUi")
        end)

        menu.AddItem(2, "hide radio", function()
            menu.Close()
            TriggerEvent("xradio:hideShoulderRadio")
        end)

        menu.AddItem(3, "Put back radio on ground", function()
            menu.Close()
            TriggerEvent("xradio:putRadioBackGround")
        end)


        menu.Open()
    end
end)

Last updated