80 lines
		
	
	
	
		
			2.1 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
			
		
		
	
	
			80 lines
		
	
	
	
		
			2.1 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
| ESX = nil
 | |
| QBCore = nil
 | |
| 
 | |
| if (GetResourceState('es_extended') == 'started') then
 | |
|     ESX = exports['es_extended']:getSharedObject()
 | |
| elseif (GetResourceState('qb-core') == 'started') then
 | |
|     QBCore = exports['qb-core']:GetCoreObject()
 | |
| end
 | |
| 
 | |
| Functions = {}
 | |
| 
 | |
| Functions.Notify = function(message, isError)
 | |
|     if ESX then
 | |
|         messageType = isError and 'error' or 'info'
 | |
|         ESX.ShowNotification(message, messageType, 5000)
 | |
|     elseif QBCore then
 | |
|         messageType = isError and 'error' or 'primary'
 | |
|         QBCore.Functions.Notify(message, messageType, 5000)
 | |
|     end
 | |
| end
 | |
| 
 | |
| Functions.CopyToClipboard = function(text)
 | |
|     emitNui('copyToClipboard', text)
 | |
| end
 | |
| 
 | |
| Functions.ShowDialog = function(title, description)
 | |
|     if GetResourceState('ox_lib') ~= 'started' then
 | |
|         return true
 | |
|     end
 | |
| 
 | |
|     local result = lib.alertDialog({
 | |
|         header = title,
 | |
|         content = description,
 | |
|         cancel = true,
 | |
|     })
 | |
| 
 | |
|     local success = (result ~= 'cancel')
 | |
|     return success
 | |
| end
 | |
| 
 | |
| Functions.TakeImage = function(data)
 | |
|     -- local droneEntity = data.droneEntity
 | |
| 
 | |
|     local imageData = exports.fmsdk:takeImage()
 | |
| 
 | |
|     local imageUrl = imageData?.data?.url
 | |
|     if imageUrl then
 | |
|         Functions.CopyToClipboard(imageUrl)
 | |
|         Functions.Notify(Config.Locales['screenshot_copied'], false)
 | |
|     else
 | |
|         Functions.Notify(Config.Locales['screenshot_failed'], true)
 | |
|     end
 | |
| end
 | |
| 
 | |
| Functions.CanUseDrone = function()
 | |
|     local ped = PlayerPedId()
 | |
| 
 | |
|     -- Vehicle check
 | |
|     if IsPedInAnyVehicle(ped, true) then return false end
 | |
| 
 | |
|     -- Interior check
 | |
|     local curInterior = GetInteriorFromEntity(ped)
 | |
|     if curInterior ~= 0 then return false end
 | |
| 
 | |
|     return true
 | |
| end
 | |
| 
 | |
| -- Useful if you want to force delete the drone, for example when a player dies
 | |
| RegisterNetEvent('gs_drone:deleteDrone', function(isCrashed, doBlackout)
 | |
|     deleteDrone(isCrashed, doBlackout)
 | |
| end)
 | |
| 
 | |
| AddEventHandler('gs_drone:onDroneSpawn', function(data)
 | |
|     local droneEntity = data.droneEntity
 | |
|     local droneIndex = data.droneIndex
 | |
| end)
 | |
| 
 | |
| AddEventHandler('gs_drone:onDroneDelete', function(data)
 | |
|     local isCrashed = data.isCrashed
 | |
| end)
 | 
