Skip to content

Commit f11acef

Browse files
committed
refactor: clean up the bug fix code, didn't want multiple loops.
1 parent 4143ebb commit f11acef

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

sv_chat_tags.lua

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,28 @@ local function syncTags(source)
2121

2222
local rolesAllowed = {}
2323
local highestRole, highestRoleIndex = nil, nil
24+
local roles = nil
25+
26+
if indetifiers.discord then
27+
roles = getRoles(source)
28+
end
2429

2530
for i = 1, #RoleList do
2631
if tostring(RoleList[i][1]) == "0" then
2732
insert(rolesAllowed, i)
2833
highestRoleIndex = i
2934
end
30-
end
3135

32-
if not identifiers.discord then -- If the player doesn't have a discord identifier, we'll just assign the default role, if it exists.
33-
cachedPlayerRoles[source] = rolesAllowed
34-
playerSelectedRole[source] = RoleList[highestRoleIndex][2]
35-
return
36-
end
37-
38-
local roles = getRoles(source)
39-
if roles == nil then goto skip end
40-
41-
for i = 1, #RoleList do
36+
if roles == nil then goto skip end
4237
for _, v in pairs(roles) do
4338
if tostring(RoleList[i][1]) == tostring(v) then
4439
insert(rolesAllowed, i)
4540
highestRole, highestRoleIndex = v, i
4641
end
4742
end
43+
::skip::
4844
end
4945

50-
::skip::
51-
5246
cachedPlayerRoles[source] = rolesAllowed
5347
playerSelectedRole[source] = RoleList[highestRoleIndex][2]
5448
end

0 commit comments

Comments
 (0)