---@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)