Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- 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'] = xPlayer.identifier,
- ['@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(xPlayer.identifier))
- else
- --clear drugs from inventory
- MySQL.Async.fetchAll('SELECT * FROM trunk_inventory WHERE plate = @plate', {
- ['@plate'] = vehicleProps.plate
- }, function(result)
- --tprint(result)
- for k, v in pairs(result) do
- local data = v.data
- --print(type(data))
- local inventory = json.decode(data)
- --tprint(inventory)
- local items = inventory.coffre
- local item2 = items
- print("yo the type is "..type(items))
- for i = 1, #items, 1 do
- print(items[i])
- if items[i].name == 'opium' then
- value = i
- table.remove(item2, value)
- print('opium detected')
- else
- print("there was no opium")
- end
- end
- inventory.coffre = item2
- local dataT = json.encode(inventory)
- MySQL.Async.execute('UPDATE trunk_inventory SET data = @data WHERE plate = @plate', {
- ['@data'] = dataT,
- ['@plate'] = plate
- }, function (rowsChanged)
- end)
- end
- end)
- 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(xPlayer.identifier))
- DropPlayer(source, _U('custom_kick'))
- cb(false)
- else
- print(('esx_advancedgarage: %s attempted to Cheat! Tried Storing: ' .. vehiclemodel .. '. Original Vehicle: ' .. originalvehprops.model):format(xPlayer.identifier))
- 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(xPlayer.identifier))
- cb(false)
- end
- end
- else
- print(('esx_advancedgarage: %s attempted to store an vehicle they don\'t own!'):format(xPlayer.identifier))
- cb(false)
- end
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement