Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. function JVS:TestDriveVehicle(model, listtype)
  2. if self.TestingCar then return; end
  3. self.TestingCar = true
  4. if listtype == 2 then
  5. ESX.Game.SpawnVehicle(model, self.PurchasedUtilPos.xyz, self.PurchasedUtilPos.w, function(cbVeh)
  6. Citizen.Wait(10)
  7. SetEntityCoords(cbVeh, self.PurchasedUtilPos.xyz, 0.0, 0.0, 0.0, true)
  8. SetEntityHeading(cbVeh, self.PurchasedUtilPos.w)
  9. SetVehicleOnGroundProperly(cbVeh)
  10. Citizen.Wait(10)
  11. TaskWarpPedIntoVehicle(GetPlayerPed(-1), cbVeh, -1)
  12. SetVehicleNumberPlateText(cbVeh, "TESTCAR")
  13. self.TestingCar = cbVeh
  14. self.TestingList = listtype
  15. end)
  16. elseif listtype == 1 or listtype == 3 then
  17. ESX.Game.SpawnVehicle(model, self.PurchasedCarPos.xyz, self.PurchasedCarPos.w, function(cbVeh)
  18. Citizen.Wait(10)
  19. SetEntityCoords(cbVeh, self.PurchasedCarPos.xyz, 0.0, 0.0, 0.0, true)
  20. SetEntityHeading(cbVeh, self.PurchasedCarPos.w)
  21. SetVehicleOnGroundProperly(cbVeh)
  22. Citizen.Wait(10)
  23. TaskWarpPedIntoVehicle(GetPlayerPed(-1), cbVeh, -1)
  24. SetVehicleNumberPlateText(cbVeh, "TESTCAR")
  25. self.TestingCar = cbVeh
  26. self.TestingList = listtype
  27. end)
  28. end
  29. end
  30.  
  31. Citizen.CreateThread(function()
  32. local self = JVS
  33. while true do
  34. Citizen.Wait(10)
  35. if self.TestingCar and self.TestingList then
  36. local plyPed = GetPlayerPed(-1)
  37. local plyPos = GetEntityCoords(plyPed)
  38. if self.TestingList == 2 then
  39. if JUtils:GetVecDist(plyPos, self.PurchasedUtilPos.xyz) < self.VehRetDist then
  40. ESX.ShowHelpNotification('Press ~INPUT_PICKUP~ to return the test vehicle.')
  41. if (IsControlJustPressed(0, JUtils.Keys["E"], IsDisabledControlJustPressed(0, JUtils.Keys["E"]))) then
  42.  
  43. local maxPassengers = GetVehicleMaxNumberOfPassengers(self.TestingCar)
  44. for seat = -1,maxPassengers-1,1 do
  45. local ped = GetPedInVehicleSeat(self.TestingCar,seat)
  46. if ped and ped ~= 0 then TaskLeaveVehicle(ped,self.TestingCar,16); end
  47. end
  48. print(maxPassengers,self.TestingCar)
  49. ESX.Game.DeleteVehicle(self.TestingCar)
  50. if DoesEntityExist(self.TestingCar) then SetVehicleUndriveable(self.TestingCar, true); end
  51. ESX.ShowNotification("You have returned the test vehicle.")
  52. self.TestingCar = false
  53. self.TestingList = false
  54. end
  55. end
  56. else
  57. if JUtils:GetVecDist(plyPos, self.PurchasedCarPos.xyz) < self.VehRetDist then
  58. ESX.ShowHelpNotification('Press ~INPUT_PICKUP~ to return the test vehicle.')
  59. if (IsControlJustPressed(0, JUtils.Keys["E"], IsDisabledControlJustPressed(0, JUtils.Keys["E"]))) then
  60. local maxPassengers = GetVehicleMaxNumberOfPassengers(self.TestingCar)
  61. for seat = -1,maxPassengers-1,1 do
  62. local ped = GetPedInVehicleSeat(self.TestingCar,seat)
  63. if ped and ped ~= 0 then TaskLeaveVehicle(ped,self.TestingCar,16); end
  64. end
  65. print(maxPassengers,self.TestingCar)
  66. ESX.Game.DeleteVehicle(self.TestingCar)
  67. ESX.ShowNotification("You have returned the test vehicle.")
  68. if DoesEntityExist(self.TestingCar) then SetVehicleUndriveable(self.TestingCar, true); end
  69. self.TestingCar = false
  70. self.TestingList = false
  71. end
  72. end
  73. end
  74. end
  75. end
  76. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement