Created
May 10, 2020 12:52
-
-
Save FiveEYZ/00fdf51d8591f4cd580533afbf8fb3c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ESX.RegisterServerCallback('esx_policejob:buyJobVehicle', function(source, cb, vehicleProps, type) | |
local xPlayer = ESX.GetPlayerFromId(source) | |
local price = getPriceFromHash(vehicleProps.model, xPlayer.job.grade_name, type) | |
-- vehicle model not found | |
if xPlayer.job.grade_name ~= 'boss' then | |
if price == 0 then | |
print(('esx_policejob: %s attempted to exploit the shop! (invalid vehicle model)'):format(xPlayer.identifier)) | |
cb(false) | |
else | |
if xPlayer.getMoney() >= price then | |
xPlayer.removeMoney(price) | |
MySQL.Async.execute('INSERT INTO owned_vehicles (owner, vehicle, plate, type, job, `stored`) VALUES (@owner, @vehicle, @plate, @type, @job, @stored)', { | |
['@owner'] = xPlayer.identifier, | |
['@vehicle'] = json.encode(vehicleProps), | |
['@plate'] = vehicleProps.plate, | |
['@type'] = type, | |
['@job'] = xPlayer.job.name, | |
['@stored'] = true | |
}, function (rowsChanged) | |
cb(true) | |
end) | |
TriggerEvent('shorty_slocks:transferOwner', vehicleProps.plate, source) | |
else | |
cb(false) | |
end | |
end | |
else | |
if xPlayer.getMoney() >= price then | |
xPlayer.removeMoney(price) | |
MySQL.Async.execute('INSERT INTO owned_vehicles (owner, vehicle, plate, type, job, `stored`) VALUES (@owner, @vehicle, @plate, @type, @job, @stored)', { | |
['@owner'] = xPlayer.identifier, | |
['@vehicle'] = json.encode(vehicleProps), | |
['@plate'] = vehicleProps.plate, | |
['@type'] = type, | |
['@job'] = xPlayer.job.name, | |
['@stored'] = true | |
}, function (rowsChanged) | |
cb(true) | |
end) | |
TriggerEvent('shorty_slocks:transferOwner', vehicleProps.plate, source) | |
else | |
cb(false) | |
end | |
end | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment