54 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
			
		
		
	
	
			54 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
| if Config.Framework ~= 'esx' then
 | |
|     return
 | |
| end
 | |
| 
 | |
| ESX = exports['es_extended']:getSharedObject()
 | |
| 
 | |
| RegisterNetEvent('esx:playerLoaded', function(id, data)
 | |
|     Wait(2000)
 | |
|     Debug('Loaded player:', id)
 | |
|     CreateQuests(id)
 | |
| end)
 | |
| 
 | |
| CreateThread(function()
 | |
|     for k, v in pairs(ESX.Players) do
 | |
|         if v and v.source then
 | |
|             Debug('Loaded player:', v.source)
 | |
|             CreateQuests(v.source)
 | |
|         end
 | |
|     end
 | |
| end)
 | |
| 
 | |
| function RegisterServerCallback(name, cb)
 | |
|     ESX.RegisterServerCallback(name, cb)
 | |
| end
 | |
| 
 | |
| function RegisterUsableItem(name, cb)
 | |
|     ESX.RegisterUsableItem(name, cb)
 | |
| end
 | |
| 
 | |
| function GetPlayerFromId(source)
 | |
|     return ESX.GetPlayerFromId(source)
 | |
| end
 | |
| 
 | |
| function GetItem(player, item)
 | |
|     return player.getInventoryItem(item)
 | |
| end
 | |
| 
 | |
| function AddItem(source, item, count)
 | |
|     local player = GetPlayerFromId(source)
 | |
|     local success = player.addInventoryItem(item, count)
 | |
|     if GetResourceState('ox_inventory'):find('started') then
 | |
|         Debug('ox_inventory add item success:::', success)
 | |
|         return success
 | |
|     end
 | |
|     return true
 | |
| end
 | |
| 
 | |
| ---@param source string
 | |
| ---@param item string
 | |
| ---@param count number
 | |
| function RemoveItem(source, item, count)
 | |
|     local player = GetPlayerFromId(source)
 | |
|     player.removeInventoryItem(item, count)
 | |
| end
 | 
