├── .gitattributes ├── fxmanifest.lua ├── config.lua ├── README.md └── client └── main.lua /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version 'cerulean' 2 | game 'gta5' 3 | 4 | description 'cm-callsign' 5 | author 'CloakedManz' 6 | version '1.5.0' 7 | 8 | shared_scripts { 9 | 'config.lua' 10 | } 11 | 12 | client_script 'client/main.lua' 13 | 14 | lua54 'yes' 15 | -------------------------------------------------------------------------------- /config.lua: -------------------------------------------------------------------------------- 1 | Config = {} 2 | 3 | Config.ProjectSlothCars = true 4 | Config.CarLabs = false 5 | Config.UseQBTarget = true 6 | Config.QBNotify = false -- False by default, Uses chat when set to false, notifications are for /setcallsigncolor // Currently only CarLabs Supports it -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cm-callsign 2 | 3 | Welcome to CM-Callsign! 4 | 5 | This resource is intended to allow the end user to change the callsign on the roof of their police vehicle in FiveM. All vehicles must support a callsign system. 6 | 7 | Currently this script supports the Project Sloth Livery V2 pack & all CarLabs cars. If you want other packs to work with it, please create an issue on this script's Github issue tab. 8 | 9 | # How does it work? 10 | 11 | * Do /callsign NUMBERS 12 | * Do /setcallsign in the vehicle OR use the qb-target integration found below outside the car. 13 | * Your callsign will be on the roof of your car. Only numbers are supported, not letters. 14 | 15 | 16 | ### CarLabs Exclusive Features 17 | 18 | Use /setcallsigncolor COLOR(Lowercase Only) to change the callsign to one of six predefined colors. Only black, white, red, yellow, pink and blue are supported. 19 | 20 | If you enter an invalid color, you have the option of chat vs QBNotify notifications telling you the pre-defined colors. You can change this in the config.lua file. 21 | 22 | 23 | PS-Liveries - https://github.com/Project-Sloth/ps-liveries 24 | 25 | CarLabs - https://car-labs.tebex.io/ 26 | 27 | ### Credits 28 | [@MonkeyWhisper](https://github.com/MonkeyWhisper) - Code Refactor and Feature Additions 29 | 30 | [@lenzh](https://github.com/lenzh) - Code Refactor and Feature Additions 31 | -------------------------------------------------------------------------------- /client/main.lua: -------------------------------------------------------------------------------- 1 | local QBCore = exports['qb-core']:GetCoreObject() 2 | 3 | RegisterCommand('setcallsign', function(source, args, rawCommand) 4 | QBCore.Functions.GetPlayerData(function(PlayerData) 5 | if PlayerData.job.type == "leo" then 6 | local playerPed = PlayerPedId() 7 | local vehicle 8 | 9 | local callsign = PlayerData.metadata['callsign'] or 'NO CALLSIGN' 10 | 11 | cs, _ = callsign:gsub("%D+", "") 12 | 13 | if Config.UseQBTarget == true then 14 | vehicle = QBCore.Functions.GetClosestVehicle() 15 | else 16 | vehicle = GetVehiclePedIsIn(playerPed, false) 17 | end 18 | 19 | if #cs == 3 then 20 | local callsign1 = tonumber(string.sub(cs, 1, 1)) 21 | local callsign2 = tonumber(string.sub(cs, 2, 2)) 22 | local callsign3 = tonumber(string.sub(cs, 3, 3)) 23 | 24 | SetVehicleModKit(vehicle, 0) 25 | 26 | if Config.ProjectSlothCars == true then 27 | SetVehicleMod(vehicle, 28, callsign1, false) 28 | SetVehicleMod(vehicle, 29, callsign2, false) 29 | SetVehicleMod(vehicle, 30, callsign3, false) 30 | elseif Config.CarLabs == true then 31 | SetVehicleMod(vehicle, 42, callsign1, false) 32 | SetVehicleMod(vehicle, 44, callsign2, false) 33 | SetVehicleMod(vehicle, 45, callsign3, false) 34 | end 35 | else 36 | QBCore.Functions.Notify('Your callsign must be 3 digits long!', 'error', 7000) 37 | end 38 | else 39 | QBCore.Functions.Notify('You are not allowed to use this command!', 'error', 7000) 40 | end 41 | end) 42 | end) 43 | 44 | RegisterCommand('removecallsign', function(source, args, rawCommand) 45 | QBCore.Functions.GetPlayerData(function(PlayerData) 46 | if PlayerData.job.type == "leo" then 47 | local playerPed = PlayerPedId() 48 | local vehicle 49 | 50 | if Config.UseQBTarget == true then 51 | vehicle = QBCore.Functions.GetClosestVehicle() 52 | else 53 | vehicle = GetVehiclePedIsIn(playerPed, false) 54 | end 55 | 56 | SetVehicleModKit(vehicle, 0) 57 | 58 | if Config.ProjectSlothCars == true then 59 | SetVehicleMod(vehicle, 28, -1, false) 60 | SetVehicleMod(vehicle, 29, -1, false) 61 | SetVehicleMod(vehicle, 30, -1, false) 62 | elseif Config.CarLabs == true then 63 | SetVehicleMod(vehicle, 42, -1, false) 64 | SetVehicleMod(vehicle, 44, -1, false) 65 | SetVehicleMod(vehicle, 45, -1, false) 66 | end 67 | 68 | else 69 | QBCore.Functions.Notify('You are not allowed to use this command!', 'error', 7000) 70 | end 71 | end) 72 | end) 73 | 74 | RegisterCommand('setcallsigncolor', function(source, args, rawCommand) 75 | local PlayerData = QBCore.Functions.GetPlayerData() 76 | 77 | if PlayerData.job.type == "leo" then 78 | local playerPed = PlayerPedId() 79 | local vehicle = GetVehiclePedIsIn(playerPed, false) 80 | 81 | local color = tostring(args[1]) 82 | 83 | if color == "black" then 84 | SetVehicleDashboardColour(vehicle, 0) 85 | elseif color == "white" then 86 | SetVehicleDashboardColour(vehicle, 111) 87 | elseif color == "red" then 88 | SetVehicleDashboardColour(vehicle, 27) 89 | elseif color == "yellow" then 90 | SetVehicleDashboardColour(vehicle, 88) 91 | elseif color == "blue" then 92 | SetVehicleDashboardColour(vehicle, 64) 93 | elseif color == "pink" then 94 | SetVehicleDashboardColour(vehicle, 136) 95 | else 96 | if Config.QBNotify == true then 97 | QBCore.Functions.Notify('CM-Callsign: Invalid Color! Only black, white, red, yellow, pink, and blue are supported.', 'error', 7000) 98 | else 99 | TriggerEvent('chat:addMessage', { 100 | color = {255, 0, 0}, 101 | multiline = true, 102 | args = {"CM-Callsign", "Invalid Color! Only black, white, red, yellow, pink, and blue are supported."} 103 | }) 104 | end 105 | end 106 | else 107 | if Config.QBNotify == true then 108 | QBCore.Functions.Notify('You are not allowed to use this command!', 'error', 7000) 109 | else 110 | TriggerEvent('chat:addMessage', { 111 | color = {255, 0, 0}, 112 | multiline = true, 113 | args = {"System", "You are not allowed to use this command!"} 114 | }) 115 | end 116 | end 117 | end) 118 | 119 | local bones = { 120 | 'seat_dside_f' 121 | } 122 | 123 | exports['qb-target']:AddTargetBone(bones, { -- The bones can be a string or a table 124 | options = { -- This is your options table, in this table all the options will be specified for the target to accept 125 | { -- This is the first table with options, you can make as many options inside the options table as you want 126 | type = "command", 127 | event = "setcallsign", 128 | icon = "fas fa-key", 129 | label = "Set Callsign2", 130 | job = {["sasp"] = 0, ["police"] = 0, ["bcso"] = 0,} 131 | }, 132 | { -- This is the first table with options, you can make as many options inside the options table as you want 133 | type = "command", 134 | event = "removecallsign", 135 | icon = "fas fa-key", 136 | label = "Remove Callsign2", 137 | job = {["sasp"] = 0, ["police"] = 0, ["bcso"] = 0,} 138 | }, 139 | 140 | }, 141 | distance = 4, -- This is the distance for you to be at for the target to turn blue, this is in GTA units and has to be a float value 142 | }) 143 | --------------------------------------------------------------------------------