πŸ“–
Documentation
  • Welcome!
  • Common Issues
    • Keymaster
    • Updating resources
  • πŸ“„Scripts
    • πŸš™AdvancedParking
      • Installation
      • Commands
      • Exports (server)
      • Exports (client)
      • Events (server)
      • Events (client)
      • FAQ
    • 🚚VehicleTransport
      • Installation
      • How to use it
      • Creating a new transport
      • Exports (client)
      • Events (server & client)
    • πŸ”‘VehicleKeyChain
      • Installation
      • Commands
      • Exports (server)
      • Exports (client)
      • FAQ
    • πŸ—œοΈVehicleClamp - Pre-Release
      • Installation
      • Commands
      • Exports (server)
      • Exports (client)
      • Integration
        • ESX
        • QB
    • πŸ“„VehicleRegistration
      • Installation
      • Exports (server)
      • Exports (client)
    • πŸ“ƒVehicleInteraction
      • Installation
    • πŸ—ΊοΈVehicleTracker
      • Installation
      • Exports (server)
      • Exports (client)
    • 🌐JobTracker
      • Installation
    • πŸ•΅οΈβ€β™‚οΈVehicleForceFirstPerson
      • Installation
    • 🎯BulletRicochet
      • Installation
  • πŸ†“Free Scripts
    • πŸ“žkimi_callbacks
      • Installation
      • Exports (server)
      • Exports (client)
      • Examples
    • 🚜VehicleDeformation
      • Installation
      • Exports (server)
      • Exports (client)
    • 🎦OrbitCam
      • Installation
      • Exports (client)
      • Commands
    • πŸ”οΈEarthquakeSimulator
      • Installation
      • Exports (server)
      • Commands
    • πŸ’€DeathCam
      • Installation
Powered by GitBook
On this page
  • Ready-made file
  • Initialization
  • Register all commands
  • Register all items
  • Check if a player has an item
  • Add an item to player inventory
  • Remove an item from player inventory
  1. Scripts
  2. VehicleClamp - Pre-Release
  3. Integration

ESX

PreviousIntegrationNextQB

Last updated 6 months ago

Ready-made file

You can either directly use this file to replace the original or use the instructions below to make the changes yourself and maybe learn a thing here and there.


Initialization

Add the following at the top of the file:

local ESX = exports["es_extended"]:getSharedObject()


Register all commands

Replace the RegisterCommands function with the following:

function RegisterCommands()
	ESX.RegisterCommand(attachClampCommand, commandPermissions, function(xPlayer, args, showError)
		OnAttachClampCommand(xPlayer.source)
	end, false, { help = "Attach a clamp to the closest vehicle wheel." })

	ESX.RegisterCommand(removeClampCommand, commandPermissions, function(xPlayer, args, showError)
		OnRemoveClampCommand(xPlayer.source)
	end, false, { help = "Remove the clamp from the closest vehicle wheel." })
end


Register all items

Replace the RegisterItems function with the following:

function RegisterItems()
	if (clampItemName) then
		ESX.RegisterUsableItem(clampItemName, StartClampingProcess)
	end
	if (removalToolItemName) then
		ESX.RegisterUsableItem(removalToolItemName, StartRemovalProcess)
	end
	if (destroyItemName) then
		ESX.RegisterUsableItem(destroyItemName, StartDestructionProcess)
	end
end


Check if a player has an item

Replace the GetPlayerHasItem function with the following:

function GetPlayerHasItem(playerId, itemName)
	local playerData = ESX.GetPlayerFromId(playerId)
	assert(playerData ~= nil, ("\"PlayerData\" could not be found for player \"%s\""):format(GetPlayerName(playerId)))
	local item = playerData.getInventoryItem(itemName)
	return item ~= nil and item.count > 0
end


Add an item to player inventory

Replace the AddPlayerItem function with the following:

function AddPlayerItem(playerId, itemName)
	local playerData = ESX.GetPlayerFromId(playerId)
	assert(playerData ~= nil, ("\"PlayerData\" could not be found for player \"%s\""):format(GetPlayerName(playerId)))
	playerData.addInventoryItem(itemName, 1)
	return true
end


Remove an item from player inventory

Replace the RemovePlayerItem function with the following:

function RemovePlayerItem(playerId, itemName)
	local playerData = ESX.GetPlayerFromId(playerId)
	assert(playerData ~= nil, ("\"PlayerData\" could not be found for player \"%s\""):format(GetPlayerName(playerId)))
	playerData.removeInventoryItem(itemName, 1)
end
πŸ“„
πŸ—œοΈ
2KB
integrations.lua
Integrations file ready-made for ESX