Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.64 KB | None | 0 0
  1. if data.current.value == 'dep_vehicle' then
  2.  
  3.         local playerped = GetPlayerPed(-1)
  4.         local vehicle = GetVehiclePedIsIn(playerped, true)
  5.  
  6.         local towmodel = GetHashKey('flatbed')
  7.         local isVehicleTow = IsVehicleModel(vehicle, towmodel)        
  8.         local towmodel2 = GetHashKey('flatbed3')
  9.         local isVehicleTow2 = IsVehicleModel(vehicle, towmodel2)        
  10.         local towmodel3 = GetHashKey('sturdy2')
  11.         local isVehicleTow3 = IsVehicleModel(vehicle, towmodel3)
  12.  
  13.         if isVehicleTow or isVehicleTow2 or isVehicleTow3 then
  14.  
  15.           local coordA = GetEntityCoords(playerped, 1)
  16.           local coordB = GetOffsetFromEntityInWorldCoords(playerped, 0.0, 5.0, 0.0)
  17.           local targetVehicle = getVehicleInDirection(coordA, coordB)
  18.  
  19.           if CurrentlyTowedVehicle == nil then
  20.             if targetVehicle ~= 0 then
  21.               if not IsPedInAnyVehicle(playerped, true) then
  22.                 if vehicle ~= targetVehicle then
  23.                   if isVehicleTow then
  24.                   AttachEntityToEntity(targetVehicle, vehicle, 20, -0.5, -5.0, 1.0, 0.0, 0.0, 0.0, false, false, false, false, 20, true)
  25.                   elseif isVehicleTow2 then
  26.                     AttachEntityToEntity(targetVehicle, vehicle, 20, 0.9, 2.4, 1.0, 0.0, 0.0, 0.0, false, false, false, false, 20, true)
  27.                   elseif isVehicleTow3 then
  28.                     AttachEntityToEntity(targetVehicle, vehicle, 20, -0.6, -4.0, 0.3, 0.0, 0.0, 0.0, false, false, false, false, 20, true)
  29.                   end
  30.                   CurrentlyTowedVehicle = targetVehicle
  31.                   ESX.ShowNotification(_U('vehicle_success_attached'))
  32.  
  33.                   if NPCOnJob then
  34.  
  35.                     if NPCTargetTowable == targetVehicle then
  36.                       ESX.ShowNotification(_U('please_drop_off'))
  37.  
  38.                       Config.Zones.VehicleDelivery.Type = 1
  39.  
  40.                       if Blips['NPCTargetTowableZone'] ~= nil then
  41.                         RemoveBlip(Blips['NPCTargetTowableZone'])
  42.                         Blips['NPCTargetTowableZone'] = nil
  43.                       end
  44.  
  45.                       Blips['NPCDelivery'] = AddBlipForCoord(Config.Zones.VehicleDelivery.Pos.x,  Config.Zones.VehicleDelivery.Pos.y,  Config.Zones.VehicleDelivery.Pos.z)
  46.  
  47.                       SetBlipRoute(Blips['NPCDelivery'], true)
  48.  
  49.                     end
  50.  
  51.                   end
  52.  
  53.                 else
  54.                   ESX.ShowNotification(_U('cant_attach_own_tt'))
  55.                 end
  56.               end
  57.             else
  58.               ESX.ShowNotification(_U('no_veh_att'))
  59.             end
  60.           else
  61.             if isVehicleTow then
  62.                 AttachEntityToEntity(CurrentlyTowedVehicle, vehicle, 20, -0.5, -12.0, 1.0, 0.0, 0.0, 0.0, false, false, false, false, 20, true)
  63.             elseif isVehicleTow2 then
  64.                 AttachEntityToEntity(CurrentlyTowedVehicle, vehicle, 20, 0.9, -4.6, 1.0, 0.0, 0.0, 0.0, false, false, false, false, 20, true)
  65.             elseif isVehicleTow3 then
  66.                 AttachEntityToEntity(CurrentlyTowedVehicle, vehicle, 20, -0.6, -11.0, 1.0, 0.0, 0.0, 0.0, false, false, false, false, 20, true)
  67.             end
  68.             DetachEntity(CurrentlyTowedVehicle, true, true)
  69.  
  70.             if NPCOnJob then
  71.  
  72.               if CurrentlyTowedVehicle == NPCTargetTowable then
  73.                 ESX.Game.DeleteVehicle(NPCTargetTowable)
  74.                 TriggerServerEvent('esx_mecanojob:onNPCJobMissionCompleted')
  75.                 StopNPCJob()
  76.  
  77.               else
  78.                 ESX.ShowNotification(_U('not_right_veh'))
  79.               end
  80.  
  81.             end
  82.  
  83.             CurrentlyTowedVehicle = nil
  84.  
  85.             ESX.ShowNotification(_U('veh_det_succ'))
  86.           end
  87.         else
  88.           ESX.ShowNotification(_U('imp_flatbed'))
  89.         end
  90.       end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement