# 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

```lua
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)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.rcore.cz/paid-resources/xradio/api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
