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:
functionRegisterCommands() 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:
functionRegisterItems()if (clampItemName) then ESX.RegisterUsableItem(clampItemName, StartClampingProcess)endif (removalToolItemName) then ESX.RegisterUsableItem(removalToolItemName, StartRemovalProcess)endif (destroyItemName) then ESX.RegisterUsableItem(destroyItemName, StartDestructionProcess)endend
Check if a player has an item
Replace the GetPlayerHasItem function with the following:
functionGetPlayerHasItem(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 ~=niland item.count >0end
Add an item to player inventory
Replace the AddPlayerItem function with the following:
functionAddPlayerItem(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)returntrueend
Remove an item from player inventory
Replace the RemovePlayerItem function with the following:
functionRemovePlayerItem(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