MrNewbScripts
My DiscordSee The StoreCommunity_BridgeGithub
  • MOTD
  • MrNewbVehicleKeys
    • Install
      • Framework
        • esx
        • qb-core
        • qbox
      • inventory
        • 🐂ox_inventory
        • qb-inventory
        • qb-inventoryv2
        • origen_inventory
        • ps-inventory
        • jpr-inventory
        • qs-inventory
      • Inventory Images
    • Exports
      • Server Exports
      • Client Exports
    • Backwards Events
      • Client Events
      • Server Events
    • FAQ
    • Commands
    • Snippet Examples
      • qb-vehicleshop
      • qb-garages
      • Common qb-core Snippets
  • MrNewbBeeKeeping
    • Install
      • Frameworks
        • qb-core
        • qbox
        • ESX
      • Inventory Images
      • Inventory
        • 🐂ox_inventory
  • MrNewbPrescriptions
    • Install
      • Framework
        • qb-core
        • qbox
        • ESX
      • inventory
        • 🐂ox inventory
        • qs-inventory
        • qb-inventory V1
        • qb-inventory v2
      • Inventory Images
    • Exports
      • Server Exports
      • Client Exports
    • Snippet Examples
      • qb-drugs
      • qbx_ambulancejob
    • FAQ
  • MrNewbPlateCarriers
    • Install
      • Framework
        • qb-core
        • qbox
        • ESX
      • inventory
        • 🐂ox_inventory
        • qb-inventoryv2
      • Inventory Images
    • Exports
      • Server Exports
  • MrNewbCustomPlates
    • Install
      • Framework
        • qb-core
        • qbox
        • ESX
      • inventory
        • ox_inventory Steps
      • Inventory Images
  • MrNewbNameChanger
    • Install
      • Frameworks
        • qb-core
        • qbox
        • ESX
      • Inventory
        • 🐂ox_inventory
        • ps-inventory
        • qb-inventoryv2
        • qb-inventory
      • Inventory Images
  • MrNewbPawn
    • Install
  • MrNewbPhoneTracker
    • Install
      • Frameworks
        • qb-core
        • qbox
        • ESX
      • Inventory Images
      • Inventory
        • 🐂ox_inventory
  • MrNewbWeaponTints
    • Install
      • inventory
        • ox_inventory Steps
      • Inventory Images
  • MrNewbGiftBox
    • Install
      • Framework
        • qb-core
        • qbox
        • ESX
      • inventory
        • ox_inventory Steps
      • Inventory Images
    • Exports
      • Server Exports
Powered by GitBook
On this page
  • Granting Keys
  • Removing Keys
  1. MrNewbVehicleKeys
  2. Snippet Examples

qb-garages

Snippet example use case in garages.

Here is a client side example on the usage of my exports in the script.

Granting Keys

RegisterNetEvent('qb-garages:client:takeOutGarage', function(data)
    QBCore.Functions.TriggerCallback('qb-garages:server:IsSpawnOk', function(spawn)
        if spawn then
            local location = GetSpawnPoint(data.garage)
            if not location then return end
            QBCore.Functions.TriggerCallback('qb-garages:server:spawnvehicle', function(netId, properties, vehPlate)
                while not NetworkDoesNetworkIdExist(netId) do Wait(10) end
                local veh = NetworkGetEntityFromNetworkId(netId)
                Citizen.Await(CheckPlate(veh, vehPlate))
                QBCore.Functions.SetVehicleProperties(veh, properties)
                exports[Config.FuelResource]:SetFuel(veh, data.stats.fuel)
                TriggerServerEvent('qb-garages:server:updateVehicleState', 0, vehPlate)
                --TriggerEvent('vehiclekeys:client:SetOwner', vehPlate)
                exports.MrNewbVehicleKeys:GiveKeys(veh) -- add this here
                if Config.Warp then TaskWarpPedIntoVehicle(PlayerPedId(), veh, -1) end
                if Config.VisuallyDamageCars then doCarDamage(veh, data.stats, properties) end
                SetVehicleEngineOn(veh, true, true, false)
            end, data.plate, data.vehicle, location, true)
        else
            QBCore.Functions.Notify(Lang:t('error.not_depot'), 'error', 5000)
        end
    end, data.plate, data.type)
end)

In the above example I left in the commented out code so you can see the similar option below it.

Removing Keys

local function CheckPlayers(vehicle)
    for i = -1, 5, 1 do
        local seat = GetPedInVehicleSeat(vehicle, i)
        if seat then
            TaskLeaveVehicle(seat, vehicle, 0)
        end
    end
    exports.MrNewbVehicleKeys:RemoveKeys(vehicle) -- Add this here
    Wait(1000)
    QBCore.Functions.DeleteVehicle(vehicle)
end

Previousqb-vehicleshopNextCommon qb-core Snippets

Last updated 3 months ago