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