Hi there fellas.
I grabbed the open source of This ESX Release and rewrote it to match QBCore framework.
All prizes must be configured by hand and some custom code need to be added into the qb-vehicleshop (look below for this code).
The car spawned inside the casino and defined in the luckywheel-script is the car qb-vehicleshop gives out when you win a car.
Download: Github
Installation:
Add to: qb-vehicleshop\client.lua
RegisterNetEvent('qb-vehicleshop:client:winCar', function (carname)
local vehicle = QBCore.Functions.GetClosestVehicle(vector3(935.01, 42.80, 72.43))
local showCar = carname
TriggerServerEvent('qb-vehicleshop:server:luckywheelWin', vehicle, showCar)
end)
RegisterNetEvent('qb-vehicleshop:client:winLuckyWheelVehicle', function(vehicle, plate)
QBCore.Functions.SpawnVehicle(carmodel, function(veh)
TaskWarpPedIntoVehicle(PlayerPedId(), veh, -1)
exports['LegacyFuel']:SetFuel(veh, 100)
SetVehicleNumberPlateText(veh, plate)
SetEntityHeading(veh, Config.LuckyWheel.w)
SetEntityAsMissionEntity(veh, true, true)
TriggerEvent("vehiclekeys:client:SetOwner", QBCore.Functions.GetPlate(veh))
TriggerServerEvent("qb-vehicletuning:server:SaveVehicleProps", QBCore.Functions.GetVehicleProperties(veh))
end, Config.LuckyWheel, true)
end)
Add to: qb-vehicleshop\server.lua
-- Win car at luckywheel
RegisterNetEvent('qb-vehicleshop:server:luckywheelWin', function(data, carname)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local PlayerData = Player.PlayerData
local vehicle = data
local showCar = carname
local plate = GeneratePlate()
MySQL.Async.insert('INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, state, garage) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', {
PlayerData.license,
PlayerData.citizenid,
carname,
GetHashKey(vehicle),
'{}',
plate,
1,
'casinovalet'
})
TriggerClientEvent('qb-vehicleshop:client:winLuckyWheelVehicle', src, vehicle, plate)
TriggerClientEvent('QBCore:Notify', src, 'Congratulations! Your vehicle can be claimed at the valet near the entrance.', 'success')
end)
Add a new garage named ācasinovaletā or change ācasinovaletā to your garage of choice.
Best regards, Revoxxi.