├── fxmanifest.lua ├── server └── server.lua ├── .github └── FUNDING.yml ├── config.lua ├── README.md ├── LICENSE └── client └── client.lua /fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version "adamant" 2 | game "gta5" 3 | 4 | shared_scripts { 5 | "config.lua" 6 | } 7 | 8 | client_scripts { 9 | 'client/*.lua' 10 | } 11 | 12 | server_scripts { 13 | "server/*.lua" 14 | } -------------------------------------------------------------------------------- /server/server.lua: -------------------------------------------------------------------------------- 1 | RegisterNetEvent('az_wheel:updatewheel') 2 | AddEventHandler('az_wheel:updatewheel', function(veh, index, offset, obj) 3 | TriggerClientEvent('az_wheel:updatewheelclient', -1, veh, index, offset, obj) 4 | end) 5 | 6 | RegisterNetEvent('az_wheel:setoffsetserver') 7 | AddEventHandler('az_wheel:setoffsetserver', function(veh, index, offset, obj) 8 | TriggerClientEvent('az_wheel:setoffset', -1, veh, index, offset, obj) 9 | end) -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: azeroth 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /config.lua: -------------------------------------------------------------------------------- 1 | Config = {} 2 | 3 | Config.FrameWork = "ESX" -- ESX / QBCore / custom 4 | 5 | Config.TriggerFix = false 6 | Config.CommandFix = true 7 | 8 | Config.TimeToDetachWheel = 1000 9 | Config.TimeToAttachWheel = 5000 10 | Config.KmMax = 200 11 | 12 | Config.Lang = { 13 | ["StartFixWheel"] = 'Repair of the wheels thrown, please exit the vehicle', 14 | ["EnterInVehicleToFix"] = 'No vehicle found, please enter the vehicle to be repaired', 15 | ["PressToPickWheel"] = 'Press E to pick up the wheel', 16 | ["PressToFixWheel"] = 'Press E to fix the wheel', 17 | ["PlayerInVeh"] = 'There is someone in the vehicle' 18 | } 19 | 20 | Config.SendNotification = function(msg) 21 | if Config.FrameWork == "ESX" then 22 | ESX.ShowNotification(msg) 23 | elseif Config.FrameWork == "QBCore" then 24 | QBCore.Functions.Notify(msg, 'success') 25 | elseif Config.FrameWork == "custom" then 26 | print(msg) 27 | end 28 | end 29 | 30 | Config.InitFrameWork = function() 31 | if Config.FrameWork == "ESX" then 32 | ESX = nil TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) 33 | elseif Config.FrameWork == "QBCore" then 34 | QBCore = exports['qb-core']:GetCoreObject() 35 | elseif Config.FrameWork == "custom" then 36 | 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Group 2 (13)](https://user-images.githubusercontent.com/76072277/212427113-123c0e95-9982-41de-a4fd-32ac33340bd2.png) 2 | 3 | [![Love](http://ForTheBadge.com/images/badges/built-with-love.svg)](https://github.com/Azerothwav) [![name](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://forum.cfx.re/t/realistic-vehicle-failure-repair-fix/4887760/2) [![name](https://img.shields.io/badge/YouTube-FF0000?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/channel/UCH7coJ4d1gqh8BMMHacGQ5A) [![LUA](https://img.shields.io/badge/Lua-2C2D72?style=for-the-badge&logo=lua&logoColor=white)](https://www.lua.org) [![Ko-Fi](https://img.shields.io/badge/Ko--fi-F16061?style=for-the-badge&logo=ko-fi&logoColor=white)](https://ko-fi.com/azeroth) 4 | 5 | # Installation 6 | curl https://github.com/Azerothwav/Az_wheeldamage 7 | 8 | # Informations 9 | This script allows you to add a new element of realism to your server by adding the possibility of losing wheels. 10 | 11 | ![alt text](https://media.discordapp.net/attachments/912680553503948821/996428698565754890/unknown.png?width=1405&height=701) 12 | 13 | ## Requirements to trigger the loss of wheels: 14 | - Make a jump that lasts more than 1 second (configurable in the config.lua) 15 | - Make a collision with a certain speed (configurable in the config.lua) 16 | 17 | 18 | The wheels are removable to be put back on the original vehicle. 19 | 20 | ![alt text](https://media.discordapp.net/attachments/912680553503948821/996428806766198804/unknown.png) 21 | 22 | ## Integration for other script 23 | A trigger is available to allow your mechanic script to repair the damaged vehicle. 24 | 25 | TriggerEvent("az_wheel:fixvehicle") 26 | 27 | ## Limitation 28 | The limitations of GTA make that the motorcycle wheels are not detachable, so they are immune. I also limited the wheels for boats, planes and helicopters. The off-road wheels allow to override the fact of losing a wheel via height but not via collisions. 29 | 30 | ## Known bugs: 31 | - Vehicles can sometimes bug and go under the map (rare but it can happen) 32 | 33 | ## Framework 34 | **QBCore / ESX / Standalone / Custom** 35 | 36 | # Preview 37 | https://www.youtube.com/watch?v=TYFLSRikyyA&t=1s 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /client/client.lua: -------------------------------------------------------------------------------- 1 | Config.InitFrameWork() 2 | 3 | local WheelAlreadyBroken = {} 4 | local objroue = {} 5 | table.insert(WheelAlreadyBroken, {index = 'none', vehicule = 'none'}) 6 | 7 | local RouePos = { 8 | [0] = {bone = 'wheel_lf', props = 'prop_wheel_01'}, 9 | [1] = {bone = 'wheel_rf', props = 'prop_wheel_01'}, 10 | [2] = {bone = 'wheel_lr', props = 'prop_wheel_01'}, 11 | [3] = {bone = 'wheel_rr', props = 'prop_wheel_01'}, 12 | } 13 | 14 | startcheck = true 15 | local havefind = false 16 | local havefind2 = false 17 | local havefind3 = false 18 | local havefind4 = false 19 | Citizen.CreateThread(function() 20 | while startcheck do 21 | local vehicle = GetVehiclePedIsIn(GetPlayerPed(-1), false) 22 | local wait = 1000 23 | if vehicle ~= 0 and GetPedInVehicleSeat(GetVehiclePedIsIn(PlayerPedId()), -1) == PlayerPedId() then 24 | local classveh = GetVehicleClass(vehicle) 25 | local classwheel = GetVehicleWheelType(vehicle) 26 | if classveh == 14 or classveh == 15 or classveh == 16 or classveh == 8 or classwheel == 4 then 27 | else 28 | wait = 0 29 | local roue = GetVehicleNumberOfWheels(vehicle) - 1 30 | for i = 0, roue, 1 do 31 | if tonumber(GetVehicleWheelSuspensionCompression(vehicle, i)) == 0.00 and not injump and GetVehicleWheelXOffset(vehicle, i) ~= '-nan' then 32 | injump = true 33 | Citizen.SetTimeout(Config.TimeToDetachWheel, function() 34 | for k, v in pairs(WheelAlreadyBroken) do 35 | if v.index == i then 36 | havefind = true 37 | end 38 | end 39 | if not havefind then 40 | ChechIfDetach(vehicle, i) 41 | else 42 | if i < 3 then 43 | for k, v in pairs(WheelAlreadyBroken) do 44 | if v.index == i + 1 then 45 | havefind2 = true 46 | end 47 | end 48 | if not havefind2 then 49 | ChechIfDetach(vehicle, i + 1) 50 | else 51 | if i < 3 then 52 | for k, v in pairs(WheelAlreadyBroken) do 53 | if v.index == i + 2 then 54 | havefind3 = true 55 | end 56 | end 57 | if not havefind3 then 58 | ChechIfDetach(vehicle, i + 2) 59 | else 60 | if i < 3 then 61 | for k, v in pairs(WheelAlreadyBroken) do 62 | if v.index == i + 3 then 63 | havefind4 = true 64 | end 65 | end 66 | if not havefind4 then 67 | ChechIfDetach(vehicle, i + 3) 68 | end 69 | end 70 | end 71 | end 72 | end 73 | end 74 | end 75 | end) 76 | end 77 | end 78 | end 79 | end 80 | Citizen.Wait(wait) 81 | end 82 | end) 83 | local inchek = false 84 | Citizen.CreateThread(function() 85 | lastkm = nil 86 | oldcompteurlaunch = false 87 | local wait = 1000 88 | while startcheck do 89 | local vehicle = GetVehiclePedIsIn(GetPlayerPed(-1), false) 90 | if vehicle ~= 0 and GetPedInVehicleSeat(GetVehiclePedIsIn(PlayerPedId()), -1) == PlayerPedId() then 91 | local classveh = GetVehicleClass(vehicle) 92 | if classveh == 14 or classveh == 15 or classveh == 16 or classveh == 8 then 93 | else 94 | wait = 0 95 | if not oldcompteurlaunch then 96 | oldcompteurlaunch = true 97 | Citizen.SetTimeout(1000, function() 98 | lastkm = math.ceil(GetEntitySpeed(vehicle) * 3.6) 99 | oldcompteurlaunch = false 100 | end) 101 | end 102 | if lastkm then 103 | if HasEntityCollidedWithAnything(vehicle) and lastkm >= Config.KmMax then 104 | if not inchek and GetVehicleWheelXOffset(vehicle, i) ~= '-nan' then 105 | inchek = true 106 | local roue = GetVehicleNumberOfWheels(vehicle) - 1 107 | for i = 0, roue, 1 do 108 | for k, v in pairs(WheelAlreadyBroken) do 109 | if v.index == i then 110 | havefind = true 111 | end 112 | end 113 | if not havefind then 114 | ChechIfDetachGround(vehicle, i) 115 | else 116 | if i < 3 then 117 | for k, v in pairs(WheelAlreadyBroken) do 118 | if v.index == i + 1 then 119 | havefind2 = true 120 | end 121 | end 122 | if not havefind2 then 123 | ChechIfDetachGround(vehicle, i + 1) 124 | else 125 | if i < 3 then 126 | for k, v in pairs(WheelAlreadyBroken) do 127 | if v.index == i + 2 then 128 | havefind3 = true 129 | end 130 | end 131 | if not havefind3 then 132 | ChechIfDetachGround(vehicle, i + 2) 133 | else 134 | if i < 3 then 135 | for k, v in pairs(WheelAlreadyBroken) do 136 | if v.index == i + 3 then 137 | havefind4 = true 138 | end 139 | end 140 | if not havefind4 then 141 | ChechIfDetachGround(vehicle, i + 3) 142 | end 143 | end 144 | end 145 | end 146 | end 147 | end 148 | end 149 | end 150 | end 151 | end 152 | end 153 | end 154 | end 155 | Citizen.Wait(wait) 156 | end 157 | end) 158 | 159 | local wheelpickup = false 160 | 161 | if Config.CommandFix then 162 | RegisterCommand("startfix", function() 163 | for k, v in pairs(WheelAlreadyBroken) do 164 | local playercoords = GetEntityCoords(GetPlayerPed(-1)) 165 | local vehicle = GetVehiclePedIsIn(GetPlayerPed(-1), false) 166 | if vehicle ~= 0 then 167 | if vehicle == v.vehicule then 168 | wheelpickup = true 169 | SetCurrentPedWeapon(GetPlayerPed(-1), 0xA2719263) 170 | AttachEntityToEntity(v.obj, GetPlayerPed(-1), GetPedBoneIndex(GetPlayerPed(-1), 28422), 0.0, 0.0, 0.0, 135.0, 0.0, 0.0, 1, 1, 0, 0, 2, 1) 171 | Config.SendNotification(Config.Lang["StartFixWheel"]) 172 | Citizen.Wait(5000) 173 | startdistancevehiclevar = true 174 | Startdistancevehicle(v.vehicule, v.obj, v.index) 175 | end 176 | else 177 | Config.SendNotification(Config.Lang["EnterInVehicleToFix"]) 178 | end 179 | end 180 | end, false) 181 | end 182 | 183 | if Config.TriggerFix then 184 | RegisterNetEvent('az_wheel:fixvehicle') 185 | AddEventHandler('az_wheel:fixvehicle', function() 186 | for k, v in pairs(WheelAlreadyBroken) do 187 | local playercoords = GetEntityCoords(GetPlayerPed(-1)) 188 | local vehicle = GetVehiclePedIsIn(GetPlayerPed(-1), false) 189 | if vehicle ~= 0 then 190 | if vehicle == v.vehicule then 191 | wheelpickup = true 192 | SetCurrentPedWeapon(GetPlayerPed(-1), 0xA2719263) 193 | AttachEntityToEntity(v.obj, GetPlayerPed(-1), GetPedBoneIndex(GetPlayerPed(-1), 28422), 0.0, 0.0, 0.0, 135.0, 0.0, 0.0, 1, 1, 0, 0, 2, 1) 194 | Config.SendNotification(Config.Lang["StartFixWheel"]) 195 | Citizen.Wait(5000) 196 | startdistancevehiclevar = true 197 | Startdistancevehicle(v.vehicule, v.obj, v.index) 198 | end 199 | else 200 | Config.SendNotification(Config.Lang["EnterInVehicleToFix"]) 201 | end 202 | end 203 | end) 204 | end 205 | 206 | Citizen.CreateThread(function() 207 | while true do 208 | local wait = 1000 209 | for k, v in pairs(WheelAlreadyBroken) do 210 | local playercoords = GetEntityCoords(GetPlayerPed(-1)) 211 | local coordsroue = GetEntityCoords(v.obj) 212 | if GetDistanceBetweenCoords(playercoords, coordsroue, true) < 2 then 213 | wait = 0 214 | if not wheelpickup then 215 | DrawText3Ds(coordsroue.x, coordsroue.y, coordsroue.z + 0.50, Config.Lang["PressToPickWheel"]) 216 | end 217 | if IsControlJustReleased(0, 38) and not wheelpickup then 218 | wheelpickup = true 219 | SetCurrentPedWeapon(GetPlayerPed(-1), 0xA2719263) 220 | AttachEntityToEntity(v.obj, GetPlayerPed(-1), GetPedBoneIndex(GetPlayerPed(-1), 28422), 0.0, 0.0, 0.0, 135.0, 0.0, 0.0, 1, 1, 0, 0, 2, 1) 221 | startdistancevehiclevar = true 222 | Startdistancevehicle(v.vehicule, v.obj, v.index) 223 | end 224 | end 225 | end 226 | Citizen.Wait(wait) 227 | end 228 | end) 229 | 230 | local sendtoserver = false 231 | function Startdistancevehicle(vehicule, obj, index) 232 | local wait = 1000 233 | local draw3dtext = false 234 | Citizen.CreateThread(function() 235 | while startdistancevehiclevar do 236 | local vehiclecoords = GetEntityCoords(vehicule) 237 | local playercoords = GetEntityCoords(GetPlayerPed(-1)) 238 | local vehicleheading = GetEntityHeading(vehicule) 239 | if GetDistanceBetweenCoords(playercoords, vehiclecoords, true) < 3 then 240 | wait = 0 241 | if not draw3dtext then 242 | DrawText3Ds(vehiclecoords.x, vehiclecoords.y, vehiclecoords.z, Config.Lang["PressToFixWheel"]) 243 | end 244 | if IsControlJustReleased(0, 38) then 245 | local findplayerin = false 246 | for l = 0, 5, 1 do 247 | if GetPedInVehicleSeat(vehicule, l - 1) ~= 0 then 248 | findplayerin = true 249 | end 250 | end 251 | if not findplayerin then 252 | draw3dtext = true 253 | Citizen.SetTimeout(5000, function() 254 | sendtoserver = false 255 | end) 256 | local phantomveh = CreateVehicle(GetHashKey("baller"), vehiclecoords, vehicleheading, false, false) 257 | FreezeEntityPosition(phantomveh, true) 258 | SetEntityCollision(phantomveh, false, false) 259 | SetEntityVisible(phantomveh, false, false) 260 | for k, v in pairs(RouePos) do 261 | if k == index then 262 | local roueposition = GetWorldPositionOfEntityBone(phantomveh, GetEntityBoneIndexByName(phantomveh, v.bone)) 263 | TaskStartScenarioInPlace(GetPlayerPed(-1), "CODE_HUMAN_MEDIC_KNEEL", 0, true) 264 | Citizen.Wait(Config.TimeToAttachWheel) 265 | ClearPedTasksImmediately(GetPlayerPed(-1)) 266 | if not sendtoserver then 267 | sendtoserver = true 268 | TriggerServerEvent('az_wheel:updatewheel', VehToNet(vehicule), index, GetVehicleWheelXOffset(phantomveh, index), ObjToNet(obj)) 269 | end 270 | DeleteEntity(phantomveh) 271 | end 272 | end 273 | Citizen.SetTimeout(2500, function() 274 | wheelpickup = false 275 | if index == 0 then 276 | if havefind then 277 | havefind = false 278 | end 279 | elseif index == 1 then 280 | if havefind2 then 281 | havefind2 = false 282 | end 283 | elseif index == 2 then 284 | if havefind3 then 285 | havefind3 = false 286 | end 287 | elseif index == 3 then 288 | if havefind4 then 289 | havefind4 = false 290 | end 291 | end 292 | end) 293 | startdistancevehiclevar = false 294 | else 295 | Config.SendNotification(Config.Lang["PlayerInVeh"]) 296 | end 297 | end 298 | end 299 | Citizen.Wait(wait) 300 | end 301 | end) 302 | end 303 | 304 | function DrawText3Ds(x,y,z, text) 305 | local onScreen,_x,_y=World3dToScreen2d(x,y,z) 306 | local px,py,pz=table.unpack(GetGameplayCamCoords()) 307 | 308 | SetTextScale(0.32, 0.32) 309 | SetTextFont(4) 310 | SetTextProportional(1) 311 | SetTextColour(255, 255, 255, 255) 312 | SetTextEntry("STRING") 313 | SetTextCentre(1) 314 | AddTextComponentString(text) 315 | DrawText(_x,_y) 316 | local factor = (string.len(text)) / 500 317 | DrawRect(_x,_y+0.0125, 0.015+ factor, 0.03, 0, 0, 0, 80) 318 | end 319 | 320 | function ChechIfDetachGround(vehicle, i) 321 | if not incooldowncheckground then 322 | local findwheel = false 323 | local havefind = false 324 | local inground = false 325 | incooldowncheckground = true 326 | Citizen.SetTimeout(1000, function() 327 | incooldowncheckground = false 328 | inchek = false 329 | end) 330 | if GetVehicleWheelXOffset(vehicle, i) ~= '-nan' then 331 | for k, v in pairs(WheelAlreadyBroken) do 332 | if v.index == i then 333 | havefind = true 334 | end 335 | if v.obj == objroue[i] then 336 | havefind = true 337 | end 338 | end 339 | if not havefind then 340 | for k, v in pairs(RouePos) do 341 | if k == i then 342 | if objroue[i] == nil then 343 | local roueposition = GetWorldPositionOfEntityBone(vehicle, GetEntityBoneIndexByName(vehicle, v.bone)) 344 | if not HasModelLoaded(v.props) then 345 | RequestModel(v.props) 346 | while not HasModelLoaded(v.props) do 347 | Citizen.Wait(1) 348 | end 349 | end 350 | objroue[i] = CreateObject(v.props, roueposition, false) 351 | TriggerServerEvent('az_wheel:setoffsetserver', VehToNet(vehicle), i, -math.random(1000, 1025), objroue[i]) 352 | end 353 | end 354 | end 355 | else 356 | if i < 3 then 357 | ChechIfDetachGround(vehicle, i + 1) 358 | end 359 | end 360 | end 361 | end 362 | end 363 | 364 | function ChechIfDetach(vehicle, i) 365 | if not incooldowncheck then 366 | local havefind = false 367 | local inground = false 368 | local hauteur = 0 369 | incooldowncheck = true 370 | Citizen.SetTimeout(1000, function() 371 | incooldowncheck = false 372 | injump = false 373 | if inchek then 374 | inchek = false 375 | end 376 | end) 377 | if tonumber(GetVehicleWheelSuspensionCompression(vehicle, i)) == 0.00 and GetVehicleWheelXOffset(vehicle, i) ~= '-nan' then 378 | for k, v in pairs(WheelAlreadyBroken) do 379 | if v.index == i then 380 | havefind = true 381 | end 382 | if v.obj and v.obj ~= nil then 383 | if v.obj == objroue[i] then 384 | havefind = true 385 | end 386 | end 387 | end 388 | if not havefind then 389 | while not inground do 390 | for n = 0, 4, 1 do 391 | hauteur = hauteur + tonumber(GetVehicleWheelSuspensionCompression(vehicle, i)) 392 | if hauteur > 0 then 393 | inground = true 394 | end 395 | end 396 | Citizen.Wait(0) 397 | end 398 | for k, v in pairs(RouePos) do 399 | if k == i then 400 | if objroue[i] == nil then 401 | local roueposition = GetWorldPositionOfEntityBone(vehicle, GetEntityBoneIndexByName(vehicle, v.bone)) 402 | if not HasModelLoaded(v.props) then 403 | RequestModel(v.props) 404 | while not HasModelLoaded(v.props) do 405 | Citizen.Wait(1) 406 | end 407 | end 408 | objroue[i] = CreateObject(v.props, roueposition, false) 409 | TriggerServerEvent('az_wheel:setoffsetserver', VehToNet(vehicle), i, -math.random(1000, 1025), objroue[i]) 410 | end 411 | end 412 | end 413 | else 414 | if i < 3 then 415 | ChechIfDetach(vehicle, i + 1) 416 | end 417 | end 418 | end 419 | end 420 | end 421 | 422 | RegisterNetEvent('az_wheel:setoffset') 423 | AddEventHandler('az_wheel:setoffset', function(veh, index, offset, obj) 424 | if index and veh and offset then 425 | table.insert(WheelAlreadyBroken, {index = index, vehicule = NetToVeh(veh), obj = obj}) 426 | SetVehicleWheelXOffset(NetToVeh(veh), index, offset) 427 | end 428 | end) 429 | 430 | RegisterNetEvent('az_wheel:updatewheelclient') 431 | AddEventHandler('az_wheel:updatewheelclient', function(veh, index, offset, obj) 432 | if index and veh and offset and obj then 433 | SetVehicleWheelXOffset(NetToVeh(veh), index, offset) 434 | for z, w in pairs(WheelAlreadyBroken) do 435 | if w.obj == obj and w.index == index then 436 | WheelAlreadyBroken[z] = nil 437 | end 438 | end 439 | DeleteEntity(obj) 440 | for k, v in pairs(objroue) do 441 | if v == obj then 442 | objroue[k] = nil 443 | end 444 | end 445 | Citizen.Wait(5000) 446 | end 447 | end) 448 | 449 | Citizen.CreateThread(function() 450 | while true do 451 | local vehicle = GetVehiclePedIsIn(GetPlayerPed(-1), false) 452 | if vehicle ~= 0 then 453 | if #WheelAlreadyBroken > 0 then 454 | for k, v in pairs(WheelAlreadyBroken) do 455 | if v.index and v.index ~= nil and v.vehicule and v.vehicule ~= 'none' then 456 | if v.vehicule == vehicle then 457 | SetEntityCollision(v.vehicule, true, true) 458 | SetVehicleWheelXOffset(v.vehicule, v.index, -math.random(1000, 1025)) 459 | end 460 | end 461 | end 462 | end 463 | end 464 | Citizen.Wait(0) 465 | end 466 | end) --------------------------------------------------------------------------------