diff --git a/helpers.lua b/helpers.lua index ea93137..9c1ff72 100644 --- a/helpers.lua +++ b/helpers.lua @@ -1,11 +1,20 @@ function ham_radio.validate_frequency(frequency) + local transmission_is_allowed = true local num_freq = tonumber(frequency) local freq = tostring(num_freq) + if next(ham_radio.find_transmitters(frequency)) then + if num_freq >= ham_radio.settings.locked_frequency.min + and num_freq <= ham_radio.settings.locked_frequency.max then + -- transmitter is in locked frequency range + transmission_is_allowed = false + end + end return freq == frequency and num_freq ~= nil and num_freq == math.floor(num_freq) and num_freq >= ham_radio.settings.frequency.min and num_freq <= ham_radio.settings.frequency.max + and transmission_is_allowed end function ham_radio.find_transmitters(frequency) diff --git a/init.lua b/init.lua index 876ccca..7e23e78 100644 --- a/init.lua +++ b/init.lua @@ -12,11 +12,18 @@ ham_radio = { broadcast_color = '#607d8b', broadcast_interval = 10, -- seconds hud_pos = { x = 0.5, y = 0.8 }, + -- radio frequency range frequency = { min = 0, max = 9999999 }, - beacon_frequency = { -- sub-range of frequency range + -- range where only one transmitter is permitted + locked_frequency = { + min = 100000, + max = 9999999 + }, + -- sub-range of frequency range + beacon_frequency = { min = 1000000, max = 9999999 },