├── fxmanifest.lua ├── README.md └── megaphonepolice.lua /fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version 'bodacious' 2 | 3 | game 'gta5' 4 | lua54 'yes' 5 | author 'AnnaLou#1509' 6 | github 'https://github.com/Annalouu' 7 | 8 | client_scripts { 9 | "megaphonepolice.lua", 10 | } 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # an-policecarmegaphone 2 | 3 | A small script i wrote to add the ability to have a megaphone in the cop cars 4 | 5 | - You can either run this by itself or get the megaphonepolice.lua and add it to your qb-policejob client and add it to your fxmanifest 6 | 7 | # Usage: 8 | - Hold LeftShift and keep holding it and then use your push to talk to speak loudly. 9 | 10 | Optimised by: https://github.com/JericoFX 11 | -------------------------------------------------------------------------------- /megaphonepolice.lua: -------------------------------------------------------------------------------- 1 | local QBCore = exports['qb-core']:GetCoreObject() 2 | local PlayerData = {} 3 | 4 | RegisterNetEvent('QBCore:Player:SetPlayerData', function(val) 5 | PlayerData = val 6 | end) 7 | 8 | local function CheckPlayer() 9 | local Player = PlayerPedId() 10 | local getVehiclePedIsIn = GetVehiclePedIsIn(Player, false) > 0 and GetVehiclePedIsIn(Player, false) or 11 | 0 -- Get the vehicle the ped is in, if is > than 0 means the player is in a vehicle 12 | if getVehiclePedIsIn == 0 then return end 13 | local vehicleClass = GetVehicleClass(getVehiclePedIsIn) == 18 and true or false --get the class of it 14 | if not vehicleClass then 15 | return 16 | end 17 | return vehicleClass 18 | end 19 | 20 | --https://cookbook.fivem.net/2020/01/06/using-the-new-console-key-bindings/ 21 | RegisterCommand('+Megaphone', function() 22 | if not PlayerData.job then PlayerData = QBCore.Functions.GetPlayerData() end 23 | if PlayerData.job.name == "police" and CheckPlayer() then 24 | exports["pma-voice"]:overrideProximityRange(30.0, true) 25 | QBCore.Functions.Notify('Megaphone on', 'success') 26 | end 27 | end, false) 28 | 29 | RegisterCommand('-Megaphone', function() 30 | if not PlayerData.job then PlayerData = QBCore.Functions.GetPlayerData() end 31 | if PlayerData.job.name == "police" and CheckPlayer() then 32 | exports["pma-voice"]:clearProximityOverride() 33 | QBCore.Functions.Notify('Megaphone off', 'error') 34 | end 35 | end, false) 36 | 37 | RegisterKeyMapping('+Megaphone', 'Talk on the Megaphone', 'keyboard', 'LSHIFT') 38 | --------------------------------------------------------------------------------