-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLegacyChatTagAPI
More file actions
106 lines (85 loc) · 2.83 KB
/
LegacyChatTagAPI
File metadata and controls
106 lines (85 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
local ServerScriptService = game:GetService("ServerScriptService")
local config = require(ServerScriptService:WaitForChild("SR_Loader"):WaitForChild("Config"))
local CustomRanks = config["Custom Ranks"]
local Group = config["Group"]
local GroupEnabled = Group["GroupEnabled"]
local GroupID = Group["GroupId"]
local GroupRanks = Group["Ranks"]
local Trello = config["Trello Stuff"]
local TrelloEnabled = Trello["TrelloEnabled"]
local TrelloRanks = Trello["Ranks"]
local TrelloBoardName = Trello["TrelloBoardName"]
local TrelloAPI = require(script.Parent.TrelloAPI)
local chattagapi = {}
function chattagapi.SetTag(speakerName)
if game:GetService("TextChatService").ChatVersion == Enum.ChatVersion.LegacyChatService then
local ChatService = require(ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local speaker = ChatService:GetSpeaker(speakerName)
local player = speaker:GetPlayer()
local plr = game.Players[speakerName]
local rank = script.Parent.Parent.PlayerRanks[player.Name]
if player and plr then
if rank.Value>0 then
local tagData
local assigned = false
if TrelloEnabled and assigned == false then
local board = TrelloAPI:GetBoardID(TrelloBoardName)
for _,v in pairs(TrelloRanks) do
if v["RankListName"] ~= "" then
local list = TrelloAPI:GetLists(v["RankListName"],board)
local cards = TrelloAPI:GetCardsInList(list)
local assigned = false
for _, i in pairs(cards) do
if string.find(i.name,plr.UserId) or string.find(i.name,plr.Name) then
if TrelloRanks[i]["TagEnabled"] == true then
tagData = TrelloRanks[i]["StaffTag"]
end
assigned = true
break
end
end
if assigned then
break
end
end
end
end
if GroupEnabled and assigned == false then
for _,v in pairs(GroupRanks) do
if v["RankId"] == plr:GetRankInGroup(GroupID) then
if v["TagEnabled"] == true then
tagData = v["StaffTag"]
end
assigned = true
break
end
end
end
if assigned == false then
if plr.UserId == game.CreatorId then
tagData = CustomRanks["Owner"]["StaffTag"]
assigned = true
else
for _,v in pairs(CustomRanks) do
if (table.find(v["Users"],plr.UserId) or table.find(v["Users"],tostring(plr.UserId)) or table.find(v["Users"],plr.Name)) ~= (nil and -1) then
if v["TagEnabled"] == true then
tagData = v["StaffTag"]
end
assigned = true
break
end
end
end
end
if tagData ~= nil then
speaker:SetExtraData("Tags",{tagData})
speaker:SetExtraData("ChatColor",tagData["TagColor"])
end
else
speaker:SetExtraData("Tags")
speaker:SetExtraData("ChatColor")
end
end
end
end
return chattagapi