Skip to content

Commit dec325a

Browse files
committed
fix: discord missing breaks chat tags.
Originally, if no Discord identifier was found, the chat tag system would return which caused unexpected issues. Now, when the resource goes to sync tags, it'll go through two checks, one for roles available to everyone, and any special roles.
1 parent 809c375 commit dec325a

2 files changed

Lines changed: 32 additions & 11 deletions

File tree

sv_chat_tags.lua

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,36 @@ local playerStaffChatStatus = {}
1919
local function syncTags(source)
2020
local identifiers = GetIdentifiersTable(source)
2121

22-
if not identifiers.discord then return end
23-
24-
local roles = getRoles(source)
2522
local rolesAllowed = {}
2623
local highestRole, highestRoleIndex = nil, nil
2724

28-
for i = 1, #RoleList do
25+
for i = 1, #RoleList do
2926
if tostring(RoleList[i][1]) == "0" then
3027
insert(rolesAllowed, i)
3128
highestRoleIndex = i
3229
end
33-
34-
if roles == nil then goto skip end
35-
30+
end
31+
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
3642
for _, v in pairs(roles) do
3743
if tostring(RoleList[i][1]) == tostring(v) then
3844
insert(rolesAllowed, i)
3945
highestRole, highestRoleIndex = v, i
4046
end
4147
end
42-
43-
::skip::
4448
end
4549

50+
::skip::
51+
4652
cachedPlayerRoles[source] = rolesAllowed
4753
playerSelectedRole[source] = RoleList[highestRoleIndex][2]
4854
end
@@ -138,4 +144,19 @@ end, false)
138144

139145
RegisterCommand("sc", function(source)
140146
StaffChat(source)
141-
end, false)
147+
end, false)
148+
149+
Citizen.CreateThread(function()
150+
local defaultRoleFound = false
151+
152+
for i = 1, #RoleList do
153+
if tostring(RoleList[i][1]) == "0" then
154+
defaultRoleFound = true
155+
break
156+
end
157+
end
158+
159+
if not defaultRoleFound then
160+
Log("There was no default role found, please ensure you add a default role in the configuration. Ensure that the role ID is set to 0. The resource may not function as expected.")
161+
end
162+
end)

sv_config.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Config = {
33
GuildID = "", -- Server ID (The server that the roles are based off of.)
44

55
ChatRolesEnabled = true, -- If you'd like chat tags, staff chat, enabled or not.
6-
RoleList = { -- Role ID of 0, will grant the role to everyone.
6+
RoleList = { -- Role ID of 0, will grant the role to everyone. (Ensure that you have a default role)
77
{0, "👦🏻 ^4Civilian | "}, -- All.
88
{793043765224931388, "👨🏼‍🎓 ^3Member | "}, -- Member
99
{793043749164417054, "👨🏼‍🎓 ^2Civilian | "}, -- Certified Civilian

0 commit comments

Comments
 (0)