├── README.md └── esx-kr-vehicle-push ├── __resource.lua └── client.lua /README.md: -------------------------------------------------------------------------------- 1 | Download the latest and updated version here https://github.com/ElectusM/electus_vehicle_push 2 | -------------------------------------------------------------------------------- /esx-kr-vehicle-push/__resource.lua: -------------------------------------------------------------------------------- 1 | resource_manifest_version '05cfa83c-a124-4cfa-a768-c24a5811d8f9' 2 | 3 | client_script "client.lua" -------------------------------------------------------------------------------- /esx-kr-vehicle-push/client.lua: -------------------------------------------------------------------------------- 1 | ESX = nil 2 | 3 | Citizen.CreateThread(function() 4 | while ESX == nil do 5 | TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) 6 | Citizen.Wait(0) 7 | end 8 | end) 9 | 10 | Config = {} 11 | Config.DamageNeeded = 100.0 -- 100.0 being broken and 1000.0 being fixed a lower value than 100.0 will break it 12 | Config.MaxWidth = 5.0 -- Will complete soon 13 | Config.MaxHeight = 5.0 14 | Config.MaxLength = 5.0 15 | 16 | local Keys = { 17 | ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57, 18 | ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177, 19 | ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18, 20 | ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182, 21 | ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81, 22 | ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70, 23 | ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178, 24 | ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173, 25 | ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118 26 | } 27 | 28 | local First = vector3(0.0, 0.0, 0.0) 29 | local Second = vector3(5.0, 5.0, 5.0) 30 | 31 | local Vehicle = {Coords = nil, Vehicle = nil, Dimension = nil, IsInFront = false, Distance = nil} 32 | Citizen.CreateThread(function() 33 | Citizen.Wait(200) 34 | while true do 35 | local ped = PlayerPedId() 36 | local closestVehicle, Distance = ESX.Game.GetClosestVehicle() 37 | local vehicleCoords = GetEntityCoords(closestVehicle) 38 | local dimension = GetModelDimensions(GetEntityModel(closestVehicle), First, Second) 39 | if Distance < 6.0 and not IsPedInAnyVehicle(ped, false) then 40 | Vehicle.Coords = vehicleCoords 41 | Vehicle.Dimensions = dimension 42 | Vehicle.Vehicle = closestVehicle 43 | Vehicle.Distance = Distance 44 | if GetDistanceBetweenCoords(GetEntityCoords(closestVehicle) + GetEntityForwardVector(closestVehicle), GetEntityCoords(ped), true) > GetDistanceBetweenCoords(GetEntityCoords(closestVehicle) + GetEntityForwardVector(closestVehicle) * -1, GetEntityCoords(ped), true) then 45 | Vehicle.IsInFront = false 46 | else 47 | Vehicle.IsInFront = true 48 | end 49 | else 50 | Vehicle = {Coords = nil, Vehicle = nil, Dimensions = nil, IsInFront = false, Distance = nil} 51 | end 52 | Citizen.Wait(500) 53 | end 54 | end) 55 | 56 | 57 | Citizen.CreateThread(function() 58 | while true do 59 | Citizen.Wait(5) 60 | local ped = PlayerPedId() 61 | if Vehicle.Vehicle ~= nil then 62 | 63 | if IsVehicleSeatFree(Vehicle.Vehicle, -1) and GetVehicleEngineHealth(Vehicle.Vehicle) <= Config.DamageNeeded then 64 | ESX.Game.Utils.DrawText3D({x = Vehicle.Coords.x, y = Vehicle.Coords.y, z = Vehicle.Coords.z}, 'Press [~g~SHIFT~w~] and [~g~E~w~] to push the vehicle', 0.4) 65 | end 66 | 67 | 68 | if IsControlPressed(0, Keys["LEFTSHIFT"]) and IsVehicleSeatFree(Vehicle.Vehicle, -1) and not IsEntityAttachedToEntity(ped, Vehicle.Vehicle) and IsControlJustPressed(0, Keys["E"]) and GetVehicleEngineHealth(Vehicle.Vehicle) <= Config.DamageNeeded then 69 | NetworkRequestControlOfEntity(Vehicle.Vehicle) 70 | local coords = GetEntityCoords(ped) 71 | if Vehicle.IsInFront then 72 | AttachEntityToEntity(PlayerPedId(), Vehicle.Vehicle, GetPedBoneIndex(6286), 0.0, Vehicle.Dimensions.y * -1 + 0.1 , Vehicle.Dimensions.z + 1.0, 0.0, 0.0, 180.0, 0.0, false, false, true, false, true) 73 | else 74 | AttachEntityToEntity(PlayerPedId(), Vehicle.Vehicle, GetPedBoneIndex(6286), 0.0, Vehicle.Dimensions.y - 0.3, Vehicle.Dimensions.z + 1.0, 0.0, 0.0, 0.0, 0.0, false, false, true, false, true) 75 | end 76 | 77 | ESX.Streaming.RequestAnimDict('missfinale_c2ig_11') 78 | TaskPlayAnim(ped, 'missfinale_c2ig_11', 'pushcar_offcliff_m', 2.0, -8.0, -1, 35, 0, 0, 0, 0) 79 | Citizen.Wait(200) 80 | 81 | local currentVehicle = Vehicle.Vehicle 82 | while true do 83 | Citizen.Wait(5) 84 | if IsDisabledControlPressed(0, Keys["A"]) then 85 | TaskVehicleTempAction(PlayerPedId(), currentVehicle, 11, 1000) 86 | end 87 | 88 | if IsDisabledControlPressed(0, Keys["D"]) then 89 | TaskVehicleTempAction(PlayerPedId(), currentVehicle, 10, 1000) 90 | end 91 | 92 | if Vehicle.IsInFront then 93 | SetVehicleForwardSpeed(currentVehicle, -1.0) 94 | else 95 | SetVehicleForwardSpeed(currentVehicle, 1.0) 96 | end 97 | 98 | if HasEntityCollidedWithAnything(currentVehicle) then 99 | SetVehicleOnGroundProperly(currentVehicle) 100 | end 101 | 102 | if not IsDisabledControlPressed(0, Keys["E"]) then 103 | DetachEntity(ped, false, false) 104 | StopAnimTask(ped, 'missfinale_c2ig_11', 'pushcar_offcliff_m', 2.0) 105 | FreezeEntityPosition(ped, false) 106 | break 107 | end 108 | end 109 | end 110 | end 111 | end 112 | end) 113 | --------------------------------------------------------------------------------