QBCore:HasItem is deprecated (problem)

Hey, I know what it is saying but I can just not get this to work, I have tried to fix it myself but to no avail, so please can anyone help me?

This is the error in server logs:

QBCore:HasItem is deprecated, please use QBCore.Functions.HasItem, it can be used on both server- and client-side and uses the same arguments.

And here is the error showing in the server log (F8) in-game.

The part of code that I am trying to fix and is obviously broken is this:

elseif itemData["name"] == "license_plate" then
	                    info.plate = tostring(QBCore.Shared.RandomInt(2) .. QBCore.Shared.RandomStr(2) .. QBCore.Shared.RandomInt(2) .. QBCore.Shared.RandomStr(2))
                        elseif itemData["name"] == "fake_plate" then
	                    info.plate = tostring(QBCore.Shared.RandomInt(2) .. QBCore.Shared.RandomStr(2) .. QBCore.Shared.RandomInt(2) .. QBCore.Shared.RandomStr(2))

I am not lazy, just not good enough to fix it with my limited skills in scripting. sorry.

TIA :slight_smile:

1 Like

Is “fakeplates/client.lua:142” this exact code?:

If so, one of the values trying to be concatenated (by using ..) is nil. According to what you have posted, the issue could be any of the following:

  • The QBCore.Shared.RandomInt and QBCore.Shared.RandomStr functions are broken (however, that is most likely not the case)
  • There is an issue with the execution of the native SetVehicleNumberPlateText, likely due to it being invoked improperly (see: the screenshot of your F8 console).
  • The QBCore:HasItem failed to be invoked due to deprecation, therefore it sent no data down the chain, so all functions that depended on it pretty much gave up due to incorrect/nil data (this is likely the case)

The code that you have provided in the post doesn’t seem to contain any QBCore:HasItem calls. However, if my guess is correct, to fix this problem you would have to replace any HasItem callback in your client script that looks like this:

QBCore.Functions.TriggerCallback('QBCore:HasItem', function()
    -- do stuff here
end, "item_id_here")

with this:

if QBCore.Functions.HasItem("item_id_here") then
    -- do stuff here
end

If that doesn’t solve the problem, please post further context as to where and how you are invoking the native that seems to be located @ line 142 in fakeplates/client.lua

No mate, the script I am trying to fix is this one (Github Download) and it is kind of working and not, the final part where it is supposed to give the fakeplate gives an error as shown in the image. Sorry for the confusion.

I think I am missing something, can u send here ur code?

It’s above mate, the (GitHub link) :slight_smile:

RegisterNetEvent('plate:installFakePlate')
AddEventHandler('plate:installFakePlate', function(data)
    local playerPed = PlayerPedId()
    local vehicle = QBCore.Functions.GetClosestVehicle()
    local plate =  GetVehicleNumberPlateText(vehicle)
    local vehCoords = GetEntityCoords(vehicle)
    local pos = GetEntityCoords(playerPed)
    local close = #(pos - vehCoords) <= 3.5

    NetworkHasControlOfEntity(vehicle)
    NetworkRequestControlOfEntity(vehicle)

    if close then
        if QBCore.Functions.HasItem('screwdriverset') then
            QBCore.Functions.Progressbar("fake_plate", "Removing Plate..", math.random(7500, 12000), false, true, {
                disableMovement = true,
                disableCarMovement = true,
                disableMouse = false,
                disableCombat = true,
            }, {
                animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
                anim = "machinic_loop_mechandplayer",
                flags = 0,
            }, {}, {}, function() -- Done
                QBCore.Functions.Progressbar("install_fake_plate", "Installing Fake Plate..", math.random(7500, 12000), false, true, {
                    disableMovement = true,
                    disableCarMovement = true,
                    disableMouse = false,
                    disableCombat = true,
                }, {
                    animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
                    anim = "machinic_loop_mechandplayer",
                    flags = 0,
                }, {}, {}, function() -- Done
                    TriggerServerEvent('plate:addPlate', plate)
                    SetVehicleNumberPlateText(vehicle, data)
                    TriggerServerEvent('plate:takeFakePlate')
                    ClearPedTasks(playerPed)
                end, function() -- Cancel
                    ClearPedTasks(playerPed)
                    QBCore.Functions.Notify("Process Canceled", "error")
                end)
            end, function() -- Cancel
                ClearPedTasks(playerPed)
                QBCore.Functions.Notify("Process Canceled", "error")
            end)
        else QBCore.Functions.Notify("You don\'t have the right tools.", "error")
        end
    else QBCore.Functions.Notify('No vehicle nearby', "error", 2500)
    end
end)

Hey man, so I added it like this:

local QBCore = exports['qb-core']:GetCoreObject()

RegisterNetEvent("plate:removePlate")
AddEventHandler("plate:removePlate", function()
    local vehicle = QBCore.Functions.GetClosestVehicle()
    local plate =  GetVehicleNumberPlateText(vehicle)
    local vehCoords = GetEntityCoords(vehicle)
    local pos = GetEntityCoords(PlayerPedId())
    local close = #(pos - vehCoords) <= 3.5

    NetworkHasControlOfEntity(vehicle)
    NetworkRequestControlOfEntity(vehicle)

    if close then
        QBCore.Functions.TriggerCallback('QBCore:HasItem', function(result)
            if result then
                local seconds = math.random(6,10)
                local circles = math.random(4,6)
                local success = exports['qb-lock']:StartLockPickCircle(circles, seconds, success)
                if success then
                    QBCore.Functions.Progressbar("plateremoval", "Removing Plate..", math.random(7500, 12000), false, true, {
                        disableMovement = true,
                        disableCarMovement = true,
                        disableMouse = false,
                        disableCombat = true,
                    }, {
                        animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
                        anim = "machinic_loop_mechandplayer",
                        flags = 0,
                    }, {}, {}, function() -- Done
                        ClearPedTasks(PlayerPedId())
                        TriggerServerEvent('plate:addPlate', plate)
                        Wait(500)
                        SetVehicleNumberPlateText(vehicle, "")
                    end, function() -- Cancel
                        ClearPedTasks(PlayerPedId())
                        QBCore.Functions.Notify("Process Canceled", "error")
                    end)
                else
                    QBCore.Functions.Notify("Failed to remove plate", "error")
                end
            else
                QBCore.Functions.Notify("You don\'t have the right tools.", "error")
            end
        end, 'screwdriverset')
    else
        QBCore.Functions.Notify('No vehicle nearby', "error", 2500)
    end
end)

RegisterNetEvent('plate:installFakePlate')
AddEventHandler('plate:installFakePlate', function(data)
    local playerPed = PlayerPedId()
    local vehicle = QBCore.Functions.GetClosestVehicle()
    local plate =  GetVehicleNumberPlateText(vehicle)
    local vehCoords = GetEntityCoords(vehicle)
    local pos = GetEntityCoords(playerPed)
    local close = #(pos - vehCoords) <= 3.5

    NetworkHasControlOfEntity(vehicle)
    NetworkRequestControlOfEntity(vehicle)

    if close then
        if QBCore.Functions.HasItem('screwdriverset') then
            QBCore.Functions.Progressbar("fake_plate", "Removing Plate..", math.random(7500, 12000), false, true, {
                disableMovement = true,
                disableCarMovement = true,
                disableMouse = false,
                disableCombat = true,
            }, {
                animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
                anim = "machinic_loop_mechandplayer",
                flags = 0,
            }, {}, {}, function() -- Done
                QBCore.Functions.Progressbar("install_fake_plate", "Installing Fake Plate..", math.random(7500, 12000), false, true, {
                    disableMovement = true,
                    disableCarMovement = true,
                    disableMouse = false,
                    disableCombat = true,
                }, {
                    animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
                    anim = "machinic_loop_mechandplayer",
                    flags = 0,
                }, {}, {}, function() -- Done
                    TriggerServerEvent('plate:addPlate', plate)
                    SetVehicleNumberPlateText(vehicle, data)
                    TriggerServerEvent('plate:takeFakePlate')
                    ClearPedTasks(playerPed)
                end, function() -- Cancel
                    ClearPedTasks(playerPed)
                    QBCore.Functions.Notify("Process Canceled", "error")
                end)
            end, function() -- Cancel
                ClearPedTasks(playerPed)
                QBCore.Functions.Notify("Process Canceled", "error")
            end)
        else QBCore.Functions.Notify("You don\'t have the right tools.", "error")
        end
    else QBCore.Functions.Notify('No vehicle nearby', "error", 2500)
    end
end)

RegisterNetEvent('plate:installFakePlate')
AddEventHandler('plate:installFakePlate', function(data)
    local vehicle = QBCore.Functions.GetClosestVehicle()
    local plate =  GetVehicleNumberPlateText(vehicle)
    local vehCoords = GetEntityCoords(vehicle)
    local pos = GetEntityCoords(PlayerPedId())
    local close = #(pos - vehCoords) <= 3.5

    NetworkHasControlOfEntity(vehicle)
    NetworkRequestControlOfEntity(vehicle)

    if close then
        QBCore.Functions.TriggerCallback('QBCore:HasItem', function(result)
            if result then
                QBCore.Functions.Progressbar("fake_plate", "Removing Plate..", math.random(7500, 12000), false, true, {
                    disableMovement = true,
                    disableCarMovement = true,
                    disableMouse = false,
                    disableCombat = true,
                }, {
                    animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
                    anim = "machinic_loop_mechandplayer",
                    flags = 0,
                }, {}, {}, function() -- Done
                    QBCore.Functions.Progressbar("install_fake_plate", "Installing Fake Plate..", math.random(7500, 12000), false, true, {
                        disableMovement = true,
                        disableCarMovement = true,
                        disableMouse = false,
                        disableCombat = true,
                    }, {
                        animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
                        anim = "machinic_loop_mechandplayer",
                        flags = 0,
                    }, {}, {}, function() -- Done
                        TriggerServerEvent('plate:addPlate', plate)
                        SetVehicleNumberPlateText(vehicle, data)
                        TriggerServerEvent('plate:takeFakePlate')
                        ClearPedTasks(PlayerPedId())
                    end, function() -- Cancel
                        ClearPedTasks(PlayerPedId())
                        QBCore.Functions.Notify("Process Canceled", "error")
                    end)
                end, function() -- Cancel
                    ClearPedTasks(PlayerPedId())
                    QBCore.Functions.Notify("Process Canceled", "error")
                end)
            else
                QBCore.Functions.Notify("You don\'t have the right tools.", "error")
            end  
        end, 'screwdriverset')
    else
        QBCore.Functions.Notify('No vehicle nearby', "error", 2500)
    end
end)

But still the same error as in the image on original post. Did I add it in the wrong place or?

You didn’t remove your old event handler.

I don’t get this man, I put it where I think it needs to go but still doesn’t work, can you show me where exactly or just put the whole part here? :rofl:

It’s making me go crazy now trying over and over again, here is what I did this time:

local QBCore = exports['qb-core']:GetCoreObject()

RegisterNetEvent("plate:removePlate")
AddEventHandler("plate:removePlate", function()
    local vehicle = QBCore.Functions.GetClosestVehicle()
    local plate =  GetVehicleNumberPlateText(vehicle)
    local vehCoords = GetEntityCoords(vehicle)
    local pos = GetEntityCoords(PlayerPedId())
    local close = #(pos - vehCoords) <= 3.5

    NetworkHasControlOfEntity(vehicle)
    NetworkRequestControlOfEntity(vehicle)

    if close then
        QBCore.Functions.TriggerCallback('QBCore:HasItem', function(result)
            if result then
                local seconds = math.random(6,10)
                local circles = math.random(4,6)
                local success = exports['qb-lock']:StartLockPickCircle(circles, seconds, success)
                if success then
                    QBCore.Functions.Progressbar("plateremoval", "Removing Plate..", math.random(7500, 12000), false, true, {
                        disableMovement = true,
                        disableCarMovement = true,
                        disableMouse = false,
                        disableCombat = true,
                    }, {
                        animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
                        anim = "machinic_loop_mechandplayer",
                        flags = 0,
                    }, {}, {}, function() -- Done
                        ClearPedTasks(PlayerPedId())
                        TriggerServerEvent('plate:addPlate', plate)
                        Wait(500)
                        SetVehicleNumberPlateText(vehicle, "")
                    end, function() -- Cancel
                        ClearPedTasks(PlayerPedId())
                        QBCore.Functions.Notify("Process Canceled", "error")
                    end)
                else
                    QBCore.Functions.Notify("Failed to remove plate", "error")
                end
            else
                QBCore.Functions.Notify("You don\'t have the right tools.", "error")
            end
        end, 'screwdriverset')
    else
        QBCore.Functions.Notify('No vehicle nearby', "error", 2500)
    end
end)

RegisterNetEvent('plate:installPlate')
AddEventHandler('plate:installPlate', function(data)
    local vehicle = QBCore.Functions.GetClosestVehicle()
    local plate =  GetVehicleNumberPlateText(vehicle)
    local vehCoords = GetEntityCoords(vehicle)
    local pos = GetEntityCoords(PlayerPedId())
    local close = #(pos - vehCoords) <= 3.5

    NetworkHasControlOfEntity(vehicle)
    NetworkRequestControlOfEntity(vehicle)

    if close then
        QBCore.Functions.TriggerCallback('QBCore:HasItem', function(result)
            if result then
                QBCore.Functions.Progressbar("installing", "Removing Current Plate..", math.random(7500, 12000), false, true, {
                    disableMovement = true,
                    disableCarMovement = true,
                    disableMouse = false,
                    disableCombat = true,
                }, {
                    animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
                    anim = "machinic_loop_mechandplayer",
                    flags = 0,
                }, {}, {}, function() -- Done
                    QBCore.Functions.Progressbar("installing", "Installing Plate..", math.random(7500, 12000), false, true, {
                        disableMovement = true,
                        disableCarMovement = true,
                        disableMouse = false,
                        disableCombat = true,
                    }, {
                        animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
                        anim = "machinic_loop_mechandplayer",
                        flags = 0,
                    }, {}, {}, function() -- Done
                        ClearPedTasks(PlayerPedId())
                        SetVehicleNumberPlateText(vehicle, data)
                        TriggerServerEvent('plate:takePlate')
                        TriggerServerEvent('plate:addPlate', plate)
                    end, function() -- Cancel
                        ClearPedTasks(PlayerPedId())
                        QBCore.Functions.Notify("Process Canceled", "error")
                    end)
                end, function() -- Cancel
                    ClearPedTasks(PlayerPedId())
                    QBCore.Functions.Notify("Process Canceled", "error")
                end)

            else
                QBCore.Functions.Notify("You don\'t have the right tools.", "error")
            end
        end, 'screwdriverset')
    else
        QBCore.Functions.Notify('No vehicle nearby', "error", 2500)
    end
end)

RegisterNetEvent('plate:installFakePlate')
AddEventHandler('plate:installFakePlate', function(data)
    local playerPed = PlayerPedId()
    local vehicle = QBCore.Functions.GetClosestVehicle()
    local plate =  GetVehicleNumberPlateText(vehicle)
    local vehCoords = GetEntityCoords(vehicle)
    local pos = GetEntityCoords(playerPed)
    local close = #(pos - vehCoords) <= 3.5

    NetworkHasControlOfEntity(vehicle)
    NetworkRequestControlOfEntity(vehicle)

    if close then
        if QBCore.Functions.HasItem('screwdriverset') then
            QBCore.Functions.Progressbar("fake_plate", "Removing Plate..", math.random(7500, 12000), false, true, {
                disableMovement = true,
                disableCarMovement = true,
                disableMouse = false,
                disableCombat = true,
            }, {
                animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
                anim = "machinic_loop_mechandplayer",
                flags = 0,
            }, {}, {}, function() -- Done
                QBCore.Functions.Progressbar("install_fake_plate", "Installing Fake Plate..", math.random(7500, 12000), false, true, {
                    disableMovement = true,
                    disableCarMovement = true,
                    disableMouse = false,
                    disableCombat = true,
                }, {
                    animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
                    anim = "machinic_loop_mechandplayer",
                    flags = 0,
                }, {}, {}, function() -- Done
                    TriggerServerEvent('plate:addPlate', plate)
                    SetVehicleNumberPlateText(vehicle, data)
                    TriggerServerEvent('plate:takeFakePlate')
                    ClearPedTasks(playerPed)
                end, function() -- Cancel
                    ClearPedTasks(playerPed)
                    QBCore.Functions.Notify("Process Canceled", "error")
                end)
            end, function() -- Cancel
                ClearPedTasks(playerPed)
                QBCore.Functions.Notify("Process Canceled", "error")
            end)
        else QBCore.Functions.Notify("You don\'t have the right tools.", "error")
        end
    else QBCore.Functions.Notify('No vehicle nearby', "error", 2500)
    end
end)

The part I changed which is the part you gave me is the (installFakePlate) event handler right?

local QBCore = exports['qb-core']:GetCoreObject()

RegisterNetEvent("plate:removePlate")
AddEventHandler("plate:removePlate", function()
    local vehicle = QBCore.Functions.GetClosestVehicle()
    local plate =  GetVehicleNumberPlateText(vehicle)
    local vehCoords = GetEntityCoords(vehicle)
    local pos = GetEntityCoords(PlayerPedId())
    local close = #(pos - vehCoords) <= 3.5

    NetworkHasControlOfEntity(vehicle)
    NetworkRequestControlOfEntity(vehicle)

    if close then
        if QBCore.Functions.HasItem('screwdriverset') then
            if result then
                local seconds = math.random(6,10)
                local circles = math.random(4,6)
                local success = exports['qb-lock']:StartLockPickCircle(circles, seconds, success)
                if success then
                    QBCore.Functions.Progressbar("plateremoval", "Removing Plate..", math.random(7500, 12000), false, true, {
                        disableMovement = true,
                        disableCarMovement = true,
                        disableMouse = false,
                        disableCombat = true,
                    }, {
                        animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
                        anim = "machinic_loop_mechandplayer",
                        flags = 0,
                    }, {}, {}, function() -- Done
                        ClearPedTasks(PlayerPedId())
                        TriggerServerEvent('plate:addPlate', plate)
                        Wait(500)
                        SetVehicleNumberPlateText(vehicle, "")
                    end, function() -- Cancel
                        ClearPedTasks(PlayerPedId())
                        QBCore.Functions.Notify("Process Canceled", "error")
                    end)
                else
                    QBCore.Functions.Notify("Failed to remove plate", "error")
                end
            else
                QBCore.Functions.Notify("You don\'t have the right tools.", "error")
            end
        end)
    else
        QBCore.Functions.Notify('No vehicle nearby', "error", 2500)
    end
end)

RegisterNetEvent('plate:installPlate')
AddEventHandler('plate:installPlate', function(data)
    local vehicle = QBCore.Functions.GetClosestVehicle()
    local plate =  GetVehicleNumberPlateText(vehicle)
    local vehCoords = GetEntityCoords(vehicle)
    local pos = GetEntityCoords(PlayerPedId())
    local close = #(pos - vehCoords) <= 3.5

    NetworkHasControlOfEntity(vehicle)
    NetworkRequestControlOfEntity(vehicle)

    if close then
        if QBCore.Functions.HasItem('screwdriverset') then
            if result then
                QBCore.Functions.Progressbar("installing", "Removing Current Plate..", math.random(7500, 12000), false, true, {
                    disableMovement = true,
                    disableCarMovement = true,
                    disableMouse = false,
                    disableCombat = true,
                }, {
                    animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
                    anim = "machinic_loop_mechandplayer",
                    flags = 0,
                }, {}, {}, function() -- Done
                    QBCore.Functions.Progressbar("installing", "Installing Plate..", math.random(7500, 12000), false, true, {
                        disableMovement = true,
                        disableCarMovement = true,
                        disableMouse = false,
                        disableCombat = true,
                    }, {
                        animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
                        anim = "machinic_loop_mechandplayer",
                        flags = 0,
                    }, {}, {}, function() -- Done
                        ClearPedTasks(PlayerPedId())
                        SetVehicleNumberPlateText(vehicle, data)
                        TriggerServerEvent('plate:takePlate')
                        TriggerServerEvent('plate:addPlate', plate)
                    end, function() -- Cancel
                        ClearPedTasks(PlayerPedId())
                        QBCore.Functions.Notify("Process Canceled", "error")
                    end)
                end, function() -- Cancel
                    ClearPedTasks(PlayerPedId())
                    QBCore.Functions.Notify("Process Canceled", "error")
                end)

            else
                QBCore.Functions.Notify("You don\'t have the right tools.", "error")
            end
        end)
    else
        QBCore.Functions.Notify('No vehicle nearby', "error", 2500)
    end
end)

RegisterNetEvent('plate:installFakePlate')
AddEventHandler('plate:installFakePlate', function(data)
    local playerPed = PlayerPedId()
    local vehicle = QBCore.Functions.GetClosestVehicle()
    local plate =  GetVehicleNumberPlateText(vehicle)
    local vehCoords = GetEntityCoords(vehicle)
    local pos = GetEntityCoords(playerPed)
    local close = #(pos - vehCoords) <= 3.5

    NetworkHasControlOfEntity(vehicle)
    NetworkRequestControlOfEntity(vehicle)

    if close then
        if QBCore.Functions.HasItem('screwdriverset') then
            QBCore.Functions.Progressbar("fake_plate", "Removing Plate..", math.random(7500, 12000), false, true, {
                disableMovement = true,
                disableCarMovement = true,
                disableMouse = false,
                disableCombat = true,
            }, {
                animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
                anim = "machinic_loop_mechandplayer",
                flags = 0,
            }, {}, {}, function() -- Done
                QBCore.Functions.Progressbar("install_fake_plate", "Installing Fake Plate..", math.random(7500, 12000), false, true, {
                    disableMovement = true,
                    disableCarMovement = true,
                    disableMouse = false,
                    disableCombat = true,
                }, {
                    animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
                    anim = "machinic_loop_mechandplayer",
                    flags = 0,
                }, {}, {}, function() -- Done
                    TriggerServerEvent('plate:addPlate', plate)
                    SetVehicleNumberPlateText(vehicle, data)
                    TriggerServerEvent('plate:takeFakePlate')
                    ClearPedTasks(playerPed)
                end, function() -- Cancel
                    ClearPedTasks(playerPed)
                    QBCore.Functions.Notify("Process Canceled", "error")
                end)
            end, function() -- Cancel
                ClearPedTasks(playerPed)
                QBCore.Functions.Notify("Process Canceled", "error")
            end)
        else QBCore.Functions.Notify("You don\'t have the right tools.", "error")
        end
    else QBCore.Functions.Notify('No vehicle nearby', "error", 2500)
    end
end)

Doesn’t work mate, when I press the license plate to do the action as it did before, nothing initiates now, no errors though.

Did you check the (server.lua) in the download too? maybe this needs something changing too?

local QBCore = exports['qb-core']:GetCoreObject()

RegisterServerEvent('plate:addPlate', function(data)
    local Player = QBCore.Functions.GetPlayer(source)
    info = {
        plate = data
    }
    Player.Functions.AddItem('license_plate', 1, false, info)
    TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items['license_plate'], 'add')
end)

RegisterNetEvent('plate:takeFakePlate', function(data)
    local Player = QBCore.Functions.GetPlayer(source)
    Player.Functions.RemoveItem('fake_plate', 1, false, info)
    TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items['fake_plate'], 'remove')
end)


RegisterNetEvent('plate:takePlate', function(data)
    local Player = QBCore.Functions.GetPlayer(source)
    Player.Functions.RemoveItem('license_plate', 1, false, info)
    TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items['license_plate'], 'remove')
end)

QBCore.Functions.CreateUseableItem("screwdriverset", function(source, item)
    local Player = QBCore.Functions.GetPlayer(source)
    if Player.Functions.GetItemBySlot(item.slot) ~= nil then
        TriggerClientEvent("plate:removePlate", source)
    end
end)

QBCore.Functions.CreateUseableItem("fake_plate", function(source, item)
    local Player = QBCore.Functions.GetPlayer(source)
    if Player.Functions.GetItemBySlot(item.slot) ~= nil then
        TriggerClientEvent('plate:installFakePlate', source, item.info.plate)
    end
end)

QBCore.Functions.CreateUseableItem("license_plate", function(source, item)
    local Player = QBCore.Functions.GetPlayer(source)
    if Player.Functions.GetItemBySlot(item.slot) ~= nil then
        TriggerClientEvent('plate:installPlate', source, item.info.plate)
    end
end)

Do you have the item?

yea mate, exactly as I had before, in my number (5) bar, I’d press 5 and then it would do the action and then put up that error I showed in the original post screenshot, but now when pressing 5 and having the plates/screwdriverset nothing happens.

Edit: Alright, so was just playing around in-game with it (stopping) and (starting) and noticed this now:

https://imgur.com/RG7QapH

Seems to be a typo? I checked and can’t make it out.

2nd Edit: So I have been playing around with it more, trying to figure it out, it seems on lines 45 and 101 where it is:

end)

seems to be the problem.

Sorry, didn’t notice it. Just change it to end.

Okay so that makes the animation and action work again as before, but upon getting to (installing fake plate) it gives out the error as shown before in first post :expressionless:

local QBCore = exports['qb-core']:GetCoreObject()

RegisterNetEvent("plate:removePlate")
AddEventHandler("plate:removePlate", function()
    local vehicle = QBCore.Functions.GetClosestVehicle()
    local plate =  GetVehicleNumberPlateText(vehicle)
    local vehCoords = GetEntityCoords(vehicle)
    local pos = GetEntityCoords(PlayerPedId())
    local close = #(pos - vehCoords) <= 3.5

    NetworkHasControlOfEntity(vehicle)
    NetworkRequestControlOfEntity(vehicle)

    if close then
        if QBCore.Functions.HasItem('screwdriverset') then
                local seconds = math.random(6,10)
                local circles = math.random(4,6)
                local success = exports['qb-lock']:StartLockPickCircle(circles, seconds, success)
                if success then
                    QBCore.Functions.Progressbar("plateremoval", "Removing Plate..", math.random(7500, 12000), false, true, {
                        disableMovement = true,
                        disableCarMovement = true,
                        disableMouse = false,
                        disableCombat = true,
                    }, {
                        animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
                        anim = "machinic_loop_mechandplayer",
                        flags = 0,
                    }, {}, {}, function() -- Done
                        ClearPedTasks(PlayerPedId())
                        TriggerServerEvent('plate:addPlate', plate)
                        Wait(500)
                        SetVehicleNumberPlateText(vehicle, "")
                    end, function() -- Cancel
                        ClearPedTasks(PlayerPedId())
                        QBCore.Functions.Notify("Process Canceled", "error")
                    end)
                else
                    QBCore.Functions.Notify("Failed to remove plate", "error")
                end
            else
                QBCore.Functions.Notify("You don\'t have the right tools.", "error")
            end
    else
        QBCore.Functions.Notify('No vehicle nearby', "error", 2500)
    end
end)

RegisterNetEvent('plate:installPlate')
AddEventHandler('plate:installPlate', function(data)
    local vehicle = QBCore.Functions.GetClosestVehicle()
    local plate =  GetVehicleNumberPlateText(vehicle)
    local vehCoords = GetEntityCoords(vehicle)
    local pos = GetEntityCoords(PlayerPedId())
    local close = #(pos - vehCoords) <= 3.5

    NetworkHasControlOfEntity(vehicle)
    NetworkRequestControlOfEntity(vehicle)

    if close then
        if QBCore.Functions.HasItem('screwdriverset') then
                QBCore.Functions.Progressbar("installing", "Removing Current Plate..", math.random(7500, 12000), false, true, {
                    disableMovement = true,
                    disableCarMovement = true,
                    disableMouse = false,
                    disableCombat = true,
                }, {
                    animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
                    anim = "machinic_loop_mechandplayer",
                    flags = 0,
                }, {}, {}, function() -- Done
                    QBCore.Functions.Progressbar("installing", "Installing Plate..", math.random(7500, 12000), false, true, {
                        disableMovement = true,
                        disableCarMovement = true,
                        disableMouse = false,
                        disableCombat = true,
                    }, {
                        animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
                        anim = "machinic_loop_mechandplayer",
                        flags = 0,
                    }, {}, {}, function() -- Done
                        ClearPedTasks(PlayerPedId())
                        SetVehicleNumberPlateText(vehicle, data)
                        TriggerServerEvent('plate:takePlate')
                        TriggerServerEvent('plate:addPlate', plate)
                    end, function() -- Cancel
                        ClearPedTasks(PlayerPedId())
                        QBCore.Functions.Notify("Process Canceled", "error")
                    end)
                end, function() -- Cancel
                    ClearPedTasks(PlayerPedId())
                    QBCore.Functions.Notify("Process Canceled", "error")
                end)

        else
              QBCore.Functions.Notify("You don\'t have the right tools.", "error")
        end
    else
        QBCore.Functions.Notify('No vehicle nearby', "error", 2500)
    end
end)

RegisterNetEvent('plate:installFakePlate')
AddEventHandler('plate:installFakePlate', function(data)
    local playerPed = PlayerPedId()
    local vehicle = QBCore.Functions.GetClosestVehicle()
    local plate =  GetVehicleNumberPlateText(vehicle)
    local vehCoords = GetEntityCoords(vehicle)
    local pos = GetEntityCoords(playerPed)
    local close = #(pos - vehCoords) <= 3.5

    NetworkHasControlOfEntity(vehicle)
    NetworkRequestControlOfEntity(vehicle)

    if close then
        if QBCore.Functions.HasItem('screwdriverset') then
            QBCore.Functions.Progressbar("fake_plate", "Removing Plate..", math.random(7500, 12000), false, true, {
                disableMovement = true,
                disableCarMovement = true,
                disableMouse = false,
                disableCombat = true,
            }, {
                animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
                anim = "machinic_loop_mechandplayer",
                flags = 0,
            }, {}, {}, function() -- Done
                QBCore.Functions.Progressbar("install_fake_plate", "Installing Fake Plate..", math.random(7500, 12000), false, true, {
                    disableMovement = true,
                    disableCarMovement = true,
                    disableMouse = false,
                    disableCombat = true,
                }, {
                    animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
                    anim = "machinic_loop_mechandplayer",
                    flags = 0,
                }, {}, {}, function() -- Done
                    TriggerServerEvent('plate:addPlate', plate)
                    SetVehicleNumberPlateText(vehicle, data)
                    TriggerServerEvent('plate:takeFakePlate')
                    ClearPedTasks(playerPed)
                end, function() -- Cancel
                    ClearPedTasks(playerPed)
                    QBCore.Functions.Notify("Process Canceled", "error")
                end)
            end, function() -- Cancel
                ClearPedTasks(playerPed)
                QBCore.Functions.Notify("Process Canceled", "error")
            end)
        else QBCore.Functions.Notify("You don\'t have the right tools.", "error")
        end
    else QBCore.Functions.Notify('No vehicle nearby', "error", 2500)
    end
end)

Nope, still an error, this time different lines :laughing:

!Bump, is anyone able to get this to work? :neutral_face:

When you hover over the fake plate item in your inventory, does it have any info attached to it, like this?:
img

That all works, even the plates show up in my inventory of the car I took it from, just the very last part where it is supposed to change the plate fails and shows an error.

The error is pointing to this line → SetVehicleNumberPlateText(vehicle, data)

In this final part:

   if close then
        if QBCore.Functions.HasItem('screwdriverset') then
            QBCore.Functions.Progressbar("fake_plate", "Removing Plate..", math.random(7500, 12000), false, true, {
                disableMovement = true,
                disableCarMovement = true,
                disableMouse = false,
                disableCombat = true,
            }, {
                animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
                anim = "machinic_loop_mechandplayer",
                flags = 0,
            }, {}, {}, function() -- Done
                QBCore.Functions.Progressbar("install_fake_plate", "Installing Fake Plate..", math.random(7500, 12000), false, true, {
                    disableMovement = true,
                    disableCarMovement = true,
                    disableMouse = false,
                    disableCombat = true,
                }, {
                    animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
                    anim = "machinic_loop_mechandplayer",
                    flags = 0,
                }, {}, {}, function() -- Done
                    TriggerServerEvent('plate:addPlate', plate)
                    SetVehicleNumberPlateText(vehicle, data)
                    TriggerServerEvent('plate:takeFakePlate')
                    ClearPedTasks(playerPed)
                end, function() -- Cancel
                    ClearPedTasks(playerPed)
                    QBCore.Functions.Notify("Process Canceled", "error")
                end)
            end, function() -- Cancel
                ClearPedTasks(playerPed)
                QBCore.Functions.Notify("Process Canceled", "error")
            end)
        else QBCore.Functions.Notify("You don\'t have the right tools.", "error")
        end
    else QBCore.Functions.Notify('No vehicle nearby', "error", 2500)
    end
end)