Suty Phone
Exports
Exports
Exports never wait (no Wait inside), so they're safe to call from anywhere. Wrap calls in pcall if suty-phone may not be started.
Server
pushNotification
A notification on a phone number, stored in its Notification Center.
local id = exports['suty-phone']:pushNotification('5551234567', {
app = 'messages', -- app whose icon it shows: messages, phone, wallet, maps, settings...
title = 'Fleeca Bank', -- required
body = 'You received $500', -- optional
id = 'my-script-123', -- optional: the same id replaces the previous one
intent = { thread = '5551234567' }, -- optional: what a tap opens in that app
silent = false, -- true = no sound
})
-- id, or false when it wasn't kept: invalid data, the app isn't on that phone, or the player
-- turned that app's notifications off
prompt
A yes / no question on a player's phone. The answer arrives in the callback, exactly once.
exports['suty-phone']:prompt(source, {
title = '¿Aceptas la transferencia?', -- required, up to 60 characters
message = '$500 de Luis', -- optional, up to 240
confirm = 'Aceptar', cancel = 'Rechazar',-- optional labels
destructive = false, -- true = red confirm button
icon = 'wallet', -- optional app id, its icon above the title
timeout = 30, -- seconds (5-120)
open = true, -- false = only if the phone is already out
}, function(accepted, reason)
-- accepted = true only for the confirm button
-- reason: 'confirm', 'cancel', 'timeout', 'closed', 'nophone', 'busy', 'rate', 'invalid', 'dropped', 'stopped'
end)
Inside your own thread it reads like a boolean:
local p = promise.new()
exports['suty-phone']:prompt(source, { title = '¿Seguro?' }, function(ok) p:resolve(ok) end)
local accepted = Citizen.Await(p)
With the phone put away, it comes out by itself when the player can hold it (on foot, not dead or cuffed). Putting it away while the question is up answers false ('closed'). Limits: Config.Prompts.
AppAllowed
For a resource that serves an app of the phone: the player's phone is out, unlocked, has the app installed and its NubeOS has it.
local allowed, reason = exports['suty-phone']:AppAllowed(source, 'garajes')
-- reason: 'locked', 'notinstalled', 'nubeos' (or 'job' for a custom app)
Custom apps
AddCustomApp, RemoveCustomApp and CustomAppAllowed: see Custom apps.
Client
Custom apps
AddCustomApp, RemoveCustomApp, SendCustomAppMessage, OpenCustomApp, CloseCustomApp, IsCustomAppOpen and SendCustomAppNotification: see Custom apps.
Items
ox_inventory calls these from the client.export of each item in install/ox_inventory/items.lua. Other inventories go through the framework's usable items, which the phone registers by itself.
| Export | Item |
|---|---|
suty-phone.usePhone |
Every phone |
suty-phone.openBox |
Phone boxes |
suty-phone.useMagsafe |
air_magsafe_battery |
suty-phone.useRice |
rice_bag |
suty-phone.useRepairKit |
phone_repair_kit |
suty-phone.useKlaroTablet |
klaro_tablet |
Exports of other phones
Scripts written for other phones keep working: the phone answers their exports and events while that phone's own resource isn't started (Compatibility). For example exports['lb-phone']:SendNotification, SendMessage, SendMail, GetEquippedPhoneNumber, exports.npwd:createNotification, or the qb-phone event qb-phone:client:CustomNotification.
