├── LICENSE ├── README.md ├── client.lua ├── fxmanifest.lua └── server.lua /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 JG Scripts 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JG Vehicle Indicators (Standalone) 2 | 3 | Simple, server synced vehicle turn signals and hazard lights for FiveM. 4 | 5 | ## How? 6 | 7 | Uses modern state bags to sync indicators to all clients, with no performance impact (0ms resmon) 8 | 9 | ## Requirements 10 | 11 | - OneSync Infinity 12 | 13 | ## Default keybinds 14 | 15 | `Left arrow key` = Left turn signal 16 | 17 | `Right arrow key` = Right turn signal 18 | 19 | `Up arrow key` = Hazard lights 20 | 21 | You can change Key binds in game by hitting `Escape -> Settings -> Key Bindings -> FiveM -> Look for (jg-vehicleindicators) key binds` 22 | 23 | ## Credits 24 | 25 | Made by JG Scripts https://jgscripts.com 26 | -------------------------------------------------------------------------------- /client.lua: -------------------------------------------------------------------------------- 1 | local function isIndicating(vehicle, type) 2 | if not Entity(vehicle).state.indicate then return false end 3 | local state = Entity(vehicle).state.indicate 4 | 5 | if state[1] and state[2] and type == "hazards" then return true end 6 | if state[1] and not state[2] and type == "right" then return true end 7 | if not state[1] and state[2] and type == "left" then return true end 8 | 9 | return false 10 | end 11 | 12 | local function indicate(type) 13 | local ped = PlayerPedId() 14 | if not IsPedInAnyVehicle(ped) then return false end 15 | local vehicle = GetVehiclePedIsIn(ped) 16 | 17 | local value = {} 18 | if type == "left" and not isIndicating(vehicle, "left") then value = {false, true} 19 | elseif type == "right" and not isIndicating(vehicle, "right") then value = {true, false} 20 | elseif type == "hazards" and not isIndicating(vehicle, "hazards") then value = {true, true} 21 | else value = {false, false} end 22 | 23 | TriggerServerEvent("jg-vehicleindicators:server:set-state", VehToNet(vehicle), value) 24 | end 25 | 26 | AddStateBagChangeHandler("indicate", nil, function(bagName, key, data) 27 | local entity = GetEntityFromStateBagName(bagName) 28 | if entity == 0 then return end 29 | for i, status in ipairs(data) do 30 | SetVehicleIndicatorLights(entity, i - 1, status) 31 | end 32 | end) 33 | 34 | RegisterCommand("indicate_left", function() indicate("left") end) 35 | RegisterKeyMapping('indicate_left', 'Vehicle indicate left', 'keyboard', 'LEFT') 36 | 37 | RegisterCommand("indicate_right", function() indicate("right") end) 38 | RegisterKeyMapping('indicate_right', 'Vehicle indicate right', 'keyboard', 'RIGHT') 39 | 40 | RegisterCommand("hazards", function() indicate("hazards") end) 41 | RegisterKeyMapping('hazards', 'Vehicle hazards', 'keyboard', 'UP') -------------------------------------------------------------------------------- /fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version "cerulean" 2 | game "gta5" 3 | lua54 "yes" 4 | 5 | description "Synced turn signals & hazards" 6 | version "1.0" 7 | author "JG Scripts" 8 | 9 | client_scripts {"client.lua"} 10 | 11 | server_scripts {"server.lua"} -------------------------------------------------------------------------------- /server.lua: -------------------------------------------------------------------------------- 1 | RegisterServerEvent("jg-vehicleindicators:server:set-state", function(netId, value) 2 | local vehicle = NetworkGetEntityFromNetworkId(netId) 3 | Entity(vehicle).state.indicate = value 4 | end) --------------------------------------------------------------------------------