Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. ESX = nil
  2. local CopsConnected = 0
  3.  
  4. TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  5.  
  6. function CountCops()
  7.  
  8. local xPlayers = ESX.GetPlayers()
  9.  
  10. CopsConnected = 0
  11.  
  12. for i=1, #xPlayers, 1 do
  13. local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
  14. if xPlayer.job.name == 'police' then
  15. CopsConnected = CopsConnected + 1
  16. end
  17. end
  18.  
  19. SetTimeout(120 * 1000, CountCops)
  20. end
  21.  
  22. CountCops()
  23.  
  24. local bonus = math.min(math.floor(((CopsConnected + 1) * 1/3) * 100) / 100, 3)
  25.  
  26. local prices = {
  27. {id = 0, price = 1265}, --compacts
  28. {id = 1, price = 1825}, --sedans
  29. {id = 2, price = 2525}, --SUV's
  30. {id = 3, price = 1645}, --coupes
  31. {id = 4, price = 2552}, --muscle
  32. {id = 5, price = 8656}, --sport classic
  33. {id = 6, price = 6256}, --sport
  34. {id = 7, price = 13355}, --super
  35. {id = 8, price = 860}, --motorcycle
  36. {id = 9, price = 785}, --offroad
  37. {id = 10, price = 1445}, --industrial
  38. {id = 11, price = 1045}, --utility
  39. {id = 12, price = 1645}, --vans
  40. {id = 13, price = 99}, --bicycles
  41. {id = 14, price = 3333}, --boats
  42. {id = 15, price = 9999}, --helicopter
  43. {id = 16, price = 9999}, --plane
  44. {id = 17, price = 1295}, --service
  45. {id = 18, price = 1635}, --emergency
  46. {id = 19, price = 2225}, --military
  47. {id = 20, price = 2245} --commercial
  48. }
  49.  
  50. RegisterServerEvent("getVehPrice")
  51. AddEventHandler("getVehPrice", function(class)
  52. for k, price in pairs(prices) do
  53. if class == price.id then
  54. vehPrice = price.price
  55. TriggerClientEvent("setVehPrice", -1, vehPrice * bonus)
  56. print(CopsConnected)
  57. print(bonus)
  58. end
  59. end
  60. end)
  61.  
  62. RegisterServerEvent("sellVehicle")
  63. AddEventHandler("sellVehicle", function(vehPrice)
  64. local _source = source
  65. local xPlayer = ESX.GetPlayerFromId(_source)
  66. xPlayer.addAccountMoney('black_money', vehPrice * bonus)
  67. CancelEvent()
  68. end)
  69.  
  70. RegisterServerEvent("resetMoney")
  71. AddEventHandler("resetMoney", function()
  72. TriggerEvent("es:getPlayerFromId", source, function(user)
  73. user.setMoney(0)
  74. end)
  75. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement