Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if data.current.value == 'dep_vehicle' then
- local playerped = GetPlayerPed(-1)
- local vehicle = GetVehiclePedIsIn(playerped, true)
- local towmodel = GetHashKey('flatbed')
- local isVehicleTow = IsVehicleModel(vehicle, towmodel)
- local towmodel2 = GetHashKey('flatbed3')
- local isVehicleTow2 = IsVehicleModel(vehicle, towmodel2)
- local towmodel3 = GetHashKey('sturdy2')
- local isVehicleTow3 = IsVehicleModel(vehicle, towmodel3)
- if isVehicleTow or isVehicleTow2 or isVehicleTow3 then
- local coordA = GetEntityCoords(playerped, 1)
- local coordB = GetOffsetFromEntityInWorldCoords(playerped, 0.0, 5.0, 0.0)
- local targetVehicle = getVehicleInDirection(coordA, coordB)
- if CurrentlyTowedVehicle == nil then
- if targetVehicle ~= 0 then
- if not IsPedInAnyVehicle(playerped, true) then
- if vehicle ~= targetVehicle then
- if isVehicleTow then
- AttachEntityToEntity(targetVehicle, vehicle, 20, -0.5, -5.0, 1.0, 0.0, 0.0, 0.0, false, false, false, false, 20, true)
- elseif isVehicleTow2 then
- AttachEntityToEntity(targetVehicle, vehicle, 20, 0.9, 2.4, 1.0, 0.0, 0.0, 0.0, false, false, false, false, 20, true)
- elseif isVehicleTow3 then
- AttachEntityToEntity(targetVehicle, vehicle, 20, -0.6, -4.0, 0.3, 0.0, 0.0, 0.0, false, false, false, false, 20, true)
- end
- CurrentlyTowedVehicle = targetVehicle
- ESX.ShowNotification(_U('vehicle_success_attached'))
- if NPCOnJob then
- if NPCTargetTowable == targetVehicle then
- ESX.ShowNotification(_U('please_drop_off'))
- Config.Zones.VehicleDelivery.Type = 1
- if Blips['NPCTargetTowableZone'] ~= nil then
- RemoveBlip(Blips['NPCTargetTowableZone'])
- Blips['NPCTargetTowableZone'] = nil
- end
- Blips['NPCDelivery'] = AddBlipForCoord(Config.Zones.VehicleDelivery.Pos.x, Config.Zones.VehicleDelivery.Pos.y, Config.Zones.VehicleDelivery.Pos.z)
- SetBlipRoute(Blips['NPCDelivery'], true)
- end
- end
- else
- ESX.ShowNotification(_U('cant_attach_own_tt'))
- end
- end
- else
- ESX.ShowNotification(_U('no_veh_att'))
- end
- else
- if isVehicleTow then
- AttachEntityToEntity(CurrentlyTowedVehicle, vehicle, 20, -0.5, -12.0, 1.0, 0.0, 0.0, 0.0, false, false, false, false, 20, true)
- elseif isVehicleTow2 then
- AttachEntityToEntity(CurrentlyTowedVehicle, vehicle, 20, 0.9, -4.6, 1.0, 0.0, 0.0, 0.0, false, false, false, false, 20, true)
- elseif isVehicleTow3 then
- AttachEntityToEntity(CurrentlyTowedVehicle, vehicle, 20, -0.6, -11.0, 1.0, 0.0, 0.0, 0.0, false, false, false, false, 20, true)
- end
- DetachEntity(CurrentlyTowedVehicle, true, true)
- if NPCOnJob then
- if CurrentlyTowedVehicle == NPCTargetTowable then
- ESX.Game.DeleteVehicle(NPCTargetTowable)
- TriggerServerEvent('esx_mecanojob:onNPCJobMissionCompleted')
- StopNPCJob()
- else
- ESX.ShowNotification(_U('not_right_veh'))
- end
- end
- CurrentlyTowedVehicle = nil
- ESX.ShowNotification(_U('veh_det_succ'))
- end
- else
- ESX.ShowNotification(_U('imp_flatbed'))
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement