AW Phone
Exports and events
#Exports
Text
-- server
exports.aw_phone:SendMail(source | citizenid | number, { sender = 'Bank', subject = 'Loan', message = 'Text', button = { label = 'Accept', event = 'my:clientEvent', data = {} } })
exports.aw_phone:SendNotification(source, { app = 'bank', title = 'Paid', body = '$500' })
exports.aw_phone:SendMessage(fromNumber, toNumber, 'Hello')
exports.aw_phone:GetNumber(source)
exports.aw_phone:GetSourceByNumber(number)
exports.aw_phone:HasPhone(source)
exports.aw_phone:IsInCall(source)
exports.aw_phone:GetCryptoPrice('lsc')
exports.aw_phone:AddCrypto(source, 'lsc', 0.5) -- give coins (heists, rewards)
-- client
exports.aw_phone:IsOpen() / OpenPhone() / ClosePhone() / IsInCall()
exports.aw_phone:ToggleDisabled(true) -- block the phone (cutscenes, jail ...)
exports.aw_phone:SendNotification({ app = 'mail', title = 'Hi', content = 'Text' })
exports.aw_phone:GetNumber()
#Your own apps (AW Store SDK)
Lua
-- server, in your resource
exports.aw_phone:AddApp({
id = 'crypto', name = 'Crypto', description = 'Buy and sell coins', developer = 'Your name',
icon = 'nui://my_crypto/html/icon.png', -- or a built-in icon name like 'dollar'
color = 'linear-gradient(180deg,#2BD67B,#0E8F4F)',
ui = 'nui://my_crypto/html/index.html', -- your page, shown inside the phone
})
-- client: answer requests from your page
AddEventHandler('aw_phone:customApp:crypto', function(action, data, cb)
if action == 'price' then cb({ btc = 63000 }) end
end)
Chat command
// in your page
const ask = (action, data) => new Promise(res => {
const id = Math.random();
const on = e => { if (e.data.awphone === 'response' && e.data.id === id) { removeEventListener('message', on); res(e.data.data); } };
addEventListener('message', on);
parent.postMessage({ awphone: 'request', id, action, data }, '*');
});
ask('price').then(p => console.log(p.btc));
parent.postMessage({ awphone: 'notify', title: 'Crypto', body: 'Price alert!' }, '*');
parent.postMessage({ awphone: 'close' }, '*');