Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.21 KB | None | 0 0
  1. elseif data.current.value == 'dep_trailer' then
  2.  
  3.         local playerPed = PlayerPedId()
  4.         local vehicle = GetVehiclePedIsIn(playerPed, true)
  5.  
  6.         local towmodel = GetHashKey('pjtrailer')
  7.         local isVehicleTow = IsVehicleModel(vehicle, towmodel)
  8.  
  9.         if isVehicleTow then
  10.             local targetVehicle = ESX.Game.GetVehicleInDirection()
  11.  
  12.             if CurrentlyTowedVehicle == nil then
  13.                 if targetVehicle ~= 0 then
  14.                     if not IsPedInAnyVehicle(playerPed, true) then
  15.                         if vehicle ~= targetVehicle then
  16.                             AttachEntityToEntity(targetVehicle, vehicle, 20, -0.5, -5.0, 1.0, 0.0, 0.0, 0.0, false, false, false, false, 20, true)
  17.                             CurrentlyTowedVehicle = targetVehicle
  18.                             ESX.ShowNotification(_U('vehicle_success_attached'))
  19.  
  20.                             if NPCOnJob then
  21.                                 if NPCTargetTowable == targetVehicle then
  22.                                     ESX.ShowNotification(_U('please_drop_off'))
  23.                                     Config.Zones.VehicleDelivery.Type = 1
  24.  
  25.                                     if Blips['NPCTargetTowableZone'] then
  26.                                         RemoveBlip(Blips['NPCTargetTowableZone'])
  27.                                         Blips['NPCTargetTowableZone'] = nil
  28.                                     end
  29.  
  30.                                     Blips['NPCDelivery'] = AddBlipForCoord(Config.Zones.VehicleDelivery.Pos.x, Config.Zones.VehicleDelivery.Pos.y, Config.Zones.VehicleDelivery.Pos.z)
  31.                                     SetBlipRoute(Blips['NPCDelivery'], true)
  32.                                 end
  33.                             end
  34.                         else
  35.                             ESX.ShowNotification(_U('cant_attach_own_tt'))
  36.                         end
  37.                     end
  38.                 else
  39.                     ESX.ShowNotification(_U('no_veh_att'))
  40.                 end
  41.             else
  42.  
  43.                 AttachEntityToEntity(CurrentlyTowedVehicle, vehicle, 20, -0.5, -12.0, 1.0, 0.0, 0.0, 0.0, false, false, false, false, 20, true)
  44.                 DetachEntity(CurrentlyTowedVehicle, true, true)
  45.  
  46.                 if NPCOnJob then
  47.                     if NPCTargetDeleterZone then
  48.  
  49.                         if CurrentlyTowedVehicle == NPCTargetTowable then
  50.                             ESX.Game.DeleteVehicle(NPCTargetTowable)
  51.                             TriggerServerEvent('esx_mechanicjob:onNPCJobMissionCompleted')
  52.                             StopNPCJob()
  53.                             NPCTargetDeleterZone = false
  54.                         else
  55.                             ESX.ShowNotification(_U('not_right_veh'))
  56.                         end
  57.  
  58.                     else
  59.                         ESX.ShowNotification(_U('not_right_place'))
  60.                     end
  61.                 end
  62.  
  63.                 CurrentlyTowedVehicle = nil
  64.                 ESX.ShowNotification(_U('veh_det_succ'))
  65.  
  66.             end
  67.         else
  68.             ESX.ShowNotification(_U('imp_flatbed'))
  69.         end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement