Can you add your car keys event? Because I don’t know what you are using
Replace server.lua with the following code;
RegisterServerEvent("customplates:buyPlate", function(newPlate, oldPlate)
local src = source
local cost = 1000
if not newPlate or #newPlate < 5 or #newPlate > 8 or not newPlate:match("^[A-Z0-9]+$") then
TriggerClientEvent('esx:showNotification', src, 'The plate is invalid.', 'error', 5000)
return
end
local exists = MySQL.scalar.await("SELECT 1 FROM owned_vehicles WHERE plate = ?", { newPlate })
if exists then
TriggerClientEvent('esx:showNotification', src, 'This plate is already in use.', 'error', 5000)
return
end
MySQL.update.await("UPDATE owned_vehicles SET plate = ? WHERE plate = ?", {
newPlate, oldPlate
})
TriggerClientEvent('esx:showNotification', src, 'License plate replaced successfully!', 'success', 5000)
TriggerClientEvent("customplates:updateVehiclePlate", src, newPlate)
TriggerClientEvent("customplates:closeUI", src)
end)