its a lootbox script and it doesnt spawn the vehicles when i win them.
RegisterNetEvent(‘lootbox:RewardVehicle’)
AddEventHandler(‘lootbox:RewardVehicle’, function(model)
– local playerPed = GetPlayerPed(-1)
– local coords = GetEntityCoords(playerPed)
– local Px, Py, Pz = table.unpack(coords)
ESX.SpawnVehicle(model, { x = 0, y = 0, z = 0 }, 180, function (vehicle)
-- TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
local newPlate = GeneratePlate()
local vehicleProps = ESX.GetVehicleProperties(vehicle)
vehicleProps.plate = newPlate
SetVehicleNumberPlateText(vehicle, newPlate)
TriggerServerEvent('esx_vehicleshop:setVehicleOwned', vehicleProps)
end)
end)
anything wrong?
These are commented as you see. Uncomment them.
thanks got any fix for the bottom part. the car wont add to garage
Manta
4
Because of this : TriggerServerEvent(‘esx_vehicleshop:setVehicleOwned’, vehicleProps)
You may not have this serverEvent in your vehicleshop script.
add this in server/main.lua
RegisterServerEvent(‘esx_vehicleshop:setVehicleOwned’)
AddEventHandler(‘esx_vehicleshop:setVehicleOwned’, function (vehicleProps)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
MySQL.Async.execute('INSERT INTO owned_vehicles (owner, plate, vehicle) VALUES (@owner, @plate, @vehicle)',
{
['@owner'] = xPlayer.identifier,
['@plate'] = vehicleProps.plate,
['@vehicle'] = json.encode(vehicleProps)
}, function (rowsChanged)
end)
end)
system
Closed
5
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.