Client side
local gum = exports.gumApi:gumApi()The returned table is built once. Keep it in a local variable at the top of your script.
Two ways to reach the API. exports.gumApi:gumApi() gives notifications, prompts, peds, blips, vehicles and the helpers below. The inputs, the yes/no question and the polygon check are only on the table you get from TriggerEvent("getApi", function(api) ... end).
Notifications#
notify#
Shows a notification card. Notifications are queued and shown one after the other.
gum.notify("Title", "Text of the notification", "bread", 4000)titlestringrequiredHeader text.
textstringrequiredBody text. Only plain formatting tags (b, i, u, strong, em, small, br) are kept, everything else is shown as text.
imgstringItem name of the icon, without .png. Taken from the inventory icon folder of your framework.
timenumberMilliseconds on screen. Default 5000, limited to 500 - 60000.
Prompts#
createPrompt / getPrompt / getPromptButton#
Native prompts in a prompt group.
local group = GetRandomIntInRange(0, 0xffffff)
gum.createPrompt("Open", 0x760A9C6F, group, false, "myScript:open")
CreateThread(function()
while true do
Wait(0)
gum.getPrompt(group, "Shop")
end
end)textstringrequiredButton text.
keynumber | stringrequiredControl hash, or a key name that has a native action.
promptHashnumberrequiredThe group the prompt belongs to.
holdModestring | falseHold timing name, for example MEDIUM_TIMED_EVENT. false = press.
eventstringClient event triggered when the prompt is completed.
getPromptButtonData#
Returns the native prompt handle that was created for a text and group.
local prompt = gum.getPromptButtonData("Open", group)For on-screen key hints that are drawn by NUI see New prompts.
Player and world helpers#
| Function | Returns | Use |
|---|---|---|
drawMe(x, y, z, text, dist, marker) |
nothing | Draws 3D text (and an optional marker) when the player is closer than dist |
playerNearCoords(x, y, z, dist, mark) |
boolean | True when the player is close, alive, on foot |
checkPlayersNearEntity(entity, distance) |
boolean | True when another player is near the entity |
groundCheck(x, y) |
number | Ground height at x, y |
getTime() |
hours, minutes | In-game clock |
getAllPeds() / getAllEntities() / getAllVehicles() |
table | Game pools |
playAnim(entity, dict, anim, flag, time) |
nothing | Loads the dictionary (100 frame limit) and plays the animation |
Entities#
createPed, getLastPed, createVehicle, getLastVehicle, deleteObj#
gum.createPed("u_m_m_valbartender_01", x, y, z, heading, 50.0, "WORLD_HUMAN_SMOKE")
local ped = gum.getLastPed()
gum.createVehicle("wagon02x", x, y, z, heading)
local wagon = gum.getLastVehicle()
gum.deleteObj(ped)createVehicle waits up to two seconds for the model and gives up if it never loads.
createPed only stores the ped in a list in this package. The loop that spawns it when the player comes close is missing (spawnNPC is never called), so no ped appears and getLastPed stays empty. Spawn peds with your own script until the author ships the loop.
createBlip#
gum.createBlip("Shop", x, y, z, 1475879922)Inputs#
The input helpers are available on the internal table used by Gum scripts (TriggerEvent("getApi", ...) on the client). They open the NUI and call your callback when the player answers.
local gum
TriggerEvent("getApi", function(api) gum = api end)
gum.getInput("Confirm", "Enter a name", function(value)
if value == "close" then return end -- player cancelled
print(value)
end)
gum.getAnswer("Delete this item?", "Yes", "No", function(answer)
print(answer) -- true or false
end)
gum.getInputs({
{ label = "Name", value = "" },
{ label = "Type", isButton = true, button1 = "Cash", button2 = "Card", value = 0 },
}, function(result)
if not result then return end -- cancelled
end)| Function | Callback receives |
|---|---|
getInput(title, subtext, cb) |
the typed text (max 2000 characters), or "close" when cancelled |
getAnswer(title, first, second, cb) |
true for the first button, false for the second or when cancelled |
getInputs(data, cb) |
the table with filled value fields, or nil when cancelled |
Zones and math#
IsPlayerInsidePolygon#
Only on the table from TriggerEvent("getApi", ...), it is not part of the exports.
local inside = gum.IsPlayerInsidePolygon(GetEntityCoords(PlayerPedId()), points, false)points is a list of vector3. The third argument draws green debug walls, the fourth draws small markers on every corner.Developer commands#
| Command | What it does |
|---|---|
/cc |
Copies your coordinates to the clipboard as x,y,z |
/cch |
Same with heading |
/polyPoint |
Starts or clears the polygon creator. Press the key to add points, then paste the result |
/target (configurable) |
Toggles the eye targeting overlay |
/cc, /cch and /polyPoint are available to every player and only help builders. Remove them from client.lua on a live server if you do not need them.