๐ŸŽฎGTPS Cloud Docs
๐ŸŽฎ

GTPS Cloud Lua API

Complete Lua scripting reference for GTPS Cloud. Build custom systems, events, dialogs, and much more โ€” all through Lua!

๐Ÿ””
83
Callbacks
๐Ÿ‘ค
125
Player Methods
๐ŸŒ
68
World Methods
โšก
411
Total Methods

๐Ÿš€ Quick Start

Lua scripts in GTPS Cloud are loaded automatically on server start. Create a .lua file and upload it through the File Manager in your dashboard.

Use loadDataFromServer and saveDataToServer for persistent storage. Data survives server restarts.

lua
-- Basic GTPS Cloud script template
print("(Loaded) My Script โ€” by Developer")

-- Register a command
registerLuaCommand({
    command = "hello",
    roleRequired = 0,
    description = "Greet a player"
})

-- Handle the command
onPlayerCommandCallback(function(world, player, fullCommand)
    local cmd = fullCommand:match("^(%S+)")
    if cmd ~= "hello" then return false end

    local name = player:getCleanName()
    player:onConsoleMessage("`6Hello, " .. name .. "! Welcome!")
    player:onTalkBubble(player:getNetID(), "Hey!", 1)
    return true
end)

-- Greet on login
onPlayerLoginCallback(function(player)
    player:sendVariant({
        "OnAddNotification",
        "interface/science_button.rttex",
        "`wWelcome to the server!",
        "audio/hub_open.wav"
    })
end)

โš ๏ธ Important Notes

๐Ÿ”’
Don't pass Player objects into timers
Use getUserID() to store a reference, then call getPlayer() inside the timer. The player object may become invalid after disconnect.
๐Ÿ’พ
Save data inside onAutoSaveRequest
The server calls this callback periodically. Save all your Lua state here to ensure data persists across restarts.
โšก
Avoid heavy computation in onTick / onWorldTick
These callbacks fire every 100ms. Large loops or expensive calculations can cause server lag.
๐Ÿ”
Wrap HTTP requests in coroutines
All http.get() and http.post() calls must be wrapped in coroutine.wrap() to avoid blocking the server loop.

๐ŸŽจ Color Codes

Use a backtick followed by a digit or letter to colorize text in console messages, dialogs, and more.

`0
White
`1
Purple
`2
Green
`3
Yellow
`4
Red
`5
Cyan
`6
Gold
`7
Orange
`8
Gray
`9
Blue
`w
White2
`o
Orange2