Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function JVS:TestDriveVehicle(model, listtype)
- if self.TestingCar then return; end
- self.TestingCar = true
- if listtype == 2 then
- ESX.Game.SpawnVehicle(model, self.PurchasedUtilPos.xyz, self.PurchasedUtilPos.w, function(cbVeh)
- Citizen.Wait(10)
- SetEntityCoords(cbVeh, self.PurchasedUtilPos.xyz, 0.0, 0.0, 0.0, true)
- SetEntityHeading(cbVeh, self.PurchasedUtilPos.w)
- SetVehicleOnGroundProperly(cbVeh)
- Citizen.Wait(10)
- TaskWarpPedIntoVehicle(GetPlayerPed(-1), cbVeh, -1)
- SetVehicleNumberPlateText(cbVeh, "TESTCAR")
- self.TestingCar = cbVeh
- self.TestingList = listtype
- end)
- elseif listtype == 1 or listtype == 3 then
- ESX.Game.SpawnVehicle(model, self.PurchasedCarPos.xyz, self.PurchasedCarPos.w, function(cbVeh)
- Citizen.Wait(10)
- SetEntityCoords(cbVeh, self.PurchasedCarPos.xyz, 0.0, 0.0, 0.0, true)
- SetEntityHeading(cbVeh, self.PurchasedCarPos.w)
- SetVehicleOnGroundProperly(cbVeh)
- Citizen.Wait(10)
- TaskWarpPedIntoVehicle(GetPlayerPed(-1), cbVeh, -1)
- SetVehicleNumberPlateText(cbVeh, "TESTCAR")
- self.TestingCar = cbVeh
- self.TestingList = listtype
- end)
- end
- end
- Citizen.CreateThread(function()
- local self = JVS
- while true do
- Citizen.Wait(10)
- if self.TestingCar and self.TestingList then
- local plyPed = GetPlayerPed(-1)
- local plyPos = GetEntityCoords(plyPed)
- if self.TestingList == 2 then
- if JUtils:GetVecDist(plyPos, self.PurchasedUtilPos.xyz) < self.VehRetDist then
- ESX.ShowHelpNotification('Press ~INPUT_PICKUP~ to return the test vehicle.')
- if (IsControlJustPressed(0, JUtils.Keys["E"], IsDisabledControlJustPressed(0, JUtils.Keys["E"]))) then
- local maxPassengers = GetVehicleMaxNumberOfPassengers(self.TestingCar)
- for seat = -1,maxPassengers-1,1 do
- local ped = GetPedInVehicleSeat(self.TestingCar,seat)
- if ped and ped ~= 0 then TaskLeaveVehicle(ped,self.TestingCar,16); end
- end
- print(maxPassengers,self.TestingCar)
- ESX.Game.DeleteVehicle(self.TestingCar)
- if DoesEntityExist(self.TestingCar) then SetVehicleUndriveable(self.TestingCar, true); end
- ESX.ShowNotification("You have returned the test vehicle.")
- self.TestingCar = false
- self.TestingList = false
- end
- end
- else
- if JUtils:GetVecDist(plyPos, self.PurchasedCarPos.xyz) < self.VehRetDist then
- ESX.ShowHelpNotification('Press ~INPUT_PICKUP~ to return the test vehicle.')
- if (IsControlJustPressed(0, JUtils.Keys["E"], IsDisabledControlJustPressed(0, JUtils.Keys["E"]))) then
- local maxPassengers = GetVehicleMaxNumberOfPassengers(self.TestingCar)
- for seat = -1,maxPassengers-1,1 do
- local ped = GetPedInVehicleSeat(self.TestingCar,seat)
- if ped and ped ~= 0 then TaskLeaveVehicle(ped,self.TestingCar,16); end
- end
- print(maxPassengers,self.TestingCar)
- ESX.Game.DeleteVehicle(self.TestingCar)
- ESX.ShowNotification("You have returned the test vehicle.")
- if DoesEntityExist(self.TestingCar) then SetVehicleUndriveable(self.TestingCar, true); end
- self.TestingCar = false
- self.TestingList = false
- end
- end
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement