PEACESCRIPT Documentation
StoreDiscord
  • 👋Introduction
  • 📸PEACE-Speedcamera
    • 📜Config File
    • 📂Unlocked File
      • 🖥️Server
        • QBCore
        • ESX
        • QBOX
        • Custom
      • 💻Client
        • QBCore
        • ESX
        • QBOX
        • Custom
  • 📄PEACE-JobMenu
    • 📜Config File
    • 📂Unlocked File
      • 💻Client
        • QBCore
        • ESX
        • Custom
  • 📊PEACE-DutyLog
    • 📜Config File
    • 📂Unlocked File
      • 💻Client
        • QBCore
        • ESX
        • QBOX
        • Custom
        • Target
      • 🖥️Server
        • QBCore
        • ESX
        • QBOX
        • Custom
  • 🖋️PEACE-PropsManager
    • ⬇️Installation
    • 📜Configuration
    • ❓FAQ
    • 📂Unlocked File
      • 🖥️Server
        • QBCore
        • ESX
        • Custom
      • 💻Client
        • QBCore
        • ESX
        • Custom
Powered by GitBook
On this page
  1. PEACE-PropsManager
  2. Unlocked File
  3. Server

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

Last updated 9 months ago

🖋️
📂
🖥️