Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. local prices = {
  2. {id = 0, price = 1600}, --compacts
  3. {id = 1, price = 2000}, --sedans
  4. {id = 2, price = 1200}, --SUV's
  5. {id = 3, price = 3400}, --coupes
  6. {id = 4, price = 2000}, --muscle
  7. {id = 5, price = 3500}, --sport classic
  8. {id = 6, price = 3200}, --sport
  9. {id = 7, price = 11000}, --super
  10. {id = 8, price = 1000}, --motorcycle
  11. {id = 9, price = 1800}, --offroad
  12. {id = 10, price = nil}, --industrial
  13. {id = 11, price = nil}, --utility
  14. {id = 12, price = 1400}, --vans
  15. {id = 13, price = 100}, --bicycles
  16. {id = 14, price = nil}, --boats
  17. {id = 15, price = 18200}, --helicopter
  18. {id = 16, price = nil}, --plane
  19. {id = 17, price = nil}, --service
  20. {id = 18, price = nil}, --emergency
  21. {id = 19, price = 6200}, --military
  22. {id = 20, price = 1400} --commercial
  23. }
  24. local vehPrice = nil
  25.  
  26. Citizen.CreateThread(function()
  27. local blipX = 1200.63
  28. local blipY = -3116.04
  29. local blipZ = 5.54
  30.  
  31. while true do
  32. Citizen.Wait(0)
  33.  
  34. local x,y,z = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
  35. local distance = GetDistanceBetweenCoords(1204.3627929688,-3116.9548339844,4.5403227806092, x, y, z, true)
  36.  
  37. --load marker and get price if player is in vehicle and close to the area
  38. if distance <= 20.0 and IsPedSittingInAnyVehicle(GetPlayerPed(-1)) then
  39. -- TriggerEvent("chatMessage", "^2Hello")
  40. DrawMarker(1,1204.3627929688,-3116.9548339844,4.5403227806092, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0, 2.0, 255, 0, 0, 100, false, true, 1, false, false, false, false)
  41.  
  42. local vehicle = GetVehiclePedIsIn(GetPlayerPed(-1), false)
  43. vehPrice = getPrice(GetVehicleClass(vehicle))
  44. -- abilty to sell if in range and vehicle can be bought
  45. if distance <= 4.0 then
  46. if vehPrice ~=nil then
  47. vehPrice = applyHealthModifier(vehPrice, vehicle)
  48. showHelp("Appuyez ~INPUT_PICKUP~ pour vendre le véhicule ~b~$" .. vehPrice .. "~s~!")
  49. if IsControlPressed(1, 38) then
  50. sellVehicle(vehicle, vehPrice)
  51. end
  52. else
  53. showHelp("Vous ne pouvez pas vendre cette voiture.")
  54. end
  55. end
  56. end
  57. end
  58. end)
  59.  
  60. function getPrice(class)
  61. for k, price in pairs(prices) do
  62. if class == price.id then
  63. return price.price
  64. end
  65. end
  66. end
  67.  
  68. function showHelp(message)
  69. SetTextEntry("STRING")
  70. AddTextComponentString(message)
  71. end
  72.  
  73. function applyHealthModifier(price, vehicle)
  74. local health = GetEntityHealth(vehicle)
  75. local modifier = health/1000
  76. return round((modifier * price), 0)
  77. end
  78.  
  79. RegisterNetEvent("deleteveh")
  80. AddEventHandler("deleteveh", function()
  81. local vehicle = SetEntityAsMissionEntity(GetVehiclePedIsIn(GetPlayerPed(-1)), true, true)
  82. DeleteVehicle(vehicle)
  83. vehPrice = nil
  84. end)
  85.  
  86. function sellVehicle(vehicle, price)
  87. if price == nil then
  88. TriggerEvent("chatMessage", "^2Vous ne pouvez pas vendre cette voiture")
  89. else
  90. TriggerServerEvent("sellVehicle", price)
  91. Citizen.Wait(960000)
  92. end
  93. end
  94.  
  95. function round(num, numDecimalPlaces)
  96. local mult = 10^(numDecimalPlaces or 0)
  97. return math.floor(num * mult + 0.5) / mult
  98. end
  99.  
  100. -- Si tu lis ça, Bob Shawar t'emmerde ;)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement