Qbox-project / qbx_radio

GNU General Public License v3.0
2 stars 11 forks source link

whitelistSubChannels false is unemployed can't join 12 channel #34

Open MisakiVanilla opened 3 months ago

MisakiVanilla commented 3 months ago

Summary

Rewrite restrictedChannels in a loop

Reproduction

  1. Config.whitelistSubChannels is false
  2. unemployed people join 12 channnel use radio

Expected behavior

Join radio channnel. can talk radio

Actual behavior

Can't Join. and not show error

Additional context

qbx_radio\server\main.lua

Since you are rewriting the restrictedChannels of the loop source within the loop, you are limited to about 14 channels.

if not config.whitelistSubChannels then
    for channel, jobs in pairs(restrictedChannels) do
        for i = 1, 99 do
            restrictedChannels[channel + (i / 100)] = jobs
        end
    end
end

Fix Idea

I think you can fix this by creating a temporary table like this and setting it in a separate loop.

local updatedChannels = {}

for channel, jobs in pairs(restrictedChannels) do
    for i = 1, 99 do
        updatedChannels[channel + (i / 100)] = jobs
    end
end

for key, value in pairs(updatedChannels) do
    restrictedChannels[key] = value
end

Current Version

v1.0.0

Custom Resources

pma-voice

mafewtm commented 3 months ago

So I have all the same parameters you currently have and I'm able to be unemployed and connected to channel 12.

MisakiVanilla commented 3 months ago

"You're connected to: 12MHz" is displayed on message, but I cannot talk using the pma-voice "Talk over radio" key. animation doesn't work either.

I can talk to channel 12 with police. i can't talk to channel 12 with unemployed

MisakiVanilla commented 3 months ago

I added a log to this section and confirmed that control of channels 12 and 13 was added. The configuration file only has up to 10 configured.

if not config.whitelistSubChannels then
    for channel, jobs in pairs(restrictedChannels) do
       print("channnel : " .. channel) -- here add log
        for i = 1, 99 do
            restrictedChannels[channel + (i / 100)] = jobs
        end
    end
end
mafewtm commented 3 months ago

I'm confused what you're actual issue is. I can't tell if this is a code issue or your own keybind issue. Show your config/shared.lua please

MisakiVanilla commented 3 months ago

I haven't edited the config file スクリーンショット 2024-07-16 084749

Install the server with QBox txAdminRecipe and add log code. If there are no problems, only 1, 2, 3, 4, 5, 6, 7, 8, 9, and 10 should be displayed.

However, due to a loop error, this is displayed in server log.

[    script:qbx_radio] channnel : 1
[    script:qbx_radio] channnel : 2
[    script:qbx_radio] channnel : 3
[    script:qbx_radio] channnel : 4
[    script:qbx_radio] channnel : 5
[    script:qbx_radio] channnel : 6
[    script:qbx_radio] channnel : 7
[    script:qbx_radio] channnel : 8
[    script:qbx_radio] channnel : 9
[    script:qbx_radio] channnel : 10
[    script:qbx_radio] channnel : 7.99
[    script:qbx_radio] channnel : 4.01
[    script:qbx_radio] channnel : 8.02
[    script:qbx_radio] channnel : 5.37
[    script:qbx_radio] channnel : 10.74
[    script:qbx_radio] channnel : 8.27
[    script:qbx_radio] channnel : 6.73
[    script:qbx_radio] channnel : 10.99
[    script:qbx_radio] channnel : 2.13
[    script:qbx_radio] channnel : 4.26
[    script:qbx_radio] channnel : 8.52
[    script:qbx_radio] channnel : 2.81
[    script:qbx_radio] channnel : 5.62
[    script:qbx_radio] channnel : 11.24
[    script:qbx_radio] channnel : 3.49
[    script:qbx_radio] channnel : 6.98
[    script:qbx_radio] channnel : 11.49
[    script:qbx_radio] channnel : 4.51
[    script:qbx_radio] channnel : 9.02
[    script:qbx_radio] channnel : 5.87
[    script:qbx_radio] channnel : 11.74
[    script:qbx_radio] channnel : 9.27
[    script:qbx_radio] channnel : 7.23
[    script:qbx_radio] channnel : 1.19
[    script:qbx_radio] channnel : 2.38
[    script:qbx_radio] channnel : 4.76
[    script:qbx_radio] channnel : 9.52
[    script:qbx_radio] channnel : 1.53
[    script:qbx_radio] channnel : 3.06
[    script:qbx_radio] channnel : 6.12
[    script:qbx_radio] channnel : 12.24
[    script:qbx_radio] channnel : 1.87
[    script:qbx_radio] channnel : 9.77
[    script:qbx_radio] channnel : 7.48
[    script:qbx_radio] channnel : 2.82
[    script:qbx_radio] channnel : 2.8
[    script:qbx_radio] channnel : 2.76
[    script:qbx_radio] channnel : 12.49
[    script:qbx_radio] channnel : 2.72
[    script:qbx_radio] channnel : 5.01
[    script:qbx_radio] channnel : 10.02
[    script:qbx_radio] channnel : 2.65
[    script:qbx_radio] channnel : 2.61
[    script:qbx_radio] channnel : 2.57
[    script:qbx_radio] channnel : 6.37
[    script:qbx_radio] channnel : 12.74
[    script:qbx_radio] channnel : 2.55
[    script:qbx_radio] channnel : 2.51
[    script:qbx_radio] channnel : 10.27
[    script:qbx_radio] channnel : 7.73
[    script:qbx_radio] channnel : 2.47
[    script:qbx_radio] channnel : 2.4
[    script:qbx_radio] channnel : 2.36
[    script:qbx_radio] channnel : 12.99
[    script:qbx_radio] channnel : 2.63
[    script:qbx_radio] channnel : 5.26
[    script:qbx_radio] channnel : 10.52
[    script:qbx_radio] channnel : 2.3
[    script:qbx_radio] channnel : 2.26
[    script:qbx_radio] channnel : 3.31
[    script:qbx_radio] channnel : 6.62
[    script:qbx_radio] channnel : 13.24
[    script:qbx_radio] channnel : 2.11
[    script:qbx_radio] channnel : 2.09
[    script:qbx_radio] channnel : 10.77
[    script:qbx_radio] channnel : 7.98
[    script:qbx_radio] channnel : 4.15
[    script:qbx_radio] channnel : 8.3
[    script:qbx_radio] channnel : 2.05
[    script:qbx_radio] channnel : 13.49
[    script:qbx_radio] channnel : 1.99
[    script:qbx_radio] channnel : 5.51
[    script:qbx_radio] channnel : 11.02
[    script:qbx_radio] channnel : 1.98
[    script:qbx_radio] channnel : 1.97
[    script:qbx_radio] channnel : 8.55
[    script:qbx_radio] channnel : 6.87
[    script:qbx_radio] channnel : 13.74
[    script:qbx_radio] channnel : 1.95
[    script:qbx_radio] channnel : 1.94
[    script:qbx_radio] channnel : 1.1
[    script:qbx_radio] channnel : 2.2
[    script:qbx_radio] channnel : 4.4
[    script:qbx_radio] channnel : 8.8
[    script:qbx_radio] channnel : 1.92
[    script:qbx_radio] channnel : 1.44
[    script:qbx_radio] channnel : 2.88
[    script:qbx_radio] channnel : 5.76
[    script:qbx_radio] channnel : 11.52
[    script:qbx_radio] channnel : 1.9
[    script:qbx_radio] channnel : 1.78
[    script:qbx_radio] channnel : 9.05
[    script:qbx_radio] channnel : 4.65
[    script:qbx_radio] channnel : 9.3
[    script:qbx_radio] channnel : 11.31
[    script:qbx_radio] channnel : 2.45
[    script:qbx_radio] channnel : 4.9
[    script:qbx_radio] channnel : 9.8
[    script:qbx_radio] channnel : 3.03
[    script:qbx_radio] channnel : 10.05
[    script:qbx_radio] channnel : 5.15
[    script:qbx_radio] channnel : 10.3
[    script:qbx_radio] channnel : 1.35
[    script:qbx_radio] channnel : 10.55
[    script:qbx_radio] channnel : 5.4
[    script:qbx_radio] channnel : 10.8
[    script:qbx_radio] channnel : 3.07
[    script:qbx_radio] channnel : 11.05
[    script:qbx_radio] channnel : 5.65
[    script:qbx_radio] channnel : 11.3
[    script:qbx_radio] channnel : 9.45
[    script:qbx_radio] channnel : 11.55
[    script:qbx_radio] channnel : 5.9
[    script:qbx_radio] channnel : 11.8
[    script:qbx_radio] channnel : 3.32
[    script:qbx_radio] channnel : 12.05
[    script:qbx_radio] channnel : 6.15
[    script:qbx_radio] channnel : 12.3
[    script:qbx_radio] channnel : 1.6
[    script:qbx_radio] channnel : 3.2
[    script:qbx_radio] channnel : 6.4
[    script:qbx_radio] channnel : 12.8
[    script:qbx_radio] channnel : 5.78
[    script:qbx_radio] channnel : 13.05
[    script:qbx_radio] channnel : 6.65
[    script:qbx_radio] channnel : 13.3
[    script:qbx_radio] channnel : 13.78
[    script:qbx_radio] channnel : 3.45
[    script:qbx_radio] channnel : 6.9
[    script:qbx_radio] channnel : 13.8