ed
This commit is contained in:
		
							parent
							
								
									5a5b4b855d
								
							
						
					
					
						commit
						f57a27b8df
					
				
					 152 changed files with 1554 additions and 0 deletions
				
			
		
							
								
								
									
										
											BIN
										
									
								
								resources/[tools]/jg-hud/client/cl-cruise-control.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								resources/[tools]/jg-hud/client/cl-cruise-control.lua
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								resources/[tools]/jg-hud/client/cl-indicators.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								resources/[tools]/jg-hud/client/cl-indicators.lua
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								resources/[tools]/jg-hud/client/cl-main.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								resources/[tools]/jg-hud/client/cl-main.lua
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										94
									
								
								resources/[tools]/jg-hud/client/cl-nearest-postal.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								resources/[tools]/jg-hud/client/cl-nearest-postal.lua
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,94 @@ | |||
| -- This is a heavily modified & highly simplified version of nearest postal from @DevBlocky: https://github.com/DevBlocky/nearest-postal | ||||
| -- just for the purposes of displaying it in the HUD, as the exports for getting distance to nearest postal wasn't available. | ||||
| -- This IS NOT designed to be a replacement for nearest-postal, as it does not include commands for waypoints etc. I recommend still | ||||
| -- using nearest-postal alongside JG HUD! | ||||
|  | ||||
| ---- ORIGINAL LICENSE ---- | ||||
|  | ||||
| -- Copyright (c) 2019 BlockBa5her | ||||
|  | ||||
| -- Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
| -- of this software and associated documentation files (the "Software"), to deal | ||||
| -- in the Software without restriction, including without limitation the rights | ||||
| -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
| -- copies of the Software, and to permit persons to whom the Software is | ||||
| -- furnished to do so, subject to the following conditions: | ||||
|  | ||||
| -- The above copyright notice and this permission notice shall be included in all | ||||
| -- copies or substantial portions of the Software. | ||||
|  | ||||
| -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
| -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
| -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
| -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
| -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
| -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
| -- SOFTWARE. | ||||
|  | ||||
| ---@type boolean | ||||
| local postalsLoaded = false | ||||
|  | ||||
| CreateThread(function() | ||||
|   if not Config.ShowNearestPostal then return end | ||||
|  | ||||
|  | ||||
|     local jsonData = LoadResourceFile(GetCurrentResourceName(), Config.NearestPostalsData) | ||||
|     if not jsonData then  | ||||
|       return DebugPrint(("[ERROR] Could not find postals data file: %s"):format(Config.NearestPostalsData))  | ||||
|     end | ||||
|      | ||||
|     local postals = json.decode(jsonData) | ||||
|   | ||||
|     if not postals then | ||||
|       return DebugPrint("[ERROR] Failed to decode postals JSON data") | ||||
|     end | ||||
|  | ||||
|     for i = 1, #postals do | ||||
|       local postal = postals[i] | ||||
|       lib.grid.addEntry({ | ||||
|         coords = vec(postal.x, postal.y), | ||||
|         code = postal.code, | ||||
|         radius = 1 | ||||
|       }) | ||||
|     end | ||||
|      | ||||
|     postalsLoaded = true | ||||
|     DebugPrint(("Loaded %d postal codes into ox_lib grid system"):format(#postals)) | ||||
| end) | ||||
|  | ||||
| ---@param pos vector | ||||
| ---@return {code: string, dist: number} | false | ||||
| function GetNearestPostal(pos) | ||||
|   if not Config.ShowNearestPostal or not postalsLoaded then  | ||||
|     return false  | ||||
|   end | ||||
|  | ||||
|   local nearbyEntries = lib.grid.getNearbyEntries(pos) | ||||
|   if not nearbyEntries or #nearbyEntries == 0 then | ||||
|     return false | ||||
|   end | ||||
|  | ||||
|   local closestEntry, minDist | ||||
|  | ||||
|   -- Check only nearby entries from grid | ||||
|   for i = 1, #nearbyEntries do | ||||
|     local entry = nearbyEntries[i] | ||||
|     local dx = pos.x - entry.coords.x | ||||
|     local dy = pos.y - entry.coords.y | ||||
|     local dist = math.sqrt(dx * dx + dy * dy) | ||||
|      | ||||
|     if not minDist or dist < minDist then | ||||
|       closestEntry = entry | ||||
|       minDist = dist | ||||
|     end | ||||
|   end | ||||
|  | ||||
|   if not closestEntry then | ||||
|     return false | ||||
|   end | ||||
|  | ||||
|   return { | ||||
|     code = closestEntry.code, | ||||
|     dist = math.round(Framework.Client.ConvertDistance(minDist, UserSettingsData?.distanceMeasurement)) | ||||
|   } | ||||
| end | ||||
							
								
								
									
										
											BIN
										
									
								
								resources/[tools]/jg-hud/client/cl-ped.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								resources/[tools]/jg-hud/client/cl-ped.lua
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								resources/[tools]/jg-hud/client/cl-radar.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								resources/[tools]/jg-hud/client/cl-radar.lua
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										149
									
								
								resources/[tools]/jg-hud/client/cl-seatbelt.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										149
									
								
								resources/[tools]/jg-hud/client/cl-seatbelt.lua
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,149 @@ | |||
| IsSeatbeltOn = true | ||||
| local seatbeltThreadCreated = false | ||||
|  | ||||
| ---Can vehicle class have a seatbelt? Disabled for bikes, motorcycles boats etc by default | ||||
| ---@param vehicle integer | ||||
| ---@return boolean canHaveSeatbelt | ||||
| local function canVehicleClassHaveSeatbelt(vehicle) | ||||
|   if not Config.EnableSeatbelt then return false end | ||||
|  | ||||
|   if not vehicle or not DoesEntityExist(vehicle) then | ||||
|     return false | ||||
|   end | ||||
|    | ||||
|   local vehicleClass = GetVehicleClass(vehicle) | ||||
|    | ||||
|   local seatbeltCompatibleClasses = { | ||||
|     [0] = true,  -- Compacts | ||||
|     [1] = true,  -- Sedans | ||||
|     [2] = true,  -- SUVs | ||||
|     [3] = true,  -- Coupes | ||||
|     [4] = true,  -- Muscle | ||||
|     [5] = true,  -- Sports Classics | ||||
|     [6] = true,  -- Sports | ||||
|     [7] = true,  -- Super | ||||
|     [9] = true,  -- Off-road | ||||
|     [10] = true, -- Industrial | ||||
|     [11] = true, -- Utility | ||||
|     [12] = true, -- Vans | ||||
|     [17] = true, -- Service | ||||
|     [18] = true, -- Emergency | ||||
|     [19] = true, -- Military | ||||
|     [20] = true, -- Commercial | ||||
|   } | ||||
|    | ||||
|   -- Excluded veh classes | ||||
|   -- [8] = Motorcycles | ||||
|   -- [13] = Cycles/Bicycles | ||||
|   -- [14] = Boats | ||||
|   -- [15] = Helicopters | ||||
|   -- [16] = Planes | ||||
|   -- [21] = Trains | ||||
|    | ||||
|   return seatbeltCompatibleClasses[vehicleClass] or false | ||||
| end | ||||
|  | ||||
| ---Is a seatbelt allowed in this particular vehicle? Checks emergency vehicles, passenger seats etc | ||||
| ---@param vehicle integer | ||||
| ---@return boolean isSeatbeltAllowed | ||||
| local function isSeatbeltAllowed(vehicle) | ||||
|   if not Config.EnableSeatbelt then return false end | ||||
|   if not vehicle then return false end | ||||
|    | ||||
|   if not canVehicleClassHaveSeatbelt(vehicle) then | ||||
|     return false | ||||
|   end | ||||
|  | ||||
|   if Config.DisablePassengerSeatbelts and cache.seat ~= -1 then | ||||
|     return false | ||||
|   end | ||||
|    | ||||
|   if Config.DisableSeatbeltInEmergencyVehicles then | ||||
|     local vehicleClass = GetVehicleClass(vehicle) | ||||
|     if vehicleClass == 18 then -- Emergency vehicles | ||||
|       return false | ||||
|     end | ||||
|   end | ||||
|    | ||||
|   return true | ||||
| end | ||||
|  | ||||
| ---Simple built in seatbelt system using "fly through windscreen" natives | ||||
| ---@param willBeYeeted boolean | ||||
| local function setWhetherPedWillFlyThroughWindscreen(willBeYeeted) | ||||
|   SetFlyThroughWindscreenParams( | ||||
|     ((not willBeYeeted) and Config.MinSpeedMphEjectionSeatbeltOn or Config.MinSpeedMphEjectionSeatbeltOff) / 2.237, | ||||
|     1.0, 17.0, 10.0 | ||||
|   ) | ||||
|   SetPedConfigFlag(cache.ped, 32, willBeYeeted) | ||||
| end | ||||
|  | ||||
| ---Toggle seatbelt main function | ||||
| ---@param vehicle integer | ||||
| ---@param toggle boolean | ||||
| function ToggleSeatbelt(vehicle, toggle) | ||||
|   if not vehicle or not isSeatbeltAllowed(vehicle) then | ||||
|     return | ||||
|   end | ||||
|  | ||||
|   IsSeatbeltOn = toggle | ||||
|   LocalPlayer.state:set("seatbelt", toggle) -- for integrations with other scripts, like jg-stress-addon | ||||
|  | ||||
|   if Config.UseCustomSeatbeltIntegration then | ||||
|     Framework.Client.ToggleSeatbelt(vehicle, toggle) | ||||
|   else | ||||
|     setWhetherPedWillFlyThroughWindscreen(not toggle) | ||||
|   end | ||||
| end | ||||
|  | ||||
| ---Thread to disable exiting vehicle when seatbelt is on | ||||
| local function startSeatbeltExitPreventionThread() | ||||
|   if not Config.PreventExitWhileBuckled then return end | ||||
|   if seatbeltThreadCreated then return end | ||||
|   seatbeltThreadCreated = true | ||||
|    | ||||
|   CreateThread(function()   | ||||
|     while cache.vehicle do | ||||
|       if IsSeatbeltOn then | ||||
|         DisableControlAction(0, 75, true) | ||||
|         DisableControlAction(27, 75, true) | ||||
|       end | ||||
|        | ||||
|       Wait(1) | ||||
|     end | ||||
|      | ||||
|     seatbeltThreadCreated = false | ||||
|   end) | ||||
| end | ||||
|  | ||||
| ---When entering vehicle | ||||
| ---@param vehicle integer | ||||
| local function onEnterVehicle(vehicle) | ||||
|   if not isSeatbeltAllowed(vehicle) then | ||||
|     setWhetherPedWillFlyThroughWindscreen(false) | ||||
|     IsSeatbeltOn = true | ||||
|     return | ||||
|   end | ||||
|  | ||||
|   ToggleSeatbelt(vehicle, false) -- Seatbelt is off when entering vehicle | ||||
|   startSeatbeltExitPreventionThread() | ||||
| end | ||||
|  | ||||
| if Config.EnableSeatbelt then | ||||
|   lib.onCache("vehicle", onEnterVehicle) | ||||
|  | ||||
|   CreateThread(function() | ||||
|     if cache.vehicle then | ||||
|       onEnterVehicle(cache.vehicle) | ||||
|     end | ||||
|   end) | ||||
| end | ||||
|  | ||||
| -- Key mapping | ||||
| if Config.EnableSeatbelt and Config.SeatbeltKeybind then | ||||
|   RegisterCommand("toggle_seatbelt", function() | ||||
|     ToggleSeatbelt(cache.vehicle, not IsSeatbeltOn) | ||||
|   end, false) | ||||
|  | ||||
|   RegisterKeyMapping("toggle_seatbelt", "Toggle vehicle seatbelt", "keyboard", Config.SeatbeltKeybind or "B") | ||||
| end | ||||
							
								
								
									
										
											BIN
										
									
								
								resources/[tools]/jg-hud/client/cl-settings.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								resources/[tools]/jg-hud/client/cl-settings.lua
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								resources/[tools]/jg-hud/client/cl-trains.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								resources/[tools]/jg-hud/client/cl-trains.lua
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								resources/[tools]/jg-hud/client/cl-vehicle-controls.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								resources/[tools]/jg-hud/client/cl-vehicle-controls.lua
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								resources/[tools]/jg-hud/client/cl-vehicle.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								resources/[tools]/jg-hud/client/cl-vehicle.lua
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								resources/[tools]/jg-hud/client/cl-weapons.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								resources/[tools]/jg-hud/client/cl-weapons.lua
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Nordi98
						Nordi98