Diff
checker
Texto
Texto
Imágenes
Documentos
Excel
Carpetas
Legal
Enterprise
Aplicación de escritorio
Precios
Iniciar sesión
Descargar Diffchecker Desktop
Comparar texto
Encuentra la diferencia entre dos archivos de texto
Herramientas
Historial
Editor live
Ocultar sin cambios
Sin ajuste de línea
Vista
Dividido
Unificado
Nivel de detalle
Inteligente
Palabra
Letra
Resaltado de sintaxis
Elegir sintaxis
Ignorar
Transformar texto
Ir al primer cambio
Editar entrada
Diffchecker Desktop
La forma más segura de usar Diffchecker. ¡Obtén la app de Diffchecker Desktop: tus diffs nunca salen de tu computadora!
Obtener Desktop
AdvancedGarage Server
Creado
hace 6 años
El diff nunca expira
Borrar
Exportar
Compartir
Explicar
0 eliminaciones
Líneas
Total
Eliminado
Caracteres
Total
Eliminado
Para continuar usando esta función, actualice a
Diff
checker
Pro
Ver precios
403 líneas
Copiar todo
51 adiciones
Líneas
Total
Añadido
Caracteres
Total
Añadido
Para continuar usando esta función, actualice a
Diff
checker
Pro
Ver precios
454 líneas
Copiar todo
ESX = nil
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
-- Make sure all Vehicles are Stored on restart
-- Make sure all Vehicles are Stored on restart
MySQL.ready(function()
MySQL.ready(function()
ParkVehicles()
ParkVehicles()
end)
end)
function ParkVehicles()
function ParkVehicles()
MySQL.Async.execute('UPDATE owned_vehicles SET `stored` = true WHERE `stored` = @stored', {
MySQL.Async.execute('UPDATE owned_vehicles SET `stored` = true WHERE `stored` = @stored', {
['@stored'] = false
['@stored'] = false
}, function(rowsChanged)
}, function(rowsChanged)
if rowsChanged > 0 then
if rowsChanged > 0 then
print(('esx_advancedgarage: %s vehicle(s) have been stored!'):format(rowsChanged))
print(('esx_advancedgarage: %s vehicle(s) have been stored!'):format(rowsChanged))
end
end
end)
end)
end
end
-- Get Owned Properties
-- Get Owned Properties
ESX.RegisterServerCallback('esx_advancedgarage:getOwnedProperties', function(source, cb)
ESX.RegisterServerCallback('esx_advancedgarage:getOwnedProperties', function(source, cb)
local _source = source
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local xPlayer = ESX.GetPlayerFromId(_source)
local properties = {}
local properties = {}
MySQL.Async.fetchAll('SELECT * FROM owned_properties WHERE owner = @owner', {
MySQL.Async.fetchAll('SELECT * FROM owned_properties WHERE owner = @owner', {
['@owner'] = xPlayer.getIdentifier()
['@owner'] = xPlayer.getIdentifier()
}, function(data)
}, function(data)
for _,v in pairs(data) do
for _,v in pairs(data) do
table.insert(properties, v.name)
table.insert(properties, v.name)
end
end
cb(properties)
cb(properties)
end)
end)
end)
end)
-- Fetch Owned Aircrafts
-- Fetch Owned Aircrafts
ESX.RegisterServerCallback('esx_advancedgarage:getOwnedAircrafts', function(source, cb)
ESX.RegisterServerCallback('esx_advancedgarage:getOwnedAircrafts', function(source, cb)
local ownedAircrafts = {}
local ownedAircrafts = {}
if Config.DontShowPoundCarsInGarage == true then
if Config.DontShowPoundCarsInGarage == true then
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = @stored', {
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = @stored', {
['@owner'] = GetPlayerIdentifiers(source)[1],
['@owner'] = GetPlayerIdentifiers(source)[1],
['@Type'] = 'aircraft',
['@Type'] = 'aircraft',
['@job'] = '',
['@job'] = '',
['@stored'] = true
['@stored'] = true
}, function(data)
}, function(data)
for _,v in pairs(data) do
for _,v in pairs(data) do
local vehicle = json.decode(v.vehicle)
local vehicle = json.decode(v.vehicle)
table.insert(ownedAircrafts, {vehicle = vehicle, stored = v.stored, plate = v.plate})
table.insert(ownedAircrafts, {vehicle = vehicle, stored = v.stored, plate = v.plate})
end
end
cb(ownedAircrafts)
cb(ownedAircrafts)
end)
end)
else
else
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job', {
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job', {
['@owner'] = GetPlayerIdentifiers(source)[1],
['@owner'] = GetPlayerIdentifiers(source)[1],
['@Type'] = 'aircraft',
['@Type'] = 'aircraft',
['@job'] = ''
['@job'] = ''
}, function(data)
}, function(data)
for _,v in pairs(data) do
for _,v in pairs(data) do
local vehicle = json.decode(v.vehicle)
local vehicle = json.decode(v.vehicle)
table.insert(ownedAircrafts, {vehicle = vehicle, stored = v.stored, plate = v.plate})
table.insert(ownedAircrafts, {vehicle = vehicle, stored = v.stored, plate = v.plate})
end
end
cb(ownedAircrafts)
cb(ownedAircrafts)
end)
end)
end
end
end)
end)
-- Fetch Owned Boats
-- Fetch Owned Boats
ESX.RegisterServerCallback('esx_advancedgarage:getOwnedBoats', function(source, cb)
ESX.RegisterServerCallback('esx_advancedgarage:getOwnedBoats', function(source, cb)
local ownedBoats = {}
local ownedBoats = {}
if Config.DontShowPoundCarsInGarage == true then
if Config.DontShowPoundCarsInGarage == true then
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = @stored', {
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = @stored', {
['@owner'] = GetPlayerIdentifiers(source)[1],
['@owner'] = GetPlayerIdentifiers(source)[1],
['@Type'] = 'boat',
['@Type'] = 'boat',
['@job'] = '',
['@job'] = '',
['@stored'] = true
['@stored'] = true
}, function(data)
}, function(data)
for _,v in pairs(data) do
for _,v in pairs(data) do
local vehicle = json.decode(v.vehicle)
local vehicle = json.decode(v.vehicle)
table.insert(ownedBoats, {vehicle = vehicle, stored = v.stored, plate = v.plate})
table.insert(ownedBoats, {vehicle = vehicle, stored = v.stored, plate = v.plate})
end
end
cb(ownedBoats)
cb(ownedBoats)
end)
end)
else
else
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job', {
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job', {
['@owner'] = GetPlayerIdentifiers(source)[1],
['@owner'] = GetPlayerIdentifiers(source)[1],
['@Type'] = 'boat',
['@Type'] = 'boat',
['@job'] = ''
['@job'] = ''
}, function(data)
}, function(data)
for _,v in pairs(data) do
for _,v in pairs(data) do
local vehicle = json.decode(v.vehicle)
local vehicle = json.decode(v.vehicle)
table.insert(ownedBoats, {vehicle = vehicle, stored = v.stored, plate = v.plate})
table.insert(ownedBoats, {vehicle = vehicle, stored = v.stored, plate = v.plate})
end
end
cb(ownedBoats)
cb(ownedBoats)
end)
end)
end
end
end)
end)
-- Fetch Owned Cars
-- Fetch Owned Cars
ESX.RegisterServerCallback('esx_advancedgarage:getOwnedCars', function(source, cb)
ESX.RegisterServerCallback('esx_advancedgarage:getOwnedCars', function(source, cb)
local ownedCars = {}
local ownedCars = {}
if Config.DontShowPoundCarsInGarage == true then
if Config.DontShowPoundCarsInGarage == true then
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = @stored', {
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = @stored', {
['@owner'] = GetPlayerIdentifiers(source)[1],
['@owner'] = GetPlayerIdentifiers(source)[1],
['@Type'] = 'car',
['@Type'] = 'car',
['@job'] = '',
['@job'] = '',
['@stored'] = true
['@stored'] = true
}, function(data)
}, function(data)
for _,v in pairs(data) do
for _,v in pairs(data) do
local vehicle = json.decode(v.vehicle)
local vehicle = json.decode(v.vehicle)
table.insert(ownedCars, {vehicle = vehicle, stored = v.stored, plate = v.plate})
table.insert(ownedCars, {vehicle = vehicle, stored = v.stored, plate = v.plate})
end
end
cb(ownedCars)
cb(ownedCars)
end)
end)
else
else
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job', {
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job', {
['@owner'] = GetPlayerIdentifiers(source)[1],
['@owner'] = GetPlayerIdentifiers(source)[1],
['@Type'] = 'car',
['@Type'] = 'car',
['@job'] = ''
['@job'] = ''
}, function(data)
}, function(data)
for _,v in pairs(data) do
for _,v in pairs(data) do
local vehicle = json.decode(v.vehicle)
local vehicle = json.decode(v.vehicle)
table.insert(ownedCars, {vehicle = vehicle, stored = v.stored, plate = v.plate})
table.insert(ownedCars, {vehicle = vehicle, stored = v.stored, plate = v.plate})
end
end
cb(ownedCars)
cb(ownedCars)
end)
end)
end
end
end)
end)
-- Store Vehicles
-- Store Vehicles
ESX.RegisterServerCallback('esx_advancedgarage:storeVehicle', function (source, cb, vehicleProps)
ESX.RegisterServerCallback('esx_advancedgarage:storeVehicle', function (source, cb, vehicleProps)
local ownedCars = {}
local ownedCars = {}
local vehplate = vehicleProps.plate:match("^%s*(.-)%s*$")
local vehplate = vehicleProps.plate:match("^%s*(.-)%s*$")
local vehiclemodel = vehicleProps.model
local vehiclemodel = vehicleProps.model
local xPlayer = ESX.GetPlayerFromId(source)
local xPlayer = ESX.GetPlayerFromId(source)
Copiar
Copiado
Copiar
Copiado
--CREO QUE SIRVE PARA IDENTIFICAR QUE EL AUTO QUE SE VA A GUARDAR ES UN AUTO CON DUEÑO
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND @plate = plate', {
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND @plate = plate', {
['@owner'] = xPlayer.identifier,
['@owner'] = xPlayer.identifier,
['@plate'] = vehicleProps.plate
['@plate'] = vehicleProps.plate
}, function (result)
}, function (result)
if result[1] ~= nil then
if result[1] ~= nil then
local originalvehprops = json.decode(result[1].vehicle)
local originalvehprops = json.decode(result[1].vehicle)
if originalvehprops.model == vehiclemodel then
if originalvehprops.model == vehiclemodel then
MySQL.Async.execute('UPDATE owned_vehicles SET vehicle = @vehicle WHERE owner = @owner AND plate = @plate', {
MySQL.Async.execute('UPDATE owned_vehicles SET vehicle = @vehicle WHERE owner = @owner AND plate = @plate', {
['@owner'] = GetPlayerIdentifiers(source)[1],
['@owner'] = GetPlayerIdentifiers(source)[1],
['@vehicle'] = json.encode(vehicleProps),
['@vehicle'] = json.encode(vehicleProps),
['@plate'] = vehicleProps.plate
['@plate'] = vehicleProps.plate
}, function (rowsChanged)
}, function (rowsChanged)
if rowsChanged == 0 then
if rowsChanged == 0 then
print(('esx_advancedgarage: %s attempted to store an vehicle they don\'t own!'):format(GetPlayerIdentifiers(source)[1]))
print(('esx_advancedgarage: %s attempted to store an vehicle they don\'t own!'):format(GetPlayerIdentifiers(source)[1]))
end
end
cb(true)
cb(true)
end)
end)
else
else
if Config.KickPossibleCheaters == true then
if Config.KickPossibleCheaters == true then
if Config.UseCustomKickMessage == true then
if Config.UseCustomKickMessage == true then
print(('esx_advancedgarage: %s attempted to Cheat! Tried Storing: '..vehiclemodel..'. Original Vehicle: '..originalvehprops.model):format(GetPlayerIdentifiers(source)[1]))
print(('esx_advancedgarage: %s attempted to Cheat! Tried Storing: '..vehiclemodel..'. Original Vehicle: '..originalvehprops.model):format(GetPlayerIdentifiers(source)[1]))
DropPlayer(source, _U('custom_kick'))
DropPlayer(source, _U('custom_kick'))
cb(false)
cb(false)
else
else
print(('esx_advancedgarage: %s attempted to Cheat! Tried Storing: '..vehiclemodel..'. Original Vehicle: '..originalvehprops.model):format(GetPlayerIdentifiers(source)[1]))
print(('esx_advancedgarage: %s attempted to Cheat! Tried Storing: '..vehiclemodel..'. Original Vehicle: '..originalvehprops.model):format(GetPlayerIdentifiers(source)[1]))
DropPlayer(source, 'You have been Kicked from the Server for Possible Garage Cheating!!!')
DropPlayer(source, 'You have been Kicked from the Server for Possible Garage Cheating!!!')
cb(false)
cb(false)
end
end
else
else
print(('esx_advancedgarage: %s attempted to Cheat! Tried Storing: '..vehiclemodel..'. Original Vehicle: '..originalvehprops.model):format(GetPlayerIdentifiers(source)[1]))
print(('esx_advancedgarage: %s attempted to Cheat! Tried Storing: '..vehiclemodel..'. Original Vehicle: '..originalvehprops.model):format(GetPlayerIdentifiers(source)[1]))
cb(false)
cb(false)
end
end
end
end
else
else
print(('esx_advancedgarage: %s attempted to store an vehicle they don\'t own!'):format(GetPlayerIdentifiers(source)[1]))
print(('esx_advancedgarage: %s attempted to store an vehicle they don\'t own!'):format(GetPlayerIdentifiers(source)[1]))
cb(false)
cb(false)
end
end
end)
end)
end)
end)
-- Fetch Pounded Aircrafts
-- Fetch Pounded Aircrafts
ESX.RegisterServerCallback('esx_advancedgarage:getOutOwnedAircrafts', function(source, cb)
ESX.RegisterServerCallback('esx_advancedgarage:getOutOwnedAircrafts', function(source, cb)
local ownedAircrafts = {}
local ownedAircrafts = {}
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = @stored', {
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = @stored', {
['@owner'] = GetPlayerIdentifiers(source)[1],
['@owner'] = GetPlayerIdentifiers(source)[1],
['@Type'] = 'aircraft',
['@Type'] = 'aircraft',
['@job'] = '',
['@job'] = '',
['@stored'] = false
['@stored'] = false
}, function(data)
}, function(data)
for _,v in pairs(data) do
for _,v in pairs(data) do
local vehicle = json.decode(v.vehicle)
local vehicle = json.decode(v.vehicle)
table.insert(ownedAircrafts, vehicle)
table.insert(ownedAircrafts, vehicle)
end
end
cb(ownedAircrafts)
cb(ownedAircrafts)
end)
end)
end)
end)
-- Fetch Pounded Boats
-- Fetch Pounded Boats
ESX.RegisterServerCallback('esx_advancedgarage:getOutOwnedBoats', function(source, cb)
ESX.RegisterServerCallback('esx_advancedgarage:getOutOwnedBoats', function(source, cb)
local ownedBoats = {}
local ownedBoats = {}
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = @stored', {
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = @stored', {
['@owner'] = GetPlayerIdentifiers(source)[1],
['@owner'] = GetPlayerIdentifiers(source)[1],
['@Type'] = 'boat',
['@Type'] = 'boat',
['@job'] = '',
['@job'] = '',
['@stored'] = false
['@stored'] = false
}, function(data)
}, function(data)
for _,v in pairs(data) do
for _,v in pairs(data) do
local vehicle = json.decode(v.vehicle)
local vehicle = json.decode(v.vehicle)
table.insert(ownedBoats, vehicle)
table.insert(ownedBoats, vehicle)
end
end
cb(ownedBoats)
cb(ownedBoats)
end)
end)
end)
end)
-- Fetch Pounded Cars
-- Fetch Pounded Cars
ESX.RegisterServerCallback('esx_advancedgarage:getOutOwnedCars', function(source, cb)
ESX.RegisterServerCallback('esx_advancedgarage:getOutOwnedCars', function(source, cb)
local ownedCars = {}
local ownedCars = {}
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = @stored', {
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = @stored', {
['@owner'] = GetPlayerIdentifiers(source)[1],
['@owner'] = GetPlayerIdentifiers(source)[1],
['@Type'] = 'car',
['@Type'] = 'car',
['@job'] = '',
['@job'] = '',
['@stored'] = false
['@stored'] = false
}, function(data)
}, function(data)
for _,v in pairs(data) do
for _,v in pairs(data) do
local vehicle = json.decode(v.vehicle)
local vehicle = json.decode(v.vehicle)
table.insert(ownedCars, vehicle)
table.insert(ownedCars, vehicle)
end
end
cb(ownedCars)
cb(ownedCars)
end)
end)
end)
end)
-- Fetch Pounded Policing Vehicles
-- Fetch Pounded Policing Vehicles
ESX.RegisterServerCallback('esx_advancedgarage:getOutOwnedPolicingCars', function(source, cb)
ESX.RegisterServerCallback('esx_advancedgarage:getOutOwnedPolicingCars', function(source, cb)
local ownedPolicingCars = {}
local ownedPolicingCars = {}
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND job = @job AND `stored` = @stored', {
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND job = @job AND `stored` = @stored', {
['@owner'] = GetPlayerIdentifiers(source)[1],
['@owner'] = GetPlayerIdentifiers(source)[1],
['@job'] = 'police',
['@job'] = 'police',
['@stored'] = false
['@stored'] = false
}, function(data)
}, function(data)
for _,v in pairs(data) do
for _,v in pairs(data) do
local vehicle = json.decode(v.vehicle)
local vehicle = json.decode(v.vehicle)
table.insert(ownedPolicingCars, vehicle)
table.insert(ownedPolicingCars, vehicle)
end
end
cb(ownedPolicingCars)
cb(ownedPolicingCars)
end)
end)
end)
end)
-- Fetch Pounded Ambulance Vehicles
-- Fetch Pounded Ambulance Vehicles
ESX.RegisterServerCallback('esx_advancedgarage:getOutOwnedAmbulanceCars', function(source, cb)
ESX.RegisterServerCallback('esx_advancedgarage:getOutOwnedAmbulanceCars', function(source, cb)
local ownedAmbulanceCars = {}
local ownedAmbulanceCars = {}
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND job = @job AND `stored` = @stored', {
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND job = @job AND `stored` = @stored', {
['@owner'] = GetPlayerIdentifiers(source)[1],
['@owner'] = GetPlayerIdentifiers(source)[1],
['@job'] = 'ambulance',
['@job'] = 'ambulance',
['@stored'] = false
['@stored'] = false
}, function(data)
}, function(data)
for _,v in pairs(data) do
for _,v in pairs(data) do
local vehicle = json.decode(v.vehicle)
local vehicle = json.decode(v.vehicle)
table.insert(ownedAmbulanceCars, vehicle)
table.insert(ownedAmbulanceCars, vehicle)
end
end
cb(ownedAmbulanceCars)
cb(ownedAmbulanceCars)
end)
end)
end)
end)
-- Check Money for Pounded Aircrafts
-- Check Money for Pounded Aircrafts
ESX.RegisterServerCallback('esx_advancedgarage:checkMoneyAircrafts', function(source, cb)
ESX.RegisterServerCallback('esx_advancedgarage:checkMoneyAircrafts', function(source, cb)
local xPlayer = ESX.GetPlayerFromId(source)
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer.get('money') >= Config.AircraftPoundPrice then
if xPlayer.get('money') >= Config.AircraftPoundPrice then
cb(true)
cb(true)
else
else
cb(false)
cb(false)
end
end
end)
end)
-- Check Money for Pounded Boats
-- Check Money for Pounded Boats
ESX.RegisterServerCallback('esx_advancedgarage:checkMoneyBoats', function(source, cb)
ESX.RegisterServerCallback('esx_advancedgarage:checkMoneyBoats', function(source, cb)
local xPlayer = ESX.GetPlayerFromId(source)
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer.get('money') >= Config.BoatPoundPrice then
if xPlayer.get('money') >= Config.BoatPoundPrice then
cb(true)
cb(true)
else
else
cb(false)
cb(false)
end
end
end)
end)
-- Check Money for Pounded Cars
-- Check Money for Pounded Cars
ESX.RegisterServerCallback('esx_advancedgarage:checkMoneyCars', function(source, cb)
ESX.RegisterServerCallback('esx_advancedgarage:checkMoneyCars', function(source, cb)
local xPlayer = ESX.GetPlayerFromId(source)
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer.get('money') >= Config.CarPoundPrice then
if xPlayer.get('money') >= Config.CarPoundPrice then
cb(true)
cb(true)
else
else
cb(false)
cb(false)
end
end
end)
end)
-- Check Money for Pounded Policing
-- Check Money for Pounded Policing
ESX.RegisterServerCallback('esx_advancedgarage:checkMoneyPolicing', function(source, cb)
ESX.RegisterServerCallback('esx_advancedgarage:checkMoneyPolicing', function(source, cb)
local xPlayer = ESX.GetPlayerFromId(source)
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer.get('money') >= Config.PolicingPoundPrice then
if xPlayer.get('money') >= Config.PolicingPoundPrice then
cb(true)
cb(true)
else
else
cb(false)
cb(false)
end
end
end)
end)
-- Check Money for Pounded Ambulance
-- Check Money for Pounded Ambulance
ESX.RegisterServerCallback('esx_advancedgarage:checkMoneyAmbulance', function(source, cb)
ESX.RegisterServerCallback('esx_advancedgarage:checkMoneyAmbulance', function(source, cb)
local xPlayer = ESX.GetPlayerFromId(source)
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer.get('money') >= Config.AmbulancePoundPrice then
if xPlayer.get('money') >= Config.AmbulancePoundPrice then
cb(true)
cb(true)
else
else
cb(false)
cb(false)
end
end
end)
end)
-- Pay for Pounded Aircrafts
-- Pay for Pounded Aircrafts
RegisterServerEvent('esx_advancedgarage:payAircraft')
RegisterServerEvent('esx_advancedgarage:payAircraft')
AddEventHandler('esx_advancedgarage:payAircraft', function()
AddEventHandler('esx_advancedgarage:payAircraft', function()
local xPlayer = ESX.GetPlayerFromId(source)
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.removeMoney(Config.AircraftPoundPrice)
xPlayer.removeMoney(Config.AircraftPoundPrice)
TriggerClientEvent('esx:showNotification', source, _U('you_paid') .. Config.AircraftPoundPrice)
TriggerClientEvent('esx:showNotification', source, _U('you_paid') .. Config.AircraftPoundPrice)
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account)
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account)
account.addMoney(Config.AircraftPoundPrice)
account.addMoney(Config.AircraftPoundPrice)
end)
end)
end)
end)
-- Pay for Pounded Boats
-- Pay for Pounded Boats
RegisterServerEvent('esx_advancedgarage:payBoat')
RegisterServerEvent('esx_advancedgarage:payBoat')
AddEventHandler('esx_advancedgarage:payBoat', function()
AddEventHandler('esx_advancedgarage:payBoat', function()
local xPlayer = ESX.GetPlayerFromId(source)
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.removeMoney(Config.BoatPoundPrice)
xPlayer.removeMoney(Config.BoatPoundPrice)
TriggerClientEvent('esx:showNotification', source, _U('you_paid') .. Config.BoatPoundPrice)
TriggerClientEvent('esx:showNotification', source, _U('you_paid') .. Config.BoatPoundPrice)
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account)
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account)
account.addMoney(Config.BoatPoundPrice)
account.addMoney(Config.BoatPoundPrice)
end)
end)
end)
end)
-- Pay for Pounded Cars
-- Pay for Pounded Cars
RegisterServerEvent('esx_advancedgarage:payCar')
RegisterServerEvent('esx_advancedgarage:payCar')
AddEventHandler('esx_advancedgarage:payCar', function()
AddEventHandler('esx_advancedgarage:payCar', function()
local xPlayer = ESX.GetPlayerFromId(source)
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.removeMoney(Config.CarPoundPrice)
xPlayer.removeMoney(Config.CarPoundPrice)
TriggerClientEvent('esx:showNotification', source, _U('you_paid') .. Config.CarPoundPrice)
TriggerClientEvent('esx:showNotification', source, _U('you_paid') .. Config.CarPoundPrice)
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account)
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account)
account.addMoney(Config.CarPoundPrice)
account.addMoney(Config.CarPoundPrice)
end)
end)
end)
end)
-- Pay for Pounded Policing
-- Pay for Pounded Policing
RegisterServerEvent('esx_advancedgarage:payPolicing')
RegisterServerEvent('esx_advancedgarage:payPolicing')
AddEventHandler('esx_advancedgarage:payPolicing', function()
AddEventHandler('esx_advancedgarage:payPolicing', function()
local xPlayer = ESX.GetPlayerFromId(source)
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.removeMoney(Config.PolicingPoundPrice)
xPlayer.removeMoney(Config.PolicingPoundPrice)
TriggerClientEvent('esx:showNotification', source, _U('you_paid') .. Config.PolicingPoundPrice)
TriggerClientEvent('esx:showNotification', source, _U('you_paid') .. Config.PolicingPoundPrice)
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account)
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account)
account.addMoney(Config.PolicingPoundPrice)
account.addMoney(Config.PolicingPoundPrice)
end)
end)
end)
end)
-- Pay for Pounded Ambulance
-- Pay for Pounded Ambulance
RegisterServerEvent('esx_advancedgarage:payAmbulance')
RegisterServerEvent('esx_advancedgarage:payAmbulance')
AddEventHandler('esx_advancedgarage:payAmbulance', function()
AddEventHandler('esx_advancedgarage:payAmbulance', function()
local xPlayer = ESX.GetPlayerFromId(source)
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.removeMoney(Config.AmbulancePoundPrice)
xPlayer.removeMoney(Config.AmbulancePoundPrice)
TriggerClientEvent('esx:showNotification', source, _U('you_paid') .. Config.AmbulancePoundPrice)
TriggerClientEvent('esx:showNotification', source, _U('you_paid') .. Config.AmbulancePoundPrice)
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account)
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account)
account.addMoney(Config.AmbulancePoundPrice)
account.addMoney(Config.AmbulancePoundPrice)
end)
end)
end)
end)
-- Pay to Return Broken Vehicles
-- Pay to Return Broken Vehicles
RegisterServerEvent('esx_advancedgarage:payhealth')
RegisterServerEvent('esx_advancedgarage:payhealth')
AddEventHandler('esx_advancedgarage:payhealth', function(price)
AddEventHandler('esx_advancedgarage:payhealth', function(price)
local xPlayer = ESX.GetPlayerFromId(source)
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.removeMoney(price)
xPlayer.removeMoney(price)
TriggerClientEvent('esx:showNotification', source, _U('you_paid') .. price)
TriggerClientEvent('esx:showNotification', source, _U('you_paid') .. price)
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account)
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account)
account.addMoney(price)
account.addMoney(price)
end)
end)
end)
end)
-- Modify State of Vehicles
-- Modify State of Vehicles
Copiar
Copiado
Copiar
Copiado
--[[
RegisterServerEvent('esx_advancedgarage:setVehicleState')
AddEventHandler('esx_advancedgarage:setVehicleState', function(plate, state)
local xPlayer = ESX.GetPlayerFromId(source)
MySQL.Async.execute('UPDATE owned_vehicles SET `stored` = @stored WHERE plate = @plate', {
['@stored'] = state,
['@plate'] = plate
}, function(rowsChanged)
if rowsChanged == 0 then
print(('esx_advancedgarage: %s exploited the garage!'):format(xPlayer.identifier))
end
end)
end)
--]]
RegisterServerEvent('esx_advancedgarage:setVehicleState')
RegisterServerEvent('esx_advancedgarage:setVehicleState')
AddEventHandler('esx_advancedgarage:setVehicleState', function(plate, state)
AddEventHandler('esx_advancedgarage:setVehicleState', function(plate, state)
local xPlayer = ESX.GetPlayerFromId(source)
local xPlayer = ESX.GetPlayerFromId(source)
MySQL.Async.execute('UPDATE owned_vehicles SET `stored` = @stored WHERE plate = @plate', {
MySQL.Async.execute('UPDATE owned_vehicles SET `stored` = @stored WHERE plate = @plate', {
['@stored'] = state,
['@stored'] = state,
['@plate'] = plate
['@plate'] = plate
}, function(rowsChanged)
}, function(rowsChanged)
if rowsChanged == 0 then
if rowsChanged == 0 then
print(('esx_advancedgarage: %s exploited the garage!'):format(xPlayer.identifier))
print(('esx_advancedgarage: %s exploited the garage!'):format(xPlayer.identifier))
end
end
end)
end)
end)
end)
Copiar
Copiado
Copiar
Copiado
RegisterServerEvent('esx_advancedgarage:saveVehicleFuel')
AddEventHandler('esx_advancedgarage:saveVehicleFuel', function(plate, fuelLevel)
local xPlayer = ESX.GetPlayerFromId(source)
MySQL.Async.execute('UPDATE owned_vehicles SET `fuel` = @fuel WHERE plate = @plate', {
['@fuel'] = fuelLevel,
['@plate'] = plate
}, function(rowsChanged)
if rowsChanged == 0 then
print(('esx_advancedgarage: %s exploited the garage!'):format(xPlayer.identifier))
end
end)
end)
RegisterServerEvent('esx_advancedgarage:setVehicleFuel')
AddEventHandler('esx_advancedgarage:setVehicleFuel', function(plate, vehicle, estado)
local source = source
MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE plate = @plate', {
['@plate'] = plate
}, function(result)
--if result[1] then
--print(result[1].fuel)
local fuel = result[1].fuel
if estado then
--print(estado) GARAGE
TriggerClientEvent( "setFuel", source, vehicle, plate, fuel )
else
--print(estado) CORRAL
TriggerClientEvent( "setFuel2", source, vehicle, plate, fuel )
end
--end
end)
end)
Diferencias guardadas
Texto original
Abrir archivo
ESX = nil TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) -- Make sure all Vehicles are Stored on restart MySQL.ready(function() ParkVehicles() end) function ParkVehicles() MySQL.Async.execute('UPDATE owned_vehicles SET `stored` = true WHERE `stored` = @stored', { ['@stored'] = false }, function(rowsChanged) if rowsChanged > 0 then print(('esx_advancedgarage: %s vehicle(s) have been stored!'):format(rowsChanged)) end end) end -- Get Owned Properties ESX.RegisterServerCallback('esx_advancedgarage:getOwnedProperties', function(source, cb) local _source = source local xPlayer = ESX.GetPlayerFromId(_source) local properties = {} MySQL.Async.fetchAll('SELECT * FROM owned_properties WHERE owner = @owner', { ['@owner'] = xPlayer.getIdentifier() }, function(data) for _,v in pairs(data) do table.insert(properties, v.name) end cb(properties) end) end) -- Fetch Owned Aircrafts ESX.RegisterServerCallback('esx_advancedgarage:getOwnedAircrafts', function(source, cb) local ownedAircrafts = {} if Config.DontShowPoundCarsInGarage == true then MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = @stored', { ['@owner'] = GetPlayerIdentifiers(source)[1], ['@Type'] = 'aircraft', ['@job'] = '', ['@stored'] = true }, function(data) for _,v in pairs(data) do local vehicle = json.decode(v.vehicle) table.insert(ownedAircrafts, {vehicle = vehicle, stored = v.stored, plate = v.plate}) end cb(ownedAircrafts) end) else MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job', { ['@owner'] = GetPlayerIdentifiers(source)[1], ['@Type'] = 'aircraft', ['@job'] = '' }, function(data) for _,v in pairs(data) do local vehicle = json.decode(v.vehicle) table.insert(ownedAircrafts, {vehicle = vehicle, stored = v.stored, plate = v.plate}) end cb(ownedAircrafts) end) end end) -- Fetch Owned Boats ESX.RegisterServerCallback('esx_advancedgarage:getOwnedBoats', function(source, cb) local ownedBoats = {} if Config.DontShowPoundCarsInGarage == true then MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = @stored', { ['@owner'] = GetPlayerIdentifiers(source)[1], ['@Type'] = 'boat', ['@job'] = '', ['@stored'] = true }, function(data) for _,v in pairs(data) do local vehicle = json.decode(v.vehicle) table.insert(ownedBoats, {vehicle = vehicle, stored = v.stored, plate = v.plate}) end cb(ownedBoats) end) else MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job', { ['@owner'] = GetPlayerIdentifiers(source)[1], ['@Type'] = 'boat', ['@job'] = '' }, function(data) for _,v in pairs(data) do local vehicle = json.decode(v.vehicle) table.insert(ownedBoats, {vehicle = vehicle, stored = v.stored, plate = v.plate}) end cb(ownedBoats) end) end end) -- Fetch Owned Cars ESX.RegisterServerCallback('esx_advancedgarage:getOwnedCars', function(source, cb) local ownedCars = {} if Config.DontShowPoundCarsInGarage == true then MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = @stored', { ['@owner'] = GetPlayerIdentifiers(source)[1], ['@Type'] = 'car', ['@job'] = '', ['@stored'] = true }, function(data) for _,v in pairs(data) do local vehicle = json.decode(v.vehicle) table.insert(ownedCars, {vehicle = vehicle, stored = v.stored, plate = v.plate}) end cb(ownedCars) end) else MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job', { ['@owner'] = GetPlayerIdentifiers(source)[1], ['@Type'] = 'car', ['@job'] = '' }, function(data) for _,v in pairs(data) do local vehicle = json.decode(v.vehicle) table.insert(ownedCars, {vehicle = vehicle, stored = v.stored, plate = v.plate}) end cb(ownedCars) end) end end) -- Store Vehicles ESX.RegisterServerCallback('esx_advancedgarage:storeVehicle', function (source, cb, vehicleProps) local ownedCars = {} local vehplate = vehicleProps.plate:match("^%s*(.-)%s*$") local vehiclemodel = vehicleProps.model local xPlayer = ESX.GetPlayerFromId(source) MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND @plate = plate', { ['@owner'] = xPlayer.identifier, ['@plate'] = vehicleProps.plate }, function (result) if result[1] ~= nil then local originalvehprops = json.decode(result[1].vehicle) if originalvehprops.model == vehiclemodel then MySQL.Async.execute('UPDATE owned_vehicles SET vehicle = @vehicle WHERE owner = @owner AND plate = @plate', { ['@owner'] = GetPlayerIdentifiers(source)[1], ['@vehicle'] = json.encode(vehicleProps), ['@plate'] = vehicleProps.plate }, function (rowsChanged) if rowsChanged == 0 then print(('esx_advancedgarage: %s attempted to store an vehicle they don\'t own!'):format(GetPlayerIdentifiers(source)[1])) end cb(true) end) else if Config.KickPossibleCheaters == true then if Config.UseCustomKickMessage == true then print(('esx_advancedgarage: %s attempted to Cheat! Tried Storing: '..vehiclemodel..'. Original Vehicle: '..originalvehprops.model):format(GetPlayerIdentifiers(source)[1])) DropPlayer(source, _U('custom_kick')) cb(false) else print(('esx_advancedgarage: %s attempted to Cheat! Tried Storing: '..vehiclemodel..'. Original Vehicle: '..originalvehprops.model):format(GetPlayerIdentifiers(source)[1])) DropPlayer(source, 'You have been Kicked from the Server for Possible Garage Cheating!!!') cb(false) end else print(('esx_advancedgarage: %s attempted to Cheat! Tried Storing: '..vehiclemodel..'. Original Vehicle: '..originalvehprops.model):format(GetPlayerIdentifiers(source)[1])) cb(false) end end else print(('esx_advancedgarage: %s attempted to store an vehicle they don\'t own!'):format(GetPlayerIdentifiers(source)[1])) cb(false) end end) end) -- Fetch Pounded Aircrafts ESX.RegisterServerCallback('esx_advancedgarage:getOutOwnedAircrafts', function(source, cb) local ownedAircrafts = {} MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = @stored', { ['@owner'] = GetPlayerIdentifiers(source)[1], ['@Type'] = 'aircraft', ['@job'] = '', ['@stored'] = false }, function(data) for _,v in pairs(data) do local vehicle = json.decode(v.vehicle) table.insert(ownedAircrafts, vehicle) end cb(ownedAircrafts) end) end) -- Fetch Pounded Boats ESX.RegisterServerCallback('esx_advancedgarage:getOutOwnedBoats', function(source, cb) local ownedBoats = {} MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = @stored', { ['@owner'] = GetPlayerIdentifiers(source)[1], ['@Type'] = 'boat', ['@job'] = '', ['@stored'] = false }, function(data) for _,v in pairs(data) do local vehicle = json.decode(v.vehicle) table.insert(ownedBoats, vehicle) end cb(ownedBoats) end) end) -- Fetch Pounded Cars ESX.RegisterServerCallback('esx_advancedgarage:getOutOwnedCars', function(source, cb) local ownedCars = {} MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = @stored', { ['@owner'] = GetPlayerIdentifiers(source)[1], ['@Type'] = 'car', ['@job'] = '', ['@stored'] = false }, function(data) for _,v in pairs(data) do local vehicle = json.decode(v.vehicle) table.insert(ownedCars, vehicle) end cb(ownedCars) end) end) -- Fetch Pounded Policing Vehicles ESX.RegisterServerCallback('esx_advancedgarage:getOutOwnedPolicingCars', function(source, cb) local ownedPolicingCars = {} MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND job = @job AND `stored` = @stored', { ['@owner'] = GetPlayerIdentifiers(source)[1], ['@job'] = 'police', ['@stored'] = false }, function(data) for _,v in pairs(data) do local vehicle = json.decode(v.vehicle) table.insert(ownedPolicingCars, vehicle) end cb(ownedPolicingCars) end) end) -- Fetch Pounded Ambulance Vehicles ESX.RegisterServerCallback('esx_advancedgarage:getOutOwnedAmbulanceCars', function(source, cb) local ownedAmbulanceCars = {} MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND job = @job AND `stored` = @stored', { ['@owner'] = GetPlayerIdentifiers(source)[1], ['@job'] = 'ambulance', ['@stored'] = false }, function(data) for _,v in pairs(data) do local vehicle = json.decode(v.vehicle) table.insert(ownedAmbulanceCars, vehicle) end cb(ownedAmbulanceCars) end) end) -- Check Money for Pounded Aircrafts ESX.RegisterServerCallback('esx_advancedgarage:checkMoneyAircrafts', function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) if xPlayer.get('money') >= Config.AircraftPoundPrice then cb(true) else cb(false) end end) -- Check Money for Pounded Boats ESX.RegisterServerCallback('esx_advancedgarage:checkMoneyBoats', function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) if xPlayer.get('money') >= Config.BoatPoundPrice then cb(true) else cb(false) end end) -- Check Money for Pounded Cars ESX.RegisterServerCallback('esx_advancedgarage:checkMoneyCars', function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) if xPlayer.get('money') >= Config.CarPoundPrice then cb(true) else cb(false) end end) -- Check Money for Pounded Policing ESX.RegisterServerCallback('esx_advancedgarage:checkMoneyPolicing', function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) if xPlayer.get('money') >= Config.PolicingPoundPrice then cb(true) else cb(false) end end) -- Check Money for Pounded Ambulance ESX.RegisterServerCallback('esx_advancedgarage:checkMoneyAmbulance', function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) if xPlayer.get('money') >= Config.AmbulancePoundPrice then cb(true) else cb(false) end end) -- Pay for Pounded Aircrafts RegisterServerEvent('esx_advancedgarage:payAircraft') AddEventHandler('esx_advancedgarage:payAircraft', function() local xPlayer = ESX.GetPlayerFromId(source) xPlayer.removeMoney(Config.AircraftPoundPrice) TriggerClientEvent('esx:showNotification', source, _U('you_paid') .. Config.AircraftPoundPrice) TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account) account.addMoney(Config.AircraftPoundPrice) end) end) -- Pay for Pounded Boats RegisterServerEvent('esx_advancedgarage:payBoat') AddEventHandler('esx_advancedgarage:payBoat', function() local xPlayer = ESX.GetPlayerFromId(source) xPlayer.removeMoney(Config.BoatPoundPrice) TriggerClientEvent('esx:showNotification', source, _U('you_paid') .. Config.BoatPoundPrice) TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account) account.addMoney(Config.BoatPoundPrice) end) end) -- Pay for Pounded Cars RegisterServerEvent('esx_advancedgarage:payCar') AddEventHandler('esx_advancedgarage:payCar', function() local xPlayer = ESX.GetPlayerFromId(source) xPlayer.removeMoney(Config.CarPoundPrice) TriggerClientEvent('esx:showNotification', source, _U('you_paid') .. Config.CarPoundPrice) TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account) account.addMoney(Config.CarPoundPrice) end) end) -- Pay for Pounded Policing RegisterServerEvent('esx_advancedgarage:payPolicing') AddEventHandler('esx_advancedgarage:payPolicing', function() local xPlayer = ESX.GetPlayerFromId(source) xPlayer.removeMoney(Config.PolicingPoundPrice) TriggerClientEvent('esx:showNotification', source, _U('you_paid') .. Config.PolicingPoundPrice) TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account) account.addMoney(Config.PolicingPoundPrice) end) end) -- Pay for Pounded Ambulance RegisterServerEvent('esx_advancedgarage:payAmbulance') AddEventHandler('esx_advancedgarage:payAmbulance', function() local xPlayer = ESX.GetPlayerFromId(source) xPlayer.removeMoney(Config.AmbulancePoundPrice) TriggerClientEvent('esx:showNotification', source, _U('you_paid') .. Config.AmbulancePoundPrice) TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account) account.addMoney(Config.AmbulancePoundPrice) end) end) -- Pay to Return Broken Vehicles RegisterServerEvent('esx_advancedgarage:payhealth') AddEventHandler('esx_advancedgarage:payhealth', function(price) local xPlayer = ESX.GetPlayerFromId(source) xPlayer.removeMoney(price) TriggerClientEvent('esx:showNotification', source, _U('you_paid') .. price) TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account) account.addMoney(price) end) end) -- Modify State of Vehicles RegisterServerEvent('esx_advancedgarage:setVehicleState') AddEventHandler('esx_advancedgarage:setVehicleState', function(plate, state) local xPlayer = ESX.GetPlayerFromId(source) MySQL.Async.execute('UPDATE owned_vehicles SET `stored` = @stored WHERE plate = @plate', { ['@stored'] = state, ['@plate'] = plate }, function(rowsChanged) if rowsChanged == 0 then print(('esx_advancedgarage: %s exploited the garage!'):format(xPlayer.identifier)) end end) end)
Texto modificado
Abrir archivo
ESX = nil TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) -- Make sure all Vehicles are Stored on restart MySQL.ready(function() ParkVehicles() end) function ParkVehicles() MySQL.Async.execute('UPDATE owned_vehicles SET `stored` = true WHERE `stored` = @stored', { ['@stored'] = false }, function(rowsChanged) if rowsChanged > 0 then print(('esx_advancedgarage: %s vehicle(s) have been stored!'):format(rowsChanged)) end end) end -- Get Owned Properties ESX.RegisterServerCallback('esx_advancedgarage:getOwnedProperties', function(source, cb) local _source = source local xPlayer = ESX.GetPlayerFromId(_source) local properties = {} MySQL.Async.fetchAll('SELECT * FROM owned_properties WHERE owner = @owner', { ['@owner'] = xPlayer.getIdentifier() }, function(data) for _,v in pairs(data) do table.insert(properties, v.name) end cb(properties) end) end) -- Fetch Owned Aircrafts ESX.RegisterServerCallback('esx_advancedgarage:getOwnedAircrafts', function(source, cb) local ownedAircrafts = {} if Config.DontShowPoundCarsInGarage == true then MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = @stored', { ['@owner'] = GetPlayerIdentifiers(source)[1], ['@Type'] = 'aircraft', ['@job'] = '', ['@stored'] = true }, function(data) for _,v in pairs(data) do local vehicle = json.decode(v.vehicle) table.insert(ownedAircrafts, {vehicle = vehicle, stored = v.stored, plate = v.plate}) end cb(ownedAircrafts) end) else MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job', { ['@owner'] = GetPlayerIdentifiers(source)[1], ['@Type'] = 'aircraft', ['@job'] = '' }, function(data) for _,v in pairs(data) do local vehicle = json.decode(v.vehicle) table.insert(ownedAircrafts, {vehicle = vehicle, stored = v.stored, plate = v.plate}) end cb(ownedAircrafts) end) end end) -- Fetch Owned Boats ESX.RegisterServerCallback('esx_advancedgarage:getOwnedBoats', function(source, cb) local ownedBoats = {} if Config.DontShowPoundCarsInGarage == true then MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = @stored', { ['@owner'] = GetPlayerIdentifiers(source)[1], ['@Type'] = 'boat', ['@job'] = '', ['@stored'] = true }, function(data) for _,v in pairs(data) do local vehicle = json.decode(v.vehicle) table.insert(ownedBoats, {vehicle = vehicle, stored = v.stored, plate = v.plate}) end cb(ownedBoats) end) else MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job', { ['@owner'] = GetPlayerIdentifiers(source)[1], ['@Type'] = 'boat', ['@job'] = '' }, function(data) for _,v in pairs(data) do local vehicle = json.decode(v.vehicle) table.insert(ownedBoats, {vehicle = vehicle, stored = v.stored, plate = v.plate}) end cb(ownedBoats) end) end end) -- Fetch Owned Cars ESX.RegisterServerCallback('esx_advancedgarage:getOwnedCars', function(source, cb) local ownedCars = {} if Config.DontShowPoundCarsInGarage == true then MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = @stored', { ['@owner'] = GetPlayerIdentifiers(source)[1], ['@Type'] = 'car', ['@job'] = '', ['@stored'] = true }, function(data) for _,v in pairs(data) do local vehicle = json.decode(v.vehicle) table.insert(ownedCars, {vehicle = vehicle, stored = v.stored, plate = v.plate}) end cb(ownedCars) end) else MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job', { ['@owner'] = GetPlayerIdentifiers(source)[1], ['@Type'] = 'car', ['@job'] = '' }, function(data) for _,v in pairs(data) do local vehicle = json.decode(v.vehicle) table.insert(ownedCars, {vehicle = vehicle, stored = v.stored, plate = v.plate}) end cb(ownedCars) end) end end) -- Store Vehicles ESX.RegisterServerCallback('esx_advancedgarage:storeVehicle', function (source, cb, vehicleProps) local ownedCars = {} local vehplate = vehicleProps.plate:match("^%s*(.-)%s*$") local vehiclemodel = vehicleProps.model local xPlayer = ESX.GetPlayerFromId(source) --CREO QUE SIRVE PARA IDENTIFICAR QUE EL AUTO QUE SE VA A GUARDAR ES UN AUTO CON DUEÑO MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND @plate = plate', { ['@owner'] = xPlayer.identifier, ['@plate'] = vehicleProps.plate }, function (result) if result[1] ~= nil then local originalvehprops = json.decode(result[1].vehicle) if originalvehprops.model == vehiclemodel then MySQL.Async.execute('UPDATE owned_vehicles SET vehicle = @vehicle WHERE owner = @owner AND plate = @plate', { ['@owner'] = GetPlayerIdentifiers(source)[1], ['@vehicle'] = json.encode(vehicleProps), ['@plate'] = vehicleProps.plate }, function (rowsChanged) if rowsChanged == 0 then print(('esx_advancedgarage: %s attempted to store an vehicle they don\'t own!'):format(GetPlayerIdentifiers(source)[1])) end cb(true) end) else if Config.KickPossibleCheaters == true then if Config.UseCustomKickMessage == true then print(('esx_advancedgarage: %s attempted to Cheat! Tried Storing: '..vehiclemodel..'. Original Vehicle: '..originalvehprops.model):format(GetPlayerIdentifiers(source)[1])) DropPlayer(source, _U('custom_kick')) cb(false) else print(('esx_advancedgarage: %s attempted to Cheat! Tried Storing: '..vehiclemodel..'. Original Vehicle: '..originalvehprops.model):format(GetPlayerIdentifiers(source)[1])) DropPlayer(source, 'You have been Kicked from the Server for Possible Garage Cheating!!!') cb(false) end else print(('esx_advancedgarage: %s attempted to Cheat! Tried Storing: '..vehiclemodel..'. Original Vehicle: '..originalvehprops.model):format(GetPlayerIdentifiers(source)[1])) cb(false) end end else print(('esx_advancedgarage: %s attempted to store an vehicle they don\'t own!'):format(GetPlayerIdentifiers(source)[1])) cb(false) end end) end) -- Fetch Pounded Aircrafts ESX.RegisterServerCallback('esx_advancedgarage:getOutOwnedAircrafts', function(source, cb) local ownedAircrafts = {} MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = @stored', { ['@owner'] = GetPlayerIdentifiers(source)[1], ['@Type'] = 'aircraft', ['@job'] = '', ['@stored'] = false }, function(data) for _,v in pairs(data) do local vehicle = json.decode(v.vehicle) table.insert(ownedAircrafts, vehicle) end cb(ownedAircrafts) end) end) -- Fetch Pounded Boats ESX.RegisterServerCallback('esx_advancedgarage:getOutOwnedBoats', function(source, cb) local ownedBoats = {} MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = @stored', { ['@owner'] = GetPlayerIdentifiers(source)[1], ['@Type'] = 'boat', ['@job'] = '', ['@stored'] = false }, function(data) for _,v in pairs(data) do local vehicle = json.decode(v.vehicle) table.insert(ownedBoats, vehicle) end cb(ownedBoats) end) end) -- Fetch Pounded Cars ESX.RegisterServerCallback('esx_advancedgarage:getOutOwnedCars', function(source, cb) local ownedCars = {} MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = @stored', { ['@owner'] = GetPlayerIdentifiers(source)[1], ['@Type'] = 'car', ['@job'] = '', ['@stored'] = false }, function(data) for _,v in pairs(data) do local vehicle = json.decode(v.vehicle) table.insert(ownedCars, vehicle) end cb(ownedCars) end) end) -- Fetch Pounded Policing Vehicles ESX.RegisterServerCallback('esx_advancedgarage:getOutOwnedPolicingCars', function(source, cb) local ownedPolicingCars = {} MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND job = @job AND `stored` = @stored', { ['@owner'] = GetPlayerIdentifiers(source)[1], ['@job'] = 'police', ['@stored'] = false }, function(data) for _,v in pairs(data) do local vehicle = json.decode(v.vehicle) table.insert(ownedPolicingCars, vehicle) end cb(ownedPolicingCars) end) end) -- Fetch Pounded Ambulance Vehicles ESX.RegisterServerCallback('esx_advancedgarage:getOutOwnedAmbulanceCars', function(source, cb) local ownedAmbulanceCars = {} MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND job = @job AND `stored` = @stored', { ['@owner'] = GetPlayerIdentifiers(source)[1], ['@job'] = 'ambulance', ['@stored'] = false }, function(data) for _,v in pairs(data) do local vehicle = json.decode(v.vehicle) table.insert(ownedAmbulanceCars, vehicle) end cb(ownedAmbulanceCars) end) end) -- Check Money for Pounded Aircrafts ESX.RegisterServerCallback('esx_advancedgarage:checkMoneyAircrafts', function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) if xPlayer.get('money') >= Config.AircraftPoundPrice then cb(true) else cb(false) end end) -- Check Money for Pounded Boats ESX.RegisterServerCallback('esx_advancedgarage:checkMoneyBoats', function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) if xPlayer.get('money') >= Config.BoatPoundPrice then cb(true) else cb(false) end end) -- Check Money for Pounded Cars ESX.RegisterServerCallback('esx_advancedgarage:checkMoneyCars', function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) if xPlayer.get('money') >= Config.CarPoundPrice then cb(true) else cb(false) end end) -- Check Money for Pounded Policing ESX.RegisterServerCallback('esx_advancedgarage:checkMoneyPolicing', function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) if xPlayer.get('money') >= Config.PolicingPoundPrice then cb(true) else cb(false) end end) -- Check Money for Pounded Ambulance ESX.RegisterServerCallback('esx_advancedgarage:checkMoneyAmbulance', function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) if xPlayer.get('money') >= Config.AmbulancePoundPrice then cb(true) else cb(false) end end) -- Pay for Pounded Aircrafts RegisterServerEvent('esx_advancedgarage:payAircraft') AddEventHandler('esx_advancedgarage:payAircraft', function() local xPlayer = ESX.GetPlayerFromId(source) xPlayer.removeMoney(Config.AircraftPoundPrice) TriggerClientEvent('esx:showNotification', source, _U('you_paid') .. Config.AircraftPoundPrice) TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account) account.addMoney(Config.AircraftPoundPrice) end) end) -- Pay for Pounded Boats RegisterServerEvent('esx_advancedgarage:payBoat') AddEventHandler('esx_advancedgarage:payBoat', function() local xPlayer = ESX.GetPlayerFromId(source) xPlayer.removeMoney(Config.BoatPoundPrice) TriggerClientEvent('esx:showNotification', source, _U('you_paid') .. Config.BoatPoundPrice) TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account) account.addMoney(Config.BoatPoundPrice) end) end) -- Pay for Pounded Cars RegisterServerEvent('esx_advancedgarage:payCar') AddEventHandler('esx_advancedgarage:payCar', function() local xPlayer = ESX.GetPlayerFromId(source) xPlayer.removeMoney(Config.CarPoundPrice) TriggerClientEvent('esx:showNotification', source, _U('you_paid') .. Config.CarPoundPrice) TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account) account.addMoney(Config.CarPoundPrice) end) end) -- Pay for Pounded Policing RegisterServerEvent('esx_advancedgarage:payPolicing') AddEventHandler('esx_advancedgarage:payPolicing', function() local xPlayer = ESX.GetPlayerFromId(source) xPlayer.removeMoney(Config.PolicingPoundPrice) TriggerClientEvent('esx:showNotification', source, _U('you_paid') .. Config.PolicingPoundPrice) TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account) account.addMoney(Config.PolicingPoundPrice) end) end) -- Pay for Pounded Ambulance RegisterServerEvent('esx_advancedgarage:payAmbulance') AddEventHandler('esx_advancedgarage:payAmbulance', function() local xPlayer = ESX.GetPlayerFromId(source) xPlayer.removeMoney(Config.AmbulancePoundPrice) TriggerClientEvent('esx:showNotification', source, _U('you_paid') .. Config.AmbulancePoundPrice) TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account) account.addMoney(Config.AmbulancePoundPrice) end) end) -- Pay to Return Broken Vehicles RegisterServerEvent('esx_advancedgarage:payhealth') AddEventHandler('esx_advancedgarage:payhealth', function(price) local xPlayer = ESX.GetPlayerFromId(source) xPlayer.removeMoney(price) TriggerClientEvent('esx:showNotification', source, _U('you_paid') .. price) TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account) account.addMoney(price) end) end) -- Modify State of Vehicles --[[ RegisterServerEvent('esx_advancedgarage:setVehicleState') AddEventHandler('esx_advancedgarage:setVehicleState', function(plate, state) local xPlayer = ESX.GetPlayerFromId(source) MySQL.Async.execute('UPDATE owned_vehicles SET `stored` = @stored WHERE plate = @plate', { ['@stored'] = state, ['@plate'] = plate }, function(rowsChanged) if rowsChanged == 0 then print(('esx_advancedgarage: %s exploited the garage!'):format(xPlayer.identifier)) end end) end) --]] RegisterServerEvent('esx_advancedgarage:setVehicleState') AddEventHandler('esx_advancedgarage:setVehicleState', function(plate, state) local xPlayer = ESX.GetPlayerFromId(source) MySQL.Async.execute('UPDATE owned_vehicles SET `stored` = @stored WHERE plate = @plate', { ['@stored'] = state, ['@plate'] = plate }, function(rowsChanged) if rowsChanged == 0 then print(('esx_advancedgarage: %s exploited the garage!'):format(xPlayer.identifier)) end end) end) RegisterServerEvent('esx_advancedgarage:saveVehicleFuel') AddEventHandler('esx_advancedgarage:saveVehicleFuel', function(plate, fuelLevel) local xPlayer = ESX.GetPlayerFromId(source) MySQL.Async.execute('UPDATE owned_vehicles SET `fuel` = @fuel WHERE plate = @plate', { ['@fuel'] = fuelLevel, ['@plate'] = plate }, function(rowsChanged) if rowsChanged == 0 then print(('esx_advancedgarage: %s exploited the garage!'):format(xPlayer.identifier)) end end) end) RegisterServerEvent('esx_advancedgarage:setVehicleFuel') AddEventHandler('esx_advancedgarage:setVehicleFuel', function(plate, vehicle, estado) local source = source MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE plate = @plate', { ['@plate'] = plate }, function(result) --if result[1] then --print(result[1].fuel) local fuel = result[1].fuel if estado then --print(estado) GARAGE TriggerClientEvent( "setFuel", source, vehicle, plate, fuel ) else --print(estado) CORRAL TriggerClientEvent( "setFuel2", source, vehicle, plate, fuel ) end --end end) end)
Encontrar la diferencia