mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 16:23:21 +00:00
fix: improper mysql parameters or api usage
Some queries used incorrect order for parameters or were using MySQL.query instead of MySQL.update. Removed empty tables. License removal did not get the correct player identifier.
This commit is contained in:
@@ -22,9 +22,9 @@ function CreateAddonAccount(name, owner, money)
|
||||
|
||||
self.save = function()
|
||||
if self.owner == nil then
|
||||
MySQL.update('UPDATE addon_account_data SET money = ? WHERE account_name = ?', {self.name, self.money})
|
||||
MySQL.update('UPDATE addon_account_data SET money = ? WHERE account_name = ?', {self.money, self.name})
|
||||
else
|
||||
MySQL.update('UPDATE addon_account_data SET money = ? WHERE account_name = ? AND owner = ?', {self.name, self.money, self.owner})
|
||||
MySQL.update('UPDATE addon_account_data SET money = ? WHERE account_name = ? AND owner = ?', {self.money, self.name, self.owner})
|
||||
end
|
||||
TriggerClientEvent('esx_addonaccount:setMoney', -1, self.name, self.money)
|
||||
end
|
||||
|
||||
@@ -55,7 +55,7 @@ ESX.RegisterServerCallback('esx_billing:payBill', function(source, cb, billId)
|
||||
if result.target_type == 'player' then
|
||||
if xTarget then
|
||||
if xPlayer.getMoney() >= amount then
|
||||
MySQL.query('DELETE FROM billing WHERE id = ?', {billId},
|
||||
MySQL.update('DELETE FROM billing WHERE id = ?', {billId},
|
||||
function(rowsChanged)
|
||||
if rowsChanged == 1 then
|
||||
xPlayer.removeMoney(amount)
|
||||
@@ -68,7 +68,7 @@ ESX.RegisterServerCallback('esx_billing:payBill', function(source, cb, billId)
|
||||
cb()
|
||||
end)
|
||||
elseif xPlayer.getAccount('bank').money >= amount then
|
||||
MySQL.query('DELETE FROM billing WHERE id = ?', {billId},
|
||||
MySQL.update('DELETE FROM billing WHERE id = ?', {billId},
|
||||
function(rowsChanged)
|
||||
if rowsChanged == 1 then
|
||||
xPlayer.removeAccountMoney('bank', amount)
|
||||
@@ -92,7 +92,7 @@ ESX.RegisterServerCallback('esx_billing:payBill', function(source, cb, billId)
|
||||
else
|
||||
TriggerEvent('esx_addonaccount:getSharedAccount', result[1].target, function(account)
|
||||
if xPlayer.getMoney() >= amount then
|
||||
MySQL.query('DELETE FROM billing WHERE id = ?', {billId},
|
||||
MySQL.update('DELETE FROM billing WHERE id = ?', {billId},
|
||||
function(rowsChanged)
|
||||
if rowsChanged == 1 then
|
||||
xPlayer.removeMoney(amount)
|
||||
@@ -107,7 +107,7 @@ ESX.RegisterServerCallback('esx_billing:payBill', function(source, cb, billId)
|
||||
cb()
|
||||
end)
|
||||
elseif xPlayer.getAccount('bank').money >= amount then
|
||||
MySQL.query('DELETE FROM billing WHERE id = ?', {billId},
|
||||
MySQL.update('DELETE FROM billing WHERE id = ?', {billId},
|
||||
function(rowsChanged)
|
||||
if rowsChanged == 1 then
|
||||
xPlayer.removeAccountMoney('bank', amount)
|
||||
|
||||
@@ -19,7 +19,7 @@ function RemoveLicense(target, type, cb)
|
||||
local xPlayer = ESX.GetPlayerFromId(target)
|
||||
|
||||
if xPlayer then
|
||||
MySQL.query('DELETE FROM user_licenses WHERE type = ? AND owner = ?', {type, Player.identifier},
|
||||
MySQL.update('DELETE FROM user_licenses WHERE type = ? AND owner = ?', {type, xPlayer.identifier},
|
||||
function(rowsChanged)
|
||||
if cb then
|
||||
cb()
|
||||
@@ -66,7 +66,7 @@ function CheckLicense(target, type, cb)
|
||||
end
|
||||
|
||||
function GetLicensesList(cb)
|
||||
MySQL.query('SELECT type, label FROM licenses', {},
|
||||
MySQL.query('SELECT type, label FROM licenses',
|
||||
function(result)
|
||||
cb(result)
|
||||
end)
|
||||
|
||||
@@ -43,7 +43,7 @@ AddEventHandler('esx_lscustom:refreshOwnedVehicle', function(vehicleProps)
|
||||
local vehicle = json.decode(result.vehicle)
|
||||
|
||||
if vehicleProps.model == vehicle.model then
|
||||
MySQL.update('UPDATE owned_vehicles SET vehicle = ? WHERE plate = ?', {vehicleProps.plate, json.encode(vehicleProps)})
|
||||
MySQL.update('UPDATE owned_vehicles SET vehicle = ? WHERE plate = ?', {json.encode(vehicleProps), vehicleProps.plate})
|
||||
else
|
||||
print(('esx_lscustom: %s attempted to upgrade vehicle with mismatching vehicle model!'):format(xPlayer.identifier))
|
||||
end
|
||||
|
||||
@@ -357,7 +357,7 @@ function isPlayerBoss(playerId, job)
|
||||
end
|
||||
|
||||
function WashMoneyCRON(d, h, m)
|
||||
MySQL.query('SELECT * FROM society_moneywash', {}, function(result)
|
||||
MySQL.query('SELECT * FROM society_moneywash', function(result)
|
||||
for i=1, #result, 1 do
|
||||
local society = GetSociety(result[i].society)
|
||||
local xPlayer = ESX.GetPlayerFromIdentifier(result[i].identifier)
|
||||
@@ -373,7 +373,7 @@ function WashMoneyCRON(d, h, m)
|
||||
end
|
||||
|
||||
end
|
||||
MySQL.query('DELETE FROM society_moneywash', {})
|
||||
MySQL.update('DELETE FROM society_moneywash')
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ Citizen.CreateThread(function()
|
||||
end)
|
||||
|
||||
function RemoveOwnedVehicle(plate)
|
||||
MySQL.query('DELETE FROM owned_vehicles WHERE plate = ?', {plate})
|
||||
MySQL.update('DELETE FROM owned_vehicles WHERE plate = ?', {plate})
|
||||
end
|
||||
|
||||
AddEventHandler('onResourceStart', function(resourceName)
|
||||
@@ -66,11 +66,11 @@ AddEventHandler('esx_vehicleshop:setVehicleOwnedPlayerId', function(playerId, ve
|
||||
MySQL.scalar('SELECT id FROM cardealer_vehicles WHERE vehicle = ?', {model},
|
||||
function(id)
|
||||
if id then
|
||||
MySQL.query('DELETE FROM cardealer_vehicles WHERE id = ?', {id},
|
||||
MySQL.update('DELETE FROM cardealer_vehicles WHERE id = ?', {id},
|
||||
function(rowsChanged)
|
||||
if rowsChanged == 1 then
|
||||
MySQL.insert('INSERT INTO owned_vehicles (owner, plate, vehicle) VALUES (?, ?, ?)', {xTarget.identifier, vehicleProps.plate, json.encode(vehicleProps)},
|
||||
function(rowsChanged)
|
||||
function(id)
|
||||
xPlayer.showNotification(_U('vehicle_set_owned', vehicleProps.plate, xTarget.getName()))
|
||||
xTarget.showNotification(_U('vehicle_belongs', vehicleProps.plate))
|
||||
end)
|
||||
@@ -84,7 +84,7 @@ AddEventHandler('esx_vehicleshop:setVehicleOwnedPlayerId', function(playerId, ve
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_vehicleshop:getSoldVehicles', function(source, cb)
|
||||
MySQL.query('SELECT client, model, plate, soldby, date FROM vehicle_sold', {}, function(result)
|
||||
MySQL.query('SELECT client, model, plate, soldby, date FROM vehicle_sold', function(result)
|
||||
cb(result)
|
||||
end)
|
||||
end)
|
||||
@@ -97,11 +97,11 @@ AddEventHandler('esx_vehicleshop:rentVehicle', function(vehicle, plate, rentPric
|
||||
MySQL.single('SELECT id, price FROM cardealer_vehicles WHERE vehicle = ?', {vehicle},
|
||||
function(result)
|
||||
if result then
|
||||
MySQL.query('DELETE FROM cardealer_vehicles WHERE id = ?', {result.id},
|
||||
MySQL.update('DELETE FROM cardealer_vehicles WHERE id = ?', {result.id},
|
||||
function(rowsChanged)
|
||||
if rowsChanged == 1 then
|
||||
MySQL.insert('INSERT INTO rented_vehicles (vehicle, plate, player_name, base_price, rent_price, owner) VALUES (?, ?, ?, ?, ?, ?)', {vehicle, plate, xTarget.getName(), result.price, rentPrice, xTarget.identifier},
|
||||
function(rowsChanged2)
|
||||
function(id)
|
||||
xPlayer.showNotification(_U('vehicle_set_rented', plate, xTarget.getName()))
|
||||
end)
|
||||
end
|
||||
@@ -180,7 +180,7 @@ ESX.RegisterServerCallback('esx_vehicleshop:buyVehicle', function(source, cb, mo
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_vehicleshop:getCommercialVehicles', function(source, cb)
|
||||
MySQL.query('SELECT price, vehicle FROM cardealer_vehicles ORDER BY vehicle ASC', {}, function(result)
|
||||
MySQL.query('SELECT price, vehicle FROM cardealer_vehicles ORDER BY vehicle ASC', function(result)
|
||||
cb(result)
|
||||
end)
|
||||
end)
|
||||
@@ -218,7 +218,7 @@ AddEventHandler('esx_vehicleshop:returnProvider', function(vehicleModel)
|
||||
if result then
|
||||
local id = result.id
|
||||
|
||||
MySQL.query('DELETE FROM cardealer_vehicles WHERE id = ?', {id},
|
||||
MySQL.update('DELETE FROM cardealer_vehicles WHERE id = ?', {id},
|
||||
function(rowsChanged)
|
||||
if rowsChanged == 1 then
|
||||
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_cardealer', function(account)
|
||||
@@ -238,7 +238,7 @@ AddEventHandler('esx_vehicleshop:returnProvider', function(vehicleModel)
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_vehicleshop:getRentedVehicles', function(source, cb)
|
||||
MySQL.query('SELECT * FROM rented_vehicles ORDER BY player_name ASC', {}, function(result)
|
||||
MySQL.query('SELECT * FROM rented_vehicles ORDER BY player_name ASC', function(result)
|
||||
local vehicles = {}
|
||||
|
||||
for i = 1, #result do
|
||||
@@ -261,7 +261,7 @@ ESX.RegisterServerCallback('esx_vehicleshop:giveBackVehicle', function(source, c
|
||||
local vehicle = result.vehicle
|
||||
local basePrice = result.base_price
|
||||
|
||||
MySQL.query('DELETE FROM rented_vehicles WHERE plate = ?', {plate},
|
||||
MySQL.update('DELETE FROM rented_vehicles WHERE plate = ?', {plate},
|
||||
function(rowsChanged)
|
||||
MySQL.insert('INSERT INTO cardealer_vehicles (vehicle, price) VALUES (?, ?)', {result.vehicle, result.base_price})
|
||||
|
||||
@@ -290,7 +290,7 @@ ESX.RegisterServerCallback('esx_vehicleshop:resellVehicle', function(source, cb,
|
||||
print(('[esx_vehicleshop] [^3WARNING^7] %s attempted to sell an unknown vehicle!'):format(xPlayer.identifier))
|
||||
cb(false)
|
||||
else
|
||||
MySQL.single('SELECT * FROM rented_vehicles WHERE plate = @plate', {plate},
|
||||
MySQL.single('SELECT * FROM rented_vehicles WHERE plate = ?', {plate},
|
||||
function(result)
|
||||
if result then -- is it a rented vehicle?
|
||||
cb(false) -- it is, don't let the player sell it since he doesn't own it
|
||||
|
||||
Reference in New Issue
Block a user