mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 16:23:21 +00:00
Updated to new vehicleshop database and fixed #9
This commit is contained in:
@@ -2,9 +2,4 @@ USE `essentialmode`;
|
|||||||
|
|
||||||
INSERT INTO `licenses` (`type`, `label`) VALUES
|
INSERT INTO `licenses` (`type`, `label`) VALUES
|
||||||
('boat', 'Boat License')
|
('boat', 'Boat License')
|
||||||
;
|
|
||||||
|
|
||||||
ALTER TABLE `owned_vehicles`
|
|
||||||
ADD COLUMN `vehicleType` VARCHAR(20) NULL DEFAULT 'car',
|
|
||||||
ADD COLUMN `stored` TINYINT(1) NOT NULL DEFAULT '1'
|
|
||||||
;
|
;
|
||||||
+21
-27
@@ -7,10 +7,8 @@ MySQL.ready(function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
function ParkBoats()
|
function ParkBoats()
|
||||||
MySQL.Async.execute('UPDATE owned_vehicles SET stored = true WHERE stored = @stored AND vehicleType = @vehicleType',
|
MySQL.Async.execute('UPDATE owned_vehicles SET `stored` = true WHERE `stored` = false AND type = @type', {
|
||||||
{
|
['@type'] = 'boat'
|
||||||
['@stored'] = false,
|
|
||||||
['@vehicleType'] = 'boat'
|
|
||||||
}, function (rowsChanged)
|
}, function (rowsChanged)
|
||||||
if rowsChanged > 0 then
|
if rowsChanged > 0 then
|
||||||
print(('esx_boat: %s boat(s) have been stored!'):format(rowsChanged))
|
print(('esx_boat: %s boat(s) have been stored!'):format(rowsChanged))
|
||||||
@@ -18,7 +16,7 @@ function ParkBoats()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
ESX.RegisterServerCallback('esx_boat:buyBoat', function (source, cb, vehicleProps)
|
ESX.RegisterServerCallback('esx_boat:buyBoat', function(source, cb, vehicleProps)
|
||||||
local xPlayer = ESX.GetPlayerFromId(source)
|
local xPlayer = ESX.GetPlayerFromId(source)
|
||||||
local price = getPriceFromModel(vehicleProps.modelAlt)
|
local price = getPriceFromModel(vehicleProps.modelAlt)
|
||||||
|
|
||||||
@@ -33,13 +31,13 @@ ESX.RegisterServerCallback('esx_boat:buyBoat', function (source, cb, vehicleProp
|
|||||||
if xPlayer.getMoney() >= price then
|
if xPlayer.getMoney() >= price then
|
||||||
xPlayer.removeMoney(price)
|
xPlayer.removeMoney(price)
|
||||||
|
|
||||||
MySQL.Async.execute('INSERT INTO owned_vehicles (owner, plate, vehicle, vehicleType) VALUES (@owner, @plate, @vehicle, @vehicleType)',
|
MySQL.Async.execute('INSERT INTO owned_vehicles (owner, plate, vehicle, type) VALUES (@owner, @plate, @vehicle, @type)',
|
||||||
{
|
{
|
||||||
['@owner'] = xPlayer.identifier,
|
['@owner'] = xPlayer.identifier,
|
||||||
['@plate'] = vehicleProps.plate,
|
['@plate'] = vehicleProps.plate,
|
||||||
['@vehicle'] = json.encode(vehicleProps),
|
['@vehicle'] = json.encode(vehicleProps),
|
||||||
['@vehicleType'] = 'boat'
|
['@type'] = 'boat'
|
||||||
}, function (rowsChanged)
|
}, function(rowsChanged)
|
||||||
cb(true)
|
cb(true)
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
@@ -48,13 +46,12 @@ ESX.RegisterServerCallback('esx_boat:buyBoat', function (source, cb, vehicleProp
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterServerEvent('esx_boat:takeOutVehicle')
|
RegisterServerEvent('esx_boat:takeOutVehicle')
|
||||||
AddEventHandler('esx_boat:takeOutVehicle', function (plate)
|
AddEventHandler('esx_boat:takeOutVehicle', function(plate)
|
||||||
MySQL.Async.execute('UPDATE owned_vehicles SET stored = @stored WHERE owner = @owner AND plate = @plate',
|
MySQL.Async.execute('UPDATE owned_vehicles SET `stored` = @stored WHERE owner = @owner AND plate = @plate', {
|
||||||
{
|
|
||||||
['@stored'] = false,
|
['@stored'] = false,
|
||||||
['@owner'] = GetPlayerIdentifiers(source)[1],
|
['@owner'] = GetPlayerIdentifiers(source)[1],
|
||||||
['@plate'] = plate
|
['@plate'] = plate
|
||||||
}, function (rowsChanged)
|
}, function(rowsChanged)
|
||||||
if rowsChanged == 0 then
|
if rowsChanged == 0 then
|
||||||
print(('esx_boat: %s exploited the garage!'):format(GetPlayerIdentifiers(source)[1]))
|
print(('esx_boat: %s exploited the garage!'):format(GetPlayerIdentifiers(source)[1]))
|
||||||
end
|
end
|
||||||
@@ -62,12 +59,11 @@ AddEventHandler('esx_boat:takeOutVehicle', function (plate)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
ESX.RegisterServerCallback('esx_boat:storeVehicle', function (source, cb, plate)
|
ESX.RegisterServerCallback('esx_boat:storeVehicle', function (source, cb, plate)
|
||||||
MySQL.Async.execute('UPDATE owned_vehicles SET stored = @stored WHERE owner = @owner AND plate = @plate',
|
MySQL.Async.execute('UPDATE owned_vehicles SET `stored` = @stored WHERE owner = @owner AND plate = @plate', {
|
||||||
{
|
|
||||||
['@stored'] = true,
|
['@stored'] = true,
|
||||||
['@owner'] = GetPlayerIdentifiers(source)[1],
|
['@owner'] = GetPlayerIdentifiers(source)[1],
|
||||||
['@plate'] = plate
|
['@plate'] = plate
|
||||||
}, function (rowsChanged)
|
}, function(rowsChanged)
|
||||||
if rowsChanged == 0 then
|
if rowsChanged == 0 then
|
||||||
print(('esx_boat: %s attempted to store an boat they don\'t own!'):format(GetPlayerIdentifiers(source)[1]))
|
print(('esx_boat: %s attempted to store an boat they don\'t own!'):format(GetPlayerIdentifiers(source)[1]))
|
||||||
end
|
end
|
||||||
@@ -76,13 +72,12 @@ ESX.RegisterServerCallback('esx_boat:storeVehicle', function (source, cb, plate)
|
|||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
ESX.RegisterServerCallback('esx_boat:getGarage', function (source, cb)
|
ESX.RegisterServerCallback('esx_boat:getGarage', function(source, cb)
|
||||||
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND vehicleType = @vehicleType AND stored = @stored',
|
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND type = @type AND `stored` = @stored', {
|
||||||
{
|
['@owner'] = GetPlayerIdentifiers(source)[1],
|
||||||
['@owner'] = GetPlayerIdentifiers(source)[1],
|
['@type'] = 'boat',
|
||||||
['@vehicleType'] = 'boat',
|
['@stored'] = true
|
||||||
['@stored'] = true
|
}, function(result)
|
||||||
}, function (result)
|
|
||||||
local vehicles = {}
|
local vehicles = {}
|
||||||
|
|
||||||
for i=1, #result, 1 do
|
for i=1, #result, 1 do
|
||||||
@@ -92,10 +87,9 @@ ESX.RegisterServerCallback('esx_boat:getGarage', function (source, cb)
|
|||||||
|
|
||||||
cb(vehicles)
|
cb(vehicles)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
ESX.RegisterServerCallback('esx_boat:buyBoatLicense', function (source, cb)
|
ESX.RegisterServerCallback('esx_boat:buyBoatLicense', function(source, cb)
|
||||||
local xPlayer = ESX.GetPlayerFromId(source)
|
local xPlayer = ESX.GetPlayerFromId(source)
|
||||||
|
|
||||||
if xPlayer.getMoney() >= Config.LicensePrice then
|
if xPlayer.getMoney() >= Config.LicensePrice then
|
||||||
|
|||||||
Reference in New Issue
Block a user