mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-03 11:48:53 +00:00
More WIP code
This commit is contained in:
+34
-6
@@ -2,9 +2,22 @@ ESX = nil
|
||||
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_boat:buyBoat', function (source, cb, vehicleProps, model)
|
||||
|
||||
--[[
|
||||
AddEventHandler('onMySQLReady', function()
|
||||
MySQL.Async.execute('UPDATE owned_vehicles SET stored = true WHERE stored = false', {}, function (rowsChanged)
|
||||
if rowsChanged > 0 then
|
||||
print('esx_boat: all boats have been stored!')
|
||||
end
|
||||
end)
|
||||
end)
|
||||
]]
|
||||
|
||||
ESX.RegisterServerCallback('esx_boat:buyBoat', function (source, cb, vehicleProps)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local price = getPriceFromModel(model)
|
||||
local price = getPriceFromModel(vehicleProps.modelAlt)
|
||||
|
||||
vehicleProps.modelAlt = nil
|
||||
|
||||
-- vehicle model not found
|
||||
if price == 0 then
|
||||
@@ -29,17 +42,32 @@ ESX.RegisterServerCallback('esx_boat:buyBoat', function (source, cb, vehicleProp
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_boat:takeOutVehicle')
|
||||
AddEventHandler('esx_boat:takeOutVehicle', function(plate)
|
||||
MySQL.Async.execute('UPDATE owned_vehicles SET stored = @stored WHERE owner = @owner AND plate = @plate',
|
||||
{
|
||||
['@stored'] = false,
|
||||
['@owner'] = GetPlayerIdentifiers(source)[1],
|
||||
['@plate'] = plate
|
||||
}, function (rowsChanged)
|
||||
print(rowsChanged)
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_boat:getGarage', function (source, cb)
|
||||
|
||||
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner, vehicleType = @vehicleType, stored = 1',
|
||||
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND vehicleType = @vehicleType AND stored = @stored',
|
||||
{
|
||||
['@owner'] = GetPlayerIdentifiers(source)[1],
|
||||
['vehicleType'] = 'boat'
|
||||
['@owner'] = GetPlayerIdentifiers(source)[1],
|
||||
['@vehicleType'] = 'boat',
|
||||
['@stored'] = true
|
||||
}, function (result)
|
||||
local vehicles = {}
|
||||
|
||||
for i=1, #result, 1 do
|
||||
table.insert(vehicles, json.decode(result[i].vehicle))
|
||||
local vehicleProps = json.decode(result[i].vehicle)
|
||||
table.insert(vehicles, vehicleProps)
|
||||
end
|
||||
|
||||
cb(vehicles)
|
||||
|
||||
Reference in New Issue
Block a user