· 6 years ago · May 24, 2019, 04:52 PM
1--[[
2
3Name: Apocalypse Rising Group Chat Monitor / Log
4This script is made for Apocalypse Rising
5Creator: Octal
6
7-- Credit to LordRevorious for the CreateInstance function.
8
9You are allowed to use this for whatever you want,
10But please give me credit if you do.
11
12Disclaimer: probs the worst looking script ever.
13Creation Date: 2017/07/14
14
15--]]
16
17
18local OldEnvironment = getfenv();
19local Players = game:GetService("Players");
20
21local Groups = {};
22local GroupStuff = {};
23_G.Messages = (_G.Messages and _G.Messages) or {};
24
25local config = {
26 InfoColour = Color3.new(0, 1, 1); -- Cyan. Sortof.
27 OutputColour = Color3.new(1, 1, 1); -- White.
28 GroupCount = 0;
29 groupsObject = game:GetService("Lighting").Groups;
30
31};
32_G.config = (_G['config'] and _G['config']) or config;
33for i,v in pairs(_G.config) do
34 pcall(function()
35 v:disconnect()
36 end)
37end
38
39--------------------------------------------------------------------------------
40
41local mainScrollingFrame;
42
43local function groupCount()
44 local num = 0;
45 for i,v in pairs(Groups) do
46 if type(tonumber(i)) == "number" then
47 num = num + 1;
48 end
49 end
50 config.GroupCount = num;
51 return num;
52end
53
54local function UpdatePositions(GroupScrollingFrame)
55 local YSize = 20
56 for i,v in pairs(config.GroupScrollFrame:GetChildren()) do
57 local Position = ((i * YSize) - YSize)
58 v.Position = UDim2.new(0, 5, 0, Position + 5)
59 end
60 Position = ((groupCount() * YSize) - YSize)
61 config.GroupScrollingFrame.CanvasSize = UDim2.new(0, 0, 0, Position + 20)
62end
63
64function Console(Player, Environment)
65 if not Player:FindFirstChild("PlayerGui") or not Player:FindFirstChild("PlayerGui").ClassName == "PlayerGui" then
66 return
67 end
68
69 local Minimized = false
70 local SavedSizes = {X = 375, Y = 190}
71 pcall(function()
72 Player.PlayerGui:FindFirstChild("Apoc Group Chat Log"):Destroy()
73 end)
74
75 local ScreenGui = CreateInstance("ScreenGui", {Name = "Apoc Group Chat Log", ResetOnSpawn = false, Parent = game.CoreGui})
76 local MainGui = CreateInstance("TextButton", { Draggable = true, BorderSizePixel = 0, BackgroundColor3 = Color3.new(0.19607843137255, 0.19607843137255, 0.19607843137255), Size = UDim2.new(0, 375, 0, 20), BackgroundTransparency = 0.2, Text = " Apoc Group Chat Log", Font = "SourceSansBold", FontSize = "Size18", Modal = false, AutoButtonColor = false, TextColor3 = Color3.new(1, 1, 1), TextXAlignment = "Left", TextYAlignment = "Top", Parent = ScreenGui })
77 local MainFrame = CreateInstance("Frame", { Size = UDim2.new(1, 0, 0, 190), BackgroundColor3 = Color3.new(0.19607843137255, 0.19607843137255, 0.19607843137255), Position = UDim2.new(0, 0, 1, 0), BorderSizePixel = 0, BackgroundTransparency = 0.5, Parent = MainGui})
78 local MainScrollingFrame = CreateInstance("ScrollingFrame", {BackgroundTransparency = 1,BorderSizePixel = 0,Size = UDim2.new(1, 0, 1, 0) --[[-20)--]],BottomImage = "rbxassetid://3064174",MidImage = "rbxassetid://3064174",TopImage = "rbxassetid://3064174",CanvasSize = UDim2.new(0, 0, 0, 0),ScrollBarThickness = 10,Parent = MainFrame})
79 local Min_Max = CreateInstance("TextButton", { Font = "SourceSansBold", Text = "-", FontSize = "Size18", BackgroundTransparency = 1, TextYAlignment = "Top", TextColor3 = Color3.new(1, 1, 1), Size = UDim2.new(0, 20, 1, 0), Position = UDim2.new(1, -20, 0, 0), Parent = MainGui })
80
81 local GroupScrollingFrame = CreateInstance("ScrollingFrame", {BackgroundTransparency = 1,BorderSizePixel = 0,Size = UDim2.new(0.21, 0, 4, 0) --[[-20)--]],BottomImage = "rbxassetid://3064174",MidImage = "rbxassetid://3064174",TopImage = "rbxassetid://3064174",CanvasSize = UDim2.new(.2, 0, 4, 0), Position = UDim2.new(1, -80, 0, 20),ScrollBarThickness = 5, Visible = false, Parent = MainGui})
82 config.GroupScrollFrame = GroupScrollingFrame;
83 config.GroupScrollingFrame = GroupScrollingFrame;
84 local GroupSelect = CreateInstance("TextButton", {Font = "SourceSansBold", Text = "Groups", FontSize = "Size14", TextYAlignment = "Top", BackgroundTransparency = 1, TextStrokeTransparency = 0.9, TextColor3 = Color3.new(1, 1, 1), Size = UDim2.new(0, 60, 1, 0), Position = UDim2.new(1, -80, 0, 0), Parent = MainGui})
85
86 config.GroupSelectionConnection = GroupSelect.MouseButton1Click:connect(function()
87 GroupScrollingFrame.Visible = not GroupScrollingFrame.Visible;
88 end)
89
90 config.MainFrame = MainFrame;
91 config.MainScrollingFrame = MainScrollingFrame;
92 mainScrollingFrame = MainScrollingFrame;
93
94 local function createGroupStuff(GroupID, GroupsTable, PositionData)
95 local found;
96 for i,v in pairs(config.GroupScrollFrame:GetChildren()) do
97 if v.Text == GroupID then
98 found = true;
99 break;
100 end
101 end
102
103 if (not found or not Groups[GroupID].RemoveGroupStuff) then
104 local count = groupCount()
105 local YSize = 20
106 local Position = ((count * YSize) - YSize)--((i * YSize) - YSize)
107
108 local GroupFrame = CreateInstance("ScrollingFrame", {BackgroundTransparency = 1,BorderSizePixel = 0,Size = UDim2.new(1, 0, 1, 0),BottomImage = "rbxassetid://3064174",MidImage = "rbxassetid://3064174",TopImage = "rbxassetid://3064174",CanvasSize = UDim2.new(0, 0, 0, 0),ScrollBarThickness = 10, Visible = false,Parent = MainFrame}); --, Visible = false})
109 local GroupButton = CreateInstance("TextButton", { Font = "SourceSansBold", Text = GroupID, FontSize = "Size12", BackgroundTransparency = .95, TextYAlignment = "Top",TextStrokeTransparency = 0.9, TextColor3 = Color3.new(1, 1, 1), Size = UDim2.new(0, 60, 0, 15), Position = UDim2.new(0, 5, 0, Position + 5) --[[20)]], Visible = true, Parent = GroupScrollingFrame})
110 GroupScrollingFrame.CanvasSize = UDim2.new(0, 0, 0, Position + 20)
111
112 local GrouPCon = GroupButton.MouseButton1Click:connect(function()
113 local MemberCount = Groups[GroupID].MemberCount;
114 local MessageCount = #Groups[GroupID].Messages;
115
116 for i,v in pairs(MainFrame:GetChildren()) do
117 if v ~= GroupFrame and v.ClassName ~= "TextButton" then
118 v.Visible = false;
119 else
120 v.Visible = true;
121 end
122 end
123 GroupFrame:ClearAllChildren(); -- Clear Messages.
124
125 Output(GroupFrame, "[INFO] Member Count: "..MemberCount, config.InfoColour);
126 local Members = Groups[GroupID].Members
127 -- tried 2 sort the table, but meh. I don't care too much and doubt anyone else will.
128 for i,v in pairs(Members) do
129 local str = v:sub(1,1):upper();
130 local number = v:sub(#v, #v);
131 str = str .. v:sub(2, (#v-1)):lower();
132 Output(GroupFrame, "[INFO] "..( str .. " #" .. number )..": "..i, config.InfoColour);
133 end
134 Output(GroupFrame, "[INFO] Message Count: "..MessageCount, config.InfoColour);
135
136 for i,v in pairs(Groups[GroupID].Messages) do
137 Output(GroupFrame, v, config.OutputColour) -- White
138 end
139 end)
140
141 function removeGroupStuff(self)
142 pcall(function() GrouPCon:disconnect() end)
143 GroupFrame:Destroy();
144 GroupButton:Destroy();
145
146 Groups[GroupID] = nil;
147 UpdatePositions();
148 end
149
150 Groups[GroupID].RemoveGroupStuff = removeGroupStuff;
151 GroupsTable[GroupID].RemoveGroupStuff = removeGroupStuff
152
153 return {
154 ScrollingFrame = GroupFrame;
155 Button = GroupButton;
156 removeGroupStuff = removeGroupStuff;
157 };
158 else
159 return "NOT FOUND"
160 end
161 end
162
163
164 local function GetNewTime(OldTime)
165 local Hours = math.floor(OldTime / 3600 % 24)
166 local Minutes = math.floor(OldTime / 60 % 60)
167 local Seconds = math.floor(OldTime% 60)
168 local Ending = ""
169 if Hours >= 12 then
170 Hours = Hours - 12
171 Ending = " PM ";
172 elseif Hours == 0 then
173 Hours = 12
174 Ending = " AM "
175 end
176 return ("%02i:%02i"):format(Hours, Minutes) .. Ending --("%02i:%02i:%02i"):format(Hours, Minutes, Seconds) .. Ending
177 end
178
179 function Output(ScrollingFramex, Message, TextColor)
180 Message = GetNewTime(tick()) .. " - " .. Message
181 ScrollingFramex = ScrollingFramex
182 local TextLabel = CreateInstance("TextLabel", { Text = " " .. Message, Name = "Line", Font = "SourceSansBold", FontSize = "Size14", BackgroundTransparency = 1, TextXAlignment = "Left", TextYAlignment = "Top", TextColor3 = TextColor, Size = UDim2.new(1, 0, 20), Position = UDim2.new(0, 0, 0, #ScrollingFramex:GetChildren() * 20), ZIndex = 2, TextStrokeTransparency = 0.9, Parent = ScrollingFramex })
183
184 if #ScrollingFramex:GetChildren() > (ScrollingFramex.AbsoluteSize.Y / 20) then
185 ScrollingFramex.CanvasSize = UDim2.new(3, 0, 0, (#ScrollingFramex:GetChildren() * 20))
186 ScrollingFramex.CanvasPosition = Vector2.new(0, (ScrollingFramex.CanvasSize.Y.Offset - ScrollingFramex.AbsoluteSize.Y) + 10)
187 end
188 end
189
190 Min_Max.MouseButton1Click:connect(function()
191 if Minimized == false then
192 Minimized = true
193 Min_Max.Text = "+"
194 MainFrame:TweenSize(UDim2.new(0, SavedSizes.X, 0, 0), "Out", "Quad", 1.5, true)
195 delay(1.32, function()
196 MainFrame.Visible = false
197 end)
198 else
199 Minimized = false
200 Min_Max.Text = "-"
201 MainFrame:TweenSize(UDim2.new(0, SavedSizes.X, 0, SavedSizes.Y), "Out", "Quad", 1.5, true)
202 delay(0.1, function()
203 MainFrame.Visible = true
204 end)
205 end
206 end)
207
208 MainGui.Position = UDim2.new(0.5, -MainFrame.AbsoluteSize.X / 2, -1, 0)
209 ScreenGui.Parent = Player.PlayerGui
210 MainGui:TweenPosition(UDim2.new(0.5, -MainFrame.AbsoluteSize.X / 2, 0.5, -MainFrame.AbsoluteSize.Y / 2), "InOut", "Quad", 1, true)
211
212 return {Output, createGroupStuff};
213
214end
215
216function CreateInstance(ClassName, Properties) -- Very useful custom create function by LordRevorius.
217 local Instance = Instance.new(ClassName)
218 local Properties = Properties or {}
219 local ConnectionIndexes = {"MouseClick","MouseHoverEnter","MouseHoverLeave","MouseButton1Down","MouseButton2Down"}
220 local CheckConnection = function(Index)
221 local Index = tostring(Index)
222 for _, Connect in pairs(ConnectionIndexes) do
223 if Index:lower() == Connect:lower() then
224 return true
225 end
226 end
227 return false
228 end
229 for Index, Value in pairs(Properties) do
230 if not CheckConnection(Index) then
231 Instance[Index] = Value
232 else
233 Instance[Index]:connect(Value)
234 end
235 end
236 return Instance
237end
238
239
240--------------------------------------------
241
242
243local CoreConsoleCall = Console(Players.LocalPlayer, getfenv());
244local Output = CoreConsoleCall[1];
245local createGroupStuff = CoreConsoleCall[2];
246
247Output(mainScrollingFrame, "Apoc Group Chat Log Started!", Color3.new(0, 1, 1));
248Output(mainScrollingFrame, "Made by Octal.", Color3.new(0, 1, 1));
249Output(mainScrollingFrame, "Have fun!", Color3.new(0, 1, 1));
250
251
252-----------------------------------------------------------------------------------------------
253-----------------------------------------------------------------------------------------------
254-----------------------------------------------------------------------------------------------
255
256
257function getGroups()
258 for groupindex, group in pairs(config.groupsObject:GetChildren()) do
259 if group.ClassName == "IntValue" then
260 local groupId = tostring(group.Name);
261 if (not Groups[groupId]) then --or (Groups[groupId] and Groups[groupId].MemberCount<=1) then -- Group does not exist
262 Groups[groupId] = {
263 GroupID = groupId;
264 Index = group;
265 Members = {};
266 Messages = (_G.Messages[groupId] and _G.Messages[groupId]) or {};
267 removeGroupStuff = nil;
268 };
269 GroupStuff[groupId] = {};
270 _G.Messages[groupId] = (_G.Messages[groupId] and _G.Messages[groupId]) or {};
271 for memberindex,member in pairs(group:GetChildren()) do
272 if member.Value ~= "NoPlayer" then
273 Groups[groupId].Members[member.Value] = member.Name;--{member.Name, true};
274 end
275
276 end
277 local k = Groups[groupId].Members
278 local num = 0;
279 for _,r in pairs(k) do --set current member count.
280 num = num + 1;
281 end
282 Groups[groupId].MemberCount = num;
283
284 local removeGroupStuf;
285 if (Groups[groupId].MemberCount >= 1) then
286 local stuff = createGroupStuff(groupId, Groups);
287 --print("Before", Groups[groupId].RemoveGroupStuff)
288 Groups[groupId].ScrollingFrame = stuff.ScrollingFrame;
289 --Groups[groupId].RemoveGroupStuff = stuff.removeGroupStuff
290 --GroupStuff[groupId].RemoveGroupStuff = stuff.removeGroupStuff
291 --print("After", Groups[groupId].RemoveGroupStuff)
292 elseif Groups[groupId].MemberCount == 0 then
293 ---Do Nothing if they don't have any ppl.
294
295 else
296 Groups[groupId] = nil;
297 print'how r u evn'
298 end
299 else -- Group already exists
300 for memberindex,member in pairs(group:GetChildren()) do
301 if member.Value ~= "NoPlayer" then
302 if not Groups[groupId].Members[member.Value] then -- check if member already exists
303 print("adding",member.Value,"to",groupId)
304 Groups[groupId].Members[member.Value] = member.Name;--{member.Name, true}; --VALUE is their actual roblox name
305 end
306 end
307
308 end
309
310 local k = Groups[groupId].Members
311 local num = 0;
312 for _,r in pairs(k) do --set current member count.
313 num = num + 1;
314 end
315 Groups[groupId].MemberCount = num;
316
317 if Groups[groupId].MemberCount >= 1 then
318
319 elseif Groups[groupId].MemberCount == 0 then
320 --Do nothing lol.
321 else
322 Groups[groupId] = nil;
323 print'how r u evn'
324 end
325 end
326
327 --Groups with no members SHOULD be taken care of right here.
328 if (Groups[groupId] and Groups[groupId].MemberCount==0) then
329 for i,v in pairs(config.MainFrame:GetChildren()) do
330 if v.Name == groupId then
331 v:Destroy()
332 end
333 end
334 for i,v in pairs(config.GroupScrollFrame:GetChildren()) do
335 if v.Text == groupId then
336 v:Destroy()
337 end
338 end
339 Groups[groupId] = nil;
340 UpdatePositions();
341 end
342
343 end
344 end
345end
346getGroups()
347
348local function groupPair(Player)
349 local groupTable;
350 for i,group in pairs(Groups) do
351 if type(tonumber(i)) == "number" then
352 local k = group.Members
353 for memberIndex,playerObject in pairs(k) do
354 local pOBJ = game:GetService("Players"):FindFirstChild(memberIndex)
355 if Player == pOBJ then
356 groupTable = group;
357 break;
358 end
359 end
360 end
361 end
362 return groupTable;
363end
364
365config.RemoteChatConnection = workspace.Remote.Chat.OnClientEvent:connect(function(...)
366 local XT = Output;
367 local Data = (...);
368 local Message = Data.Message;
369 local ChannelType = Data.Channel;
370 local TimeStamp = Data.TimeStamp;
371 local Speaker = Data.Speaker;
372
373 if ChannelType == "Group" then
374 local owningGroup = groupPair(Speaker); --> returns table of the group
375 if owningGroup ~= nil then
376 local MSG = "["..Speaker.Name.."] "..Message;
377 owningGroup.Messages[#owningGroup.Messages + 1] = MSG;
378 _G.Messages[owningGroup.GroupID][#_G.Messages[owningGroup.GroupID]+1] = MSG;
379
380 Output(owningGroup.ScrollingFrame, MSG, config.OutputColour)
381 end
382 end
383end)
384
385config.ItemConnection = game.ItemChanged:connect(function(obj)
386 if obj:IsDescendantOf(config.groupsObject) then
387 if obj.ClassName == "IntValue" or obj.ClassName == "StringValue" then
388 getGroups() -- spawn(getGroups)
389 end
390 end
391end)