Haha no problem, I test last night and it keeps saying I don’t own the vehicle when I do, so I’m gonna test a bit more and will let you know the issue if I find it, I’ll also give you the code for the item and a generic image for the inventory. Do you know if there’s a way to restrict its use by way of Discord role or similar?
I created a function recently but I guess I can share it.
ESX.CheckPerms = function(playerId, rolesArray)
local p = promise.new()
if rolesArray ~= nil then
exports['discordroles']:getUserRoles(playerId, function(roles)
if roles ~= nil then
for _, playerRole in pairs(roles) do
for _, role in pairs(rolesArray) do
if playerRole == role then
return p:resolve({a = true})
end
end
end
else
TriggerClientEvent('t-notify:client:Alert', playerId, {
style = 'error',
message = 'No estas en el discord'
})
end
return p:resolve({a = false})
end)
else
print("Array of data is missing")
return false
end
local result = Citizen.Await(p)
return result.a
end
It basically returns if the player has a discord role from the roles array. You just need discordroles
Regarding owning a vehicle. That’s probably due to Gmatt since I did not know how it works and my qbcore testing server is broken.
Right so to enable this in QB-Core you need to:
- Open shared.lua in qb-core, within the QBShared.Items section add a new item just like you normally do for QB-Core:
["licenseplate"] = {["name"] = "licenseplate", ["label"] = "Custom License Plate", ["weight"] = 0, ["type"] = "item", ["image"] = "licenseplate.png", ["unique"] = true, ["useable"] = true, ["shouldClose"] = true, ["combinable"] = nil, ["description"] = "A custom license plate!"},
(NOTE: Change “unique” to false if you want the item to stack.)
- Open your QB-Inventory\html\images\ folder (or whatever inventory system you use) and add this image (feel free to customise it to how you want it)
Image: https://imgur.com/tu9diBT.png
- then ingame do /giveitem licenseplate and there you go
NOTE:
For some reason it won’t allow you to use the plate in qb-core as the SQL stuff needs to be fixed.
Also the plate is limited to 6 characters but you can have 8 in fivem so i’ve self-edited it up to 8, just look for the number 6 in the script lua and adjust (not 100% sure if it’s working yet :P)
Thanks for that!
What do you need from the sql stuff for it to play correctly?
I’ll fix the SQL for QBCore today and add a config for max chars. I was doing another paid resource
You’re a machine! thanks mate!
So first off thanks for the info about where to add the item @nzkfc I had figured it out and came here to explain where to do it but noticed you already got it Second I’ve found where the issue is for the error of owning the car here (platechanger/server/plate.lua line: 142):
exports.ghmattimysql.execute(‘SELECT plate FROM owned_vehicles WHERE owner = @owner AND plate = @plate’, {
But all I know is that it’s player_vehicles not owned_vehicles. A little more information if needed. QBCore has a “fakeplate” in the database for player_vehicles
Ah I see. Thank you very for actually giving me some data on the issue. I’ll update it today.
Have you gotten to this yet? I can’t figure it out myself because I’m still new to all this but have a background with lua so I can understand what the issue was
Done.
New Stuff
- Fixed QBCore
- Blacklist words
- Max chars + 8 chars
- SQL for ESX
What button confirms after you’ve typed your new license plate? Cause every time I hit enter after it doesn’t work and if I hit ESC it removed the ability for me to use my mouse and buttons
Thanks, just ran a test, so get the plate fine, can use it, comes up perfectly, but exiting with ESC, Backspace or similar seems to throw an error in the JS file.
Then your mouse locks up, until you stop/restart the resource, console just spams the above.
There’s a config for that.
Did you rename the resource. If you did you can change the name of the resource on that line in your error. If you did not change the name then idk cause that doesn’t happen in my localhost.
Insert doesn’t work either. I’m just trying to figure out what to press to “confirm” the new plate in game
That still didn’t work. Also the limit for typing it out is still at 6. Like I can’t input more then 6 in the license plate
EDIT: It was still set to 6 in the ui.html and fixed that myself
There’s a config though?
Yes but in the ui.html it’s set to limit the input text to 6. (ui.html Line 20)
placeholder=“ABC123” maxlength=“6”
Yes. There’s a config which if you set to true, it will set max to 8.