Hey guys,
I am trying to lock station 1-4 for specific jobs, in the clients.lua of the radio I have:
Citizen.CreateThread(function()
-- ESX - do not touch
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
if ESX.PlayerData.job.name == 'police' then -- police
exports["rp-radio"]:GivePlayerAccessToFrequencies(1)
elseif ESX.PlayerData.job.name == 'ambulance' then --EMS
exports["rp-radio"]:GivePlayerAccessToFrequencies(2)
elseif ESX.PlayerData.job.name == 'sheriff' then --sheriffs department
exports["rp-radio"]:GivePlayerAccessToFrequencies(3)
elseif ESX.PlayerData.job.name == 'mecano' then --mechanic
exports["rp-radio"]:GivePlayerAccessToFrequencies(4)
else
exports["rp-radio"]:RemovePlayerAccessToFrequencies(1, 2, 3, 4)
end
GenerateFrequencyList()
end)
Frequency = {
Private = { -- List of private frequencies
[1] = true,
[2] = true,
[3] = true,
[4] = true,
}, -- List of private frequencies
Current = 1, -- Don't touch
CurrentIndex = 1, -- Don't touch
Min = 1, -- Minimum frequency
Max = 1024, -- Max number of frequencies
List = {}, -- Frequency list, Don't touch
Access = {}, -- List of freqencies a player has access to
},
AllowRadioWhenClosed = true -- Allows the radio to be used when not open (uses police radio animation)
In the config, I have set those to private, however the script doesn’t error out, it doesn’t work as well. It won’t allow me to switch to those stations. Can you please provide some insight as to what I’m doing wrong?
EDIT: If I remove them from private frequencies in the config, everybody can join those frequencies.