Modifications
Remember that this resource has verified DMCA protection, and its illegal use or distribution could imply a claim for protection of Title 17 of Chapter 512 (c) (3) of the Digital Millennium Copyright Act


In order for the item information to appear in our inventory, we must add the following line in our config_metadata.js in case of qs-inventory, or qb-inventory/html/js/app.js
1
} else if (itemData.name == "vehiclekeys") {
2
$(".item-info-title").html("<p>" + itemData.label + "</p>");
3
$(".item-info-description").html(
4
"<p><strong>Plate: </strong><span>" +
5
itemData.info.plate +
6
"</span></p><p><strong>Model: </strong><span>" +
7
itemData.info.description +
8
"</span></p>"
9
);
This trigger works to give the user the vehicle keys that you choose, you need to send 2 values on your script.
Client side
TriggerServerEvent('vehiclekeys:server:givekey', plate, model)
This trigger deletes the keys that the user has as long as you send the correct key information. Just like the other trigger you need to send the plate and model values.
Client side
TriggerServerEvent('vehiclekeys:server:removekey', plate, model)
It is the registration of the vehicle, mostly you can use it
local vehicle = GetVehiclePedIsIn(playerPed, false) -- https://docs.fivem.net/natives/?_0x9A9112A0FE9A4713
local plate = GetVehicleNumberPlateText(vehicle) -- https://docs.fivem.net/natives/?_0xE8522D58
local vehicle = GetVehiclePedIsIn(playerPed, false) -- https://docs.fivem.net/natives/?_0x9A9112A0FE9A4713
local plate = QBCore.Functions.GetVehicleProperties(vehicle).plate -- https://docs.qbcore.org/qbcore-documentation/qb-core/client-function-reference#qbcore.functions.getvehicleproperties
These are just examples, you can send the vehicle however you want, it depends a lot on the script.
This one is a little more complicated because many times it is not sent by the scripts or you have to do it manually, this one is a little more complicated because many times it is not sent by the scripts or you have to do it manually. But you can always use the same code since you need the entity.
local vehicle = GetVehiclePedIsIn(playerPed, false)
local model = GetDisplayNameFromVehicleModel(GetEntityModel(vehicle))
-- https://docs.fivem.net/natives/?_0xB215AAC32D25D019
-- https://docs.fivem.net/natives/?_0x9F47B058362C84B5
The script will warn you when you send the wrong values, but I recommend you always use print() to see if you are doing it right

For the resource to work, we need to add the event that gives you the keys in our scripts that call the vehicle, although it would work just the same if you just add it in your vehicleshop
Please make sure you have basic knowledge to add this event, as supporters are not your personal developers
The event below consists of two parts, as we can see it requires adding a
plate
and a model
so that the keys take the metadataWe will need to modify the
plate
and model
part to make it work with our resourcesTriggerServerEvent('vehiclekeys:server:givekey', plate, model)
We can follow the
qb-vehicleshop
example like this in qb-vehicleshop/client.lua
:RegisterNetEvent('qb-vehicleshop:client:buyShowroomVehicle', function(vehicle, plate)
tempShop = insideShop -- temp hacky way of setting the shop because it changes after the callback has returned since you are outside the zone
QBCore.Functions.TriggerCallback('QBCore:Server:SpawnVehicle', function(netId)
local veh = NetToVeh(netId)
exports['LegacyFuel']:SetFuel(veh, 100)
SetVehicleNumberPlateText(veh, plate)
SetEntityHeading(veh, Config.Shops[tempShop]["VehicleSpawn"].w)
TriggerServerEvent('vehiclekeys:server:givekey', QBCore.Functions.GetPlate(veh), vehicle)
TriggerServerEvent("qb-vehicletuning:server:SaveVehicleProps", QBCore.Functions.GetVehicleProperties(veh))
end, vehicle, Config.Shops[tempShop]["VehicleSpawn"], true)
end)
Make sure to use it by modifying the value of "plate" and "model" to be compatible with your event
We also have an event to remove the keys, using the following event
TriggerServerEvent('vehiclekeys:server:removekey', plate, model)
Last modified 9d ago