DRC Scripts

Give Vehicle Keys:

SpawnVehicle = function(model, coords, heading, livery)
    if Config.Framework == "ESX" then
        ESX.Game.SpawnVehicle(model, coords, heading, function(vehicle)
            SetEntityHeading(vehicle, heading)
            SetVehicleLivery(vehicle, livery)
            local plate = GetVehicleNumberPlateText(vehicle)
            exports['ic3d_vehiclekeys']:ClientInventoryKeys('add', plate)
        end)
    elseif Config.Framework == "qbcore" then
        QBCore.Functions.SpawnVehicle(model, function(vehicle)
            SetEntityHeading(vehicle, heading)
            SetVehicleLivery(vehicle, livery)
            local plate = QBCore.Functions.GetPlate(vehicle)
            exports['ic3d_vehiclekeys']:ClientInventoryKeys('add', plate)
        end, coords, true)
    elseif Config.Framework == "standalone" then
        -- Für Standalone ebenfalls Schlüssel hinzufügen
        local vehicle = CreateVehicle(model, coords.x, coords.y, coords.z, heading, true, false)
        SetEntityHeading(vehicle, heading)
        SetVehicleLivery(vehicle, livery)
        local plate = GetVehicleNumberPlateText(vehicle)
        exports['ic3d_vehiclekeys']:ClientInventoryKeys('add', plate)
    end
end

Remove Vehicle Keys:

GetClosestCar = function(coords)
    local vehicle

    if Config.Framework == "ESX" then
        vehicle = ESX.Game.GetClosestVehicle(coords)
    elseif Config.Framework == "qbcore" then
        vehicle = QBCore.Functions.GetClosestVehicle()
    elseif Config.Framework == "standalone" then
        -- eigenes Framework hier
        vehicle = GetClosestVehicle(coords.x, coords.y, coords.z, 5.0, 0, 70) -- Beispiel
    end

    if vehicle and vehicle ~= 0 then
        local plate = GetVehicleNumberPlateText(vehicle)
        if plate then
            exports['ic3d_vehiclekeys']:ClientInventoryKeys('remove', plate)
            print(("[VehicleKeys] Schlüssel für Fahrzeug %s entfernt."):format(plate))
        end
    end

    return vehicle
end

Last updated

Was this helpful?