Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. ESX = nil
  2. local PlayerData = {}
  3.  
  4. --Car Positions:
  5. local position1=vector3(-1201.18,-1738.57,4.39)
  6. local position2=vector3(-1197.7,-1738.15,4.39)
  7. local position3=vector3(-1194.03,-1737.95,4.39)
  8.  
  9. Citizen.CreateThread(function()
  10. while ESX == nil do
  11. TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  12. Citizen.Wait(0)
  13. end
  14. end)
  15.  
  16. Citizen.CreateThread(function()
  17. while true do
  18. Citizen.Wait(1000)
  19. PlayerData = ESX.GetPlayerData()
  20. end
  21. end)
  22.  
  23. RegisterCommand('testcar', function(source, args, rawCommand)
  24. if PlayerData.job.name == 'cardealer' then
  25. local veh = args[1]
  26. local position=tonumber(args[2])
  27. if veh == nil then
  28. ESX.ShowNotification("~r~Please enter a car model")
  29. end
  30. vehiclehash = GetHashKey(veh)
  31. RequestModel(vehiclehash)
  32.  
  33. Citizen.CreateThread(function()
  34. local waiting = 0
  35. while not HasModelLoaded(vehiclehash) do
  36. waiting = waiting + 100
  37. Citizen.Wait(100)
  38. if waiting > 5000 then
  39. ESX.ShowNotification("Could not load the vehicle model.")
  40. break
  41. end
  42. end
  43.  
  44. if position then
  45. if position==1 then
  46. TriggerEvent("SpawnVehicle",position1)
  47. elseif position==2 then
  48. TriggerEvent("SpawnVehicle",position2)
  49. elseif position==3 then
  50. TriggerEvent("SpawnVehicle",position3)
  51. end
  52. else
  53. ESX.ShowNotification("~r~No position")
  54. end
  55. end)
  56. elseif PlayerData.job.name ~= 'cardealer' then
  57. ESX.ShowNotification("~r~You cannot use this command")
  58. end
  59. end)
  60.  
  61. --CLEARING THE AREA OUT OF VEHICLES
  62. Citizen.CreateThread(function()
  63. while true do
  64. ClearAreaOfVehicles(-1168.08, -1747.34, 4.0, 30.0, false,false,false,false,false)
  65. Citizen.Wait(0)
  66. end
  67. end)
  68.  
  69. RegisterCommand('dvtest', function()
  70. if PlayerData.job.name == 'cardealer' then
  71. if IsPedSittingInAnyVehicle(GetPlayerPed(-1)) and not IsEntityDead(GetPlayerPed(-1)) then
  72. DeleteEntity(GetVehiclePedIsIn(GetPlayerPed(-1),false))
  73. end
  74. end
  75. end)
  76.  
  77.  
  78. RegisterNetEvent("SpawnVehicle")
  79. AddEventHandler('SpawnVehicle', function(x,y,z)
  80. ESX.Game.SpawnVehicle(vehiclehash,x,y,z,296,function(vehicle)
  81. FreezeEntityPosition(vehicle, true)
  82. end)
  83. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement