ZPROJECT

Checkboxes, listes et sliders

Par
Sören
v2.0.0

Checkbox

lua
zUI.Checkbox(label, description, state, styles, action)

Exemple :

lua
local godModeEnabled = false

zUI.Checkbox(
    "God Mode",
    "Activer l’invincibilité.",
    godModeEnabled,
    {
        IsDisabled = false
    },
    function(onSelected)
        if onSelected then
            godModeEnabled = not godModeEnabled
            SetPlayerInvincible(PlayerId(), godModeEnabled)
        end
    end
)

La variable contenant l’état doit être mise à jour lorsque l’utilisateur sélectionne la checkbox.

Liste

lua
zUI.List(label, description, items, index, styles, action)

Exemple :

lua
local vehicles = {
    "Adder",
    "Zentorno",
    "T20",
    "Osiris"
}

local vehicleIndex = 1

zUI.List(
    "Véhicule",
    "Choisir un véhicule.",
    vehicles,
    vehicleIndex,
    {
        IsDisabled = false
    },
    function(onSelected, onChange, index)
        if onChange then
            vehicleIndex = index
        end

        if onSelected then
            print("Véhicule sélectionné :", vehicles[vehicleIndex])
        end
    end
)

Slider

lua
zUI.Slider(label, description, percentage, step, styles, action)

Exemple :

lua
local volume = 50

zUI.Slider(
    "Volume",
    "Régler le volume.",
    volume,
    5,
    {
        IsDisabled = false,
        ShowPercentage = true
    },
    function(onSelected, onChange, percentage)
        if onChange then
            volume = percentage
        end
    end
)

Le paramètre step définit la valeur ajoutée ou retirée à chaque modification.