Skip to content

Native UI API

The Native UI API provides functions for interacting with the game's user interface elements in Schedule 1. This includes displaying notifications, showing dialog boxes, and managing in-game messages.

Implementation Status: Partially implemented. Basic functionality works, but some advanced features are still in development.

Overview

The Native UI API focuses on built-in game UI elements that allow your script to communicate with the player. For custom UI elements (windows, controls, styling), please refer to the Custom UI API.

Available Functions

Notifications

Dialogs

Phone UI

Tooltips

UI Items

Storage Entities

Custom GUI

Controls

UI Style Functions

Global UI Functions

Example Usage

Basic Notification

lua
function OnPlayerReady()
    -- Show a simple welcome notification
    ShowNotification("Welcome", "Welcome to my custom script!")
    
    -- Show an energy warning when energy is low
    if GetPlayerEnergy() < 20 then
        ShowNotification("Warning", "Low energy!")
    end
    
    return true
end

-- Notification that disappears after 5 seconds
function OnPlayerHealthChanged(newHealth)
    if newHealth < 50 then
        ShowNotificationWithTimeout("Your health is low!", 5.0)
    end
end

Interactive Dialog

lua
function OfferPlayerChoice()
    local choices = {
        "Accept the quest",
        "Decline",
        "Ask for more information"
    }
    
    ShowChoiceDialogue(
        "New Quest Available", 
        "A stranger needs your help finding a lost item. Will you help?",
        choices,
        function(choiceIndex)
            if choiceIndex == 1 then
                ShowNotification("Quest", "Quest accepted!")
                StartQuest()
            elseif choiceIndex == 2 then
                ShowNotification("Quest", "Quest declined.")
            elseif choiceIndex == 3 then
                ShowDialogue(
                    "Quest Details", 
                    "The stranger lost a valuable watch somewhere in the Downtown area. " ..
                    "They will pay you 100 credits if you can find it."
                )
                -- Ask again after showing more info
                Wait(3.0, function()
                    OfferPlayerChoice()
                end)
            end
        end
    )
end

-- Register a command to start the dialogue
RegisterCommand("quest", "Starts a sample quest dialogue", "quest", function(args)
    OfferPlayerChoice()
end)

Custom Window UI

lua
function CreateInventoryUI()
    -- Create main window
    local windowId = CreateWindow("inventory", "Player Inventory", 100, 100, 400, 300)
    
    -- Add title and instructions
    AddLabel(windowId, "title", "Manage your items")
    SetControlPosition("title", 150, 30)
    
    -- Add a button to close the window
    AddButton(windowId, "closeBtn", "Close", function()
        ShowWindow(windowId, false)
    end)
    SetControlPosition("closeBtn", 150, 250)
    
    -- Show the window
    ShowWindow(windowId, true)
    
    return windowId
end

-- Register a command to toggle the inventory UI
RegisterCommand("inventory", "Shows inventory UI", "inventory", function(args)
    if IsWindowVisible("inventory") then
        ShowWindow("inventory", false)
    else
        if not _G.inventoryWindowId then
            _G.inventoryWindowId = CreateInventoryUI()
        else
            ShowWindow(_G.inventoryWindowId, true)
        end
    end
end)

Best Practices

  • User experience: Keep notifications brief and only show when necessary
  • Dialog usage: Use dialogs for important information that requires attention
  • Avoid spam: Don't overuse notifications, as they can become annoying
  • Timeouts: Consider using timed notifications for transient information
  • Clear dialogs: Always close dialogs when they're no longer needed
  • Resource management: Destroy windows and controls when no longer needed

Explore the sections in the sidebar for detailed documentation of each function.

Released as Beta Software under the GPL-3.0 License.