Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ESX = nil
- local CopsConnected = 0
- TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
- function CountCops()
- local xPlayers = ESX.GetPlayers()
- CopsConnected = 0
- for i=1, #xPlayers, 1 do
- local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
- if xPlayer.job.name == 'police' then
- CopsConnected = CopsConnected + 1
- end
- end
- SetTimeout(120 * 1000, CountCops)
- end
- CountCops()
- local bonus = math.min(math.floor(((CopsConnected + 1) * 1/3) * 100) / 100, 3)
- local prices = {
- {id = 0, price = 1265}, --compacts
- {id = 1, price = 1825}, --sedans
- {id = 2, price = 2525}, --SUV's
- {id = 3, price = 1645}, --coupes
- {id = 4, price = 2552}, --muscle
- {id = 5, price = 8656}, --sport classic
- {id = 6, price = 6256}, --sport
- {id = 7, price = 13355}, --super
- {id = 8, price = 860}, --motorcycle
- {id = 9, price = 785}, --offroad
- {id = 10, price = 1445}, --industrial
- {id = 11, price = 1045}, --utility
- {id = 12, price = 1645}, --vans
- {id = 13, price = 99}, --bicycles
- {id = 14, price = 3333}, --boats
- {id = 15, price = 9999}, --helicopter
- {id = 16, price = 9999}, --plane
- {id = 17, price = 1295}, --service
- {id = 18, price = 1635}, --emergency
- {id = 19, price = 2225}, --military
- {id = 20, price = 2245} --commercial
- }
- RegisterServerEvent("getVehPrice")
- AddEventHandler("getVehPrice", function(class)
- for k, price in pairs(prices) do
- if class == price.id then
- vehPrice = price.price
- TriggerClientEvent("setVehPrice", -1, vehPrice * bonus)
- print(CopsConnected)
- print(bonus)
- end
- end
- end)
- RegisterServerEvent("sellVehicle")
- AddEventHandler("sellVehicle", function(vehPrice)
- local _source = source
- local xPlayer = ESX.GetPlayerFromId(_source)
- xPlayer.addAccountMoney('black_money', vehPrice * bonus)
- CancelEvent()
- end)
- RegisterServerEvent("resetMoney")
- AddEventHandler("resetMoney", function()
- TriggerEvent("es:getPlayerFromId", source, function(user)
- user.setMoney(0)
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement