Files
red-valley/resources/[framework]/[addons]/qs-smartphone-pro/client/custom/misc/OpenPhone.lua

40 lines
1.5 KiB
Lua
Raw Normal View History

2026-03-29 21:41:17 +03:00
---@param emergency? boolean
---@return boolean
function TogglePhone(emergency)
if not emergency and (isDead() or not canOpenPhone) then return false end
if not Config.UniquePhone then
local hasData = lib.callback.await('phone:server:HasPhone', 0)
if not hasData.phone then
SendTextMessage(Lang('PHONE_NOTIFICATION_PHONE_NO_PHONE'), 'error')
return false
end
local meta = TriggerServerCallbackSync('phone:GetPhoneDataForWithoutMeta')
OpenPhone(hasData.phone, Config.PhonesProps[hasData.name], meta)
return true
end
if not MetaData then
TriggerServerEvent('phone:server:openRandomItemPhone')
return true
end
local phoneData, name = TriggerServerCallbackSync('phone:server:checkHasPhoneWithUniqueId', MetaData.uniqueId)
if not phoneData then
if MetaData then
MetaData = nil
TriggerServerEvent('phone:server:openRandomItemPhone')
-- SendTextMessage('Your phone is fucked up', 'inform')
return true
end
SendTextMessage(Lang('PHONE_NOTIFICATION_PHONE_NO_PHONE'), 'error')
return false
end
OpenPhone(CurrentPhoneData.type, CurrentPhoneData.phoneColor, MetaData)
return true
end
if not Config.OpenPhoneByPress and Config.UniquePhone then return end
RegisterKeyMapping('TooglePhone', 'Open phone', 'keyboard', Config.OpenPhone)
RegisterCommand('TooglePhone', function()
TogglePhone()
end, false)