ESX
CreateThread(function()
if LoadFrameworkConfig() ~= 'ESX' then return end
local ESX = nil
if GetResourceState('esx-core') ~= "missing" or GetResourceState('es_extended') ~= "missing" then
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
else
print('esx-core or es_extended ressource not found the reset of frameworkConfig files is launch')
local fileName = "frameworkConfig"
local configData = { framework = "None" }
SaveJson(fileName, configData)
return
end
-- GET GetPlayers
function GetPlayer()
local players = ESX.GetPlayers()
return players
end
-- GET CITIZENID
function GetCitizenId(player)
local xPlayer = ESX.GetPlayerFromId(player)
if xPlayer then
return xPlayer.identifier
end
return nil
end
-- GET PERMISSION
function GetPlayerPermission(player)
local xPlayer = ESX.GetPlayerFromId(player)
print('PERMISSION :')
print(json.encode(xPlayer.getGroup()))
if xPlayer then
return xPlayer.getGroup()
end
return nil
end
-- RemovePlayerItem
function RemovePlayerItem(playerId, itemName, quantity)
local xPlayer = ESX.GetPlayerFromId(playerId)
if xPlayer then
local item = xPlayer.getInventoryItem(itemName)
if item.count >= quantity then
xPlayer.removeInventoryItem(itemName, quantity)
return true
else
return false
end
end
return false
end
-- HasPlayerItem
function HasPlayerItem(playerId, itemName, quantity)
local xPlayer = ESX.GetPlayerFromId(playerId)
if xPlayer then
local item = xPlayer.getInventoryItem(itemName)
if item and item.count >= (quantity or 1) then
return true
end
end
return false
end
-- CreateUsableItem
function CreateUsableItem(itemName, propData)
print(itemName)
print(json.encode(propData))
ESX.RegisterUsableItem(itemName, function(source)
print(itemName)
print(json.encode(propData))
local playerId = source
TriggerClientEvent('peace-propsmanager:client:usePropItem', playerId, propData)
end)
end
end)
Last updated