SHOW:
|
|
- or go back to the newest paste.
1 | --SafeGuard Version 1.1.0 rewrite 3 Development Build 4 | |
2 | local licenseKey = "105s106c106o107t107t103k106i105d" | |
3 | local g = game | |
4 | - | local plyrs = g:service("Players") |
4 | + | local plyrs = g:service("kaemi") |
5 | local ws = g:service("Workspace") | |
6 | local lg = g:service("Lighting") | |
7 | local sgu = g:service("StarterGui") | |
8 | local sp = g:service("StarterPack") | |
9 | local d = g:service("Debris") | |
10 | local ss = g:service("SoundService") | |
11 | local sc = g:service("ScriptContext") | |
12 | ||
13 | if not script then | |
14 | local h = Instance.new("Message",Workspace) | |
15 | h.Text = "SafeGuard 1.1.0 rw3 FATAL ERROR | script is undefined!" | |
16 | wait(4) | |
17 | h:destroy() | |
18 | end | |
19 | ||
20 | local s = script | |
21 | local sbk = script | |
22 | ||
23 | if shared.SG_GENV == nil then | |
24 | shared.SG_GENV = {} | |
25 | shared.SG_GENV.math = math | |
26 | shared.SG_GENV.string = string | |
27 | shared.SG_GENV.table = table | |
28 | shared.SG_GENV.game = game | |
29 | end | |
30 | ||
31 | math = shared.SG_GENV.math | |
32 | string = shared.SG_GENV.string | |
33 | table = shared.SG_GENV.table | |
34 | ||
35 | if not script.Parent == nil then wait(.5) script:destroy() end | |
36 | wait(1) | |
37 | ||
38 | sg = {} | |
39 | sg.Functions = {} | |
40 | sg.Settings = {} | |
41 | sg.Data = {} | |
42 | sg.EmergeControl = {} | |
43 | sg.Services = {} | |
44 | sg.Commands = {} | |
45 | sg.Modules = {} | |
46 | sg.Players = {} | |
47 | sg.Sounds = { | |
48 | ["Beep"] = "http://www.roblox.com/asset/?id=15666462", | |
49 | ["Five"] = "http://www.roblox.com/asset/?id=29445395", | |
50 | ["Four"] = "http://www.roblox.com/asset/?id=29445378", | |
51 | ["Three"] = "http://www.roblox.com/asset/?id=29445358", | |
52 | ["Two"] = "http://www.roblox.com/asset/?id=29445339", | |
53 | ["One"] = "http://www.roblox.com/asset/?id=29445305"} | |
54 | sg.Init = {} | |
55 | ||
56 | sg.Settings.ProtectedUnit = "scottkid" | |
57 | sg.Settings.Service = "disabled" | |
58 | sg.Settings.EmergeControl = "disabled" | |
59 | sg.Settings.sysActivated = "check" | |
60 | sg.Settings.sysCreators = {} | |
61 | sg.Settings.MaxNumOfNotifications = 8 | |
62 | sg.Settings.NotificationsEnabled = true | |
63 | sg.Settings.BreakLoop = false | |
64 | ||
65 | sg.Data.curVer = "1.1.0 rw3" | |
66 | sg.Data.NotAllowed = {"ikiled"} | |
67 | sg.Data.UpdateModels = {} | |
68 | sg.Data.LoadedScript = {} | |
69 | sg.Data.Services = {"BadgeService","CoreGui","StarterGui","ChangeHistoryService","Chat","CollectionService","ContentFilter","ContentProvider","ControllerService","Debris","FlagStandService","FriendService","Geometry","GuiService","GuidRegistryService","InsertService","Lighting","LocalBackpack","MeshContentProvider","NetworkClient","NetworkServer","Workspace","PhysicsService","RunService","ScriptContext","ScriptInformationProvider","Selection","SocialService","SoundService","SpawnerService","Stats","StarterPack","Teams","TeleportService","TextService","Timer","VirtualUser","Visit","RenderHooksService"} | |
70 | sg.Data.UpdateModuleAsset = nil | |
71 | sg.Data.AccessDenied = "Access Denied to "..sg.Data.curVer.." instance! | Code used - " | |
72 | sg.Data.AccessCode = "access1234" | |
73 | sg.Data.LastUpdatedNum = 1369011221 | |
74 | sg.Data.LastUpdatedInfo = { | |
75 | ["Minutes"] = math.floor(sg.Data.LastUpdatedNum/(60)), | |
76 | ["Hours"] = math.floor(sg.Data.LastUpdatedNum/(60*60)), | |
77 | ["Days"] = math.floor(sg.Data.LastUpdatedNum/(60*60*24)) | |
78 | } | |
79 | sg.Data.PermissionLevels = { | |
80 | ["System"] = 5, | |
81 | ["Administrator"] = 4, | |
82 | ["Moderator"] = 3, | |
83 | ["Trusted User"] = 2, | |
84 | ["User"] = 1, | |
85 | ["Unprivildged User"] = 0, | |
86 | ["Banned"] = -1 | |
87 | } | |
88 | ||
89 | sg.Preregistered = { | |
90 | ["tusKOr661"] = "Administrator", | |
91 | ["4byte"] = "Administrator" | |
92 | } | |
93 | ||
94 | ||
95 | ||
96 | setmetatable(sg,{__call = function() return script end}) | |
97 | sg.Functions.AddNewScript = function(ins) | |
98 | if ins == script then return end | |
99 | if ins:isA"Script" or ins:isA"LocalScript" then | |
100 | if not ins:findFirstChild("DSource") then return end | |
101 | sg.Data.LoadedScript[ins.Name] = ins | |
102 | sg.Functions.gNotification("New Script "..ins:GetFullName().." was added to the database!") | |
103 | end | |
104 | end | |
105 | ||
106 | game.DescendantAdded:connect(sg.Functions.AddNewScript) | |
107 | ||
108 | sg.Functions.AntiChange = function(p) | |
109 | if p == "Parent" then | |
110 | script:destroy() | |
111 | script.Changed:connect(sg.Functions.AntiChange) | |
112 | pcall(function() sg.Functions.ReconnectConnections() end) | |
113 | elseif p == "Disabled" then | |
114 | script.Disabled = false | |
115 | else | |
116 | script.Archivable = false | |
117 | script.Name = "SafeGuard "..sg.Data.curVer | |
118 | end | |
119 | end | |
120 | ||
121 | sg.Functions.AntiRemove = function(i) | |
122 | if i == script then | |
123 | script:destroy() | |
124 | script.Changed:connect(sg.Functions.AntiRemove) | |
125 | pcall(function() sg.Functions.ReconnectConnections() end) | |
126 | end | |
127 | end | |
128 | ||
129 | sg.Functions.ReconnectConnections = function() | |
130 | for i,v in pairs(plyrs:GetPlayers()) do | |
131 | coroutine.wrap(function() | |
132 | pcall(function() | |
133 | while v.PlayerGui["SafeGuard_GUI"]["Msg"] do | |
134 | v.PlayerGui["SafeGuard_GUI"]["Msg"]:destroy() | |
135 | end | |
136 | end) | |
137 | end)() | |
138 | coroutine.wrap(function() | |
139 | pcall(function() | |
140 | v.Chatted:connect(function(chat,ins) sg.Functions.OnChatted(chat,v) end) | |
141 | end) | |
142 | end)() | |
143 | coroutine.wrap(function() | |
144 | pcall(function() v.PlayerGui["SafeGuard_GUI"]:destroy() end) | |
145 | local a = Instance.new("ScreenGui",v.PlayerGui) | |
146 | a.Name = "SafeGuard_GUI" | |
147 | end)() | |
148 | wait() | |
149 | sg.Functions.Notification(v,"Your connections were reconnected!") | |
150 | end | |
151 | plyrs.PlayerAdded:connect(function(p) sg.Functions.RegisterPlayer(p,1) end) | |
152 | end | |
153 | ||
154 | script.Changed:connect(sg.Functions.AntiChange) | |
155 | script.Parent.DescendantRemoving:connect(sg.Functions.AntiRemove) | |
156 | ||
157 | sg.Functions.PlaySound = function(soundName) | |
158 | if not sg.Sounds[soundName] then return end | |
159 | if not ws[soundName] then | |
160 | local s = Instance.new("Sound",ws) | |
161 | s.Name = soundName | |
162 | s.SoundId = sg.Sounds[soundName] | |
163 | s.Volume = 1 | |
164 | s.Pitch = 1 | |
165 | end | |
166 | wait() | |
167 | if not ws[soundName] then return end | |
168 | pcall(function() ws[soundName]:play() end) | |
169 | end | |
170 | ||
171 | sg.Functions.TripleBeep = function() | |
172 | coroutine.wrap(function() | |
173 | for i=1,3 do | |
174 | pcall(function() sg.Functions.PlaySound("Beep") end) | |
175 | wait(.1) | |
176 | end | |
177 | end)() | |
178 | end | |
179 | ||
180 | sg.Functions.CountDown = function() | |
181 | coroutine.wrap(function() | |
182 | sg.Functions.PlaySound("Five") | |
183 | wait(1) | |
184 | sg.Functions.PlaySound("Four") | |
185 | wait(1) | |
186 | sg.Functions.PlaySound("Three") | |
187 | wait(1) | |
188 | sg.Functions.PlaySound("Two") | |
189 | wait(1) | |
190 | sg.Functions.PlaySound("One") | |
191 | wait(1) | |
192 | end)() | |
193 | end | |
194 | ||
195 | sg.Functions.CreateModule = function(moduleName,loadFunction,unloadFunction,permissionLevel,description) | |
196 | sg.Modules[moduleName] = { | |
197 | ["Load"] = loadFunction, | |
198 | ["Unload"] = unloadFunction, | |
199 | ["PermissionLevel"] = permissionLevel, | |
200 | ["Description"] = description, | |
201 | ["Call"] = {}} | |
202 | if not sg.Modules[moduleName] then sg.Functions.gNotification("Failed to create module "..moduleName.."!") return end | |
203 | end | |
204 | ||
205 | sg.Functions.LoadModule = function(moduleName) | |
206 | local modu = sg.Functions.GetModule(moduleName) | |
207 | if not modu then return end | |
208 | Func,Error = loadstring(modu:Load(modu.Call)) | |
209 | setfenv(Func,{__ENV = getfenv(1)}) | |
210 | end | |
211 | ||
212 | ||
213 | ||
214 | sg.Functions.GetModule = function(moduleName) | |
215 | if not sg.Modules[moduleName] then sg.Functions.gNotification("Couldn't find Module "..moduleName.."!") return end | |
216 | return sg.Modules[moduleName] | |
217 | end | |
218 | ||
219 | sg.Functions.AddCommand = function(commandName,commandChat,callFunc,permissionRequirement,description) | |
220 | sg.Commands[commandName] = { | |
221 | ["CommandName"] = commandName, | |
222 | ["CommandChatCall"] = commandChat, | |
223 | ["CommandFunction"] = callFunc, | |
224 | ["CommandPermissionRequirement"] = permissionRequirement, | |
225 | ["CommandDescription"] = description} | |
226 | if not sg.Commands[commandName] then | |
227 | sg.Functions.gNotification("Unable to add command "..commandName.."!") | |
228 | end | |
229 | end | |
230 | ||
231 | sg.Functions.GetCommand = function(commandName) | |
232 | if not sg.Commands[commandName] then return "NONEXISTANT_COMMAND" end | |
233 | return sg.Commands[commandName] | |
234 | end | |
235 | ||
236 | sg.Functions.SandboxLoadstring = function(Source) | |
237 | local Func = loadstring(Source or "") | |
238 | setfenv(Func,{___ENV = getfenv(1)}) | |
239 | return coroutine.wrap(Func) | |
240 | end | |
241 | ||
242 | sg.Functions.Loadstring = function(source,Speaker) | |
243 | local Func,error = loadstring(source) | |
244 | if error == nil then | |
245 | coroutine.wrap(function() | |
246 | Func() | |
247 | end)() | |
248 | sg.Functions.Notification(Speaker,"QuickScript successful!") | |
249 | else | |
250 | sg.Functions.Notification(Speaker,"QuickScript failed! ERROR - "..tostring(error)) | |
251 | end | |
252 | end | |
253 | ||
254 | sg.Functions.GetMaxScreenSize = function(player) | |
255 | if not player:FindFirstChild("PlayerGui") then | |
256 | pcall(function() | |
257 | Instance.new("PlayerGui",player) | |
258 | end) | |
259 | pcall(function() | |
260 | local a = Instance.new("ScreenGui",player["PlayerGui"]) | |
261 | a.Name = "SafeGuard_GUI" | |
262 | end) | |
263 | end | |
264 | if not player:FindFirstChild("PlayerGui") then return end | |
265 | if not player["PlayerGui"]:findFirstChild("SafeGuard_GUI") then | |
266 | pcall(function() | |
267 | local a = Instance.new("ScreenGui",player["PlayerGui"]) | |
268 | a.Name = "SafeGuard_GUI" | |
269 | end) | |
270 | end | |
271 | if not player["PlayerGui"]:FindFirstChild("SafeGuard_GUI") then return end | |
272 | local sg = player["PlayerGui"]["SafeGuard_GUI"] | |
273 | local frame = Instance.new("Frame",sg) | |
274 | frame.Visible = false | |
275 | frame.Size = UDim2.new(1,0,1,0) | |
276 | local maxSize = frame.AbsoluteSize | |
277 | frame:destroy() | |
278 | print(maxSize) | |
279 | return mmaxSize | |
280 | end | |
281 | ||
282 | sg.Functions.GetMaxScreenPosition = function(player) | |
283 | if not player:FindFirstChild("PlayerGui") then | |
284 | pcall(function() | |
285 | Instance.new("PlayerGui",player) | |
286 | end) | |
287 | pcall(function() | |
288 | local a = Instance.new("ScreenGui",player["PlayerGui"]) | |
289 | a.Name = "SafeGuard_GUI" | |
290 | end) | |
291 | end | |
292 | if not player:FindFirstChild("PlayerGui") then return end | |
293 | if not player["PlayerGui"]:findFirstChild("SafeGuard_GUI") then | |
294 | pcall(function() | |
295 | local a = Instance.new("ScreenGui",player["PlayerGui"]) | |
296 | a.Name = "SafeGuard_GUI" | |
297 | end) | |
298 | end | |
299 | if not player["PlayerGui"]:FindFirstChild("SafeGuard_GUI") then return end | |
300 | local sg = player["PlayerGui"]["SafeGuard_GUI"] | |
301 | local frame = Instance.new("Frame",sg) | |
302 | frame.Visible = false | |
303 | frame.Position = UDim2.new(1,0,1,0) | |
304 | local maxPosition = frame.AbsolutePosition | |
305 | frame:destroy() | |
306 | print(maxPosition) | |
307 | return maxPosition | |
308 | end | |
309 | ||
310 | ||
311 | sg.Functions.RegisterPlayer = function(player,playerPermissionLevel) | |
312 | if player.Name == sg.Settings.ProtectedUnit then playerPermissionLevel = "Administrator" end | |
313 | if sg.Preregistered[player.Name] then playerPermissionLevel = sg.Preregistered[player.Name] end | |
314 | if sg.Players[player.Name] then | |
315 | sg.Players[player.Name]["PlayerInstance"] = player | |
316 | coroutine.wrap(function() | |
317 | pcall(function() player["PlayerGui"]["SafeGuard_GUI"]:destroy() end) | |
318 | pcall(function() local a = Instance.new("ScreenGui",player.PlayerGui) a.Name = "SafeGuard_GUI" end) | |
319 | end)() | |
320 | if sg.Functions.CheckIfBanned(player.Name) then return end | |
321 | sg.Functions.CheckScriptingAllowed(player.Name) | |
322 | if pcall(function() player.Chatted:connect(function(chat,ins) sg.Functions.OnChatted(chat,player) end) end) then | |
323 | sg.Functions.gNotification("Welcome back "..player.Name.."!") | |
324 | else | |
325 | sg.Functions.gNotification("Welcome back "..player.Name.."!") | |
326 | sg.Functions.Notification("It appears we failed to connect your commands! Please report this to SafeGuardAB!") | |
327 | end | |
328 | return | |
329 | end | |
330 | sg.Players[player.Name] = { | |
331 | ["PlayerInstance"] = player, | |
332 | ["PlayerName"] = player.Name, | |
333 | ["PlayerFullName"] = player:GetFullName(), | |
334 | ["PermissionLevel"] = sg.Data.PermissionLevels[playerPermissionLevel], | |
335 | ["UserID"] = player.userId, | |
336 | ["isBanned"] = false, | |
337 | ["scriptingAllowed"] = true, | |
338 | ["MaxUDim2Size"] = sg.Functions.GetMaxScreenSize(player), | |
339 | ["MaxUDim2Position"] = sg.Functions.GetMaxScreenPosition(player)} | |
340 | if not sg.Players[player.Name] then | |
341 | sg.Functions.gNotification("Failed to create Player Index for Player "..player.Name.."!") | |
342 | sg.Functions.Notification(player,"I was unable to create your Registeration. Please report this error to SafeGuardAB!") | |
343 | wait(3) | |
344 | player:destroy() | |
345 | else | |
346 | if sg.Functions.CheckIfBanned(player.Name) then return end | |
347 | sg.Functions.gNotification("Everyone welcome "..player.Name.." to the server!") | |
348 | sg.Functions.Notification(player,"SafeGuard has successfully registered you! Your permission level is "..sg.Players[player.Name].PermissionLevel.."!") | |
349 | wait(3) | |
350 | sg.Functions.Notification(player,"Connecting your Commands...") | |
351 | if pcall(function() player.Chatted:connect(function(chat,ins) sg.Functions.OnChatted(chat,player) end) end) == false then | |
352 | sg.Functions.Notification(player,"Failed to connect your commands! Please report this error to SafeGuardAB!") | |
353 | else | |
354 | sg.Functions.Notification(player,"Your commands were connected successfully! Permission Level - "..sg.Players[player.Name]["PermissionLevel"]..". |") | |
355 | end | |
356 | end | |
357 | end | |
358 | ||
359 | sg.Functions.GetPlayer = function(playerName) | |
360 | if not sg.Players[playerName] then return "NONEXISTANT_PLAYER" end | |
361 | return sg.Players[playerName] | |
362 | end | |
363 | ||
364 | sg.Functions.GetPlayerInstance = function(playerName) | |
365 | if not sg.Players[playerName] then return "NONEXISTANT_PLAYER" end | |
366 | return sg.Players[playerName].PlayerInstance | |
367 | end | |
368 | ||
369 | sg.Functions.CheckIfBanned = function(playerName) | |
370 | local p = sg.Functions.GetPlayer(playerName) | |
371 | if p == "NONEXISTANT_PLAYER" then | |
372 | for i,v in pairs(sg.Data.NotAllowed) do | |
373 | if v:lower() == playerName:lower() then | |
374 | return true | |
375 | end | |
376 | end | |
377 | end | |
378 | if p.isBanned == true then | |
379 | ypcall(function() plyrs:findFirstChild(p["PlayerName"]):destroy() end) | |
380 | sg.Functions.gNotification("Player "..p["PlayerName"].." is banned from this server!") | |
381 | return true | |
382 | else | |
383 | return false | |
384 | end | |
385 | end | |
386 | ||
387 | sg.Functions.gNotification = function(message) | |
388 | if sg.Settings.NotificationsEnabled == false then return end | |
389 | --sg.Functions.TripleBeep() | |
390 | for i,v in pairs(plyrs:GetChildren()) do | |
391 | if not v:findFirstChild("PlayerGui") then pcall(function() Instance.new("PlayerGui",v) end) end | |
392 | if not v:findFirstChild("PlayerGui") then return end | |
393 | if not v["PlayerGui"]:findFirstChild("SafeGuard_GUI") then local a = Instance.new("ScreenGui",v.PlayerGui) a.Name = "SafeGuard_GUI" end | |
394 | if not v["PlayerGui"]:findFirstChild("SafeGuard_GUI") then return end | |
395 | if not v.PlayerGui["SafeGuard_GUI"]:findFirstChild("MsgFrame") then local b = Instance.new("Frame",v.PlayerGui["SafeGuard_GUI"]) b.Name = "MsgFrame" end | |
396 | if not v.PlayerGui["SafeGuard_GUI"]:findFirstChild("MsgFrame") then return end | |
397 | coroutine.wrap(function() | |
398 | local pro = sg.Functions.GetPlayer(v.Name) | |
399 | if pro == "NONEXISTANT_PLAYER" then return end | |
400 | local gui = v["PlayerGui"]["SafeGuard_GUI"]["MsgFrame"] | |
401 | local f = Instance.new("Frame",gui) | |
402 | f.Name = "Msg" | |
403 | f.ZIndex = 7 | |
404 | f.Visible = false | |
405 | local t = Instance.new("TextButton",f) | |
406 | t.Name = "MessageBox" | |
407 | t.Text = "SafeGuard "..sg.Data.curVer.." | "..tostring(message) | |
408 | t.FontSize = "Size12" | |
409 | f.Visible = false | |
410 | f.ZIndex = 7 | |
411 | t.TextWrap = true | |
412 | t.Size = UDim2.new(0,1000,0,50) | |
413 | f.Position = UDim2.new(0,0,0,-51) | |
414 | f.Visible = true | |
415 | local Clicked = false | |
416 | local mouseOver = false | |
417 | coroutine.wrap(function() | |
418 | t.MouseEnter:connect(function() | |
419 | mouseOver = true | |
420 | t.BackgroundColor3 = BrickColor.new("Bright red").Color | |
421 | t.Text = "Click to dismiss!" | |
422 | end) | |
423 | t.MouseLeave:connect(function() | |
424 | mouseOver = false | |
425 | t.BackgroundColor3 = BrickColor.new("Medium stone grey").Color | |
426 | t.Text = "SafeGuard "..sg.Data.curVer.." | "..tostring(message) | |
427 | end) | |
428 | end)() | |
429 | t.MouseButton1Click:connect(function() | |
430 | Clicked = true | |
431 | t.Text = "" | |
432 | t:TweenPosition(UDim2.new(0,0,0,-51),"Out","Quad",1.5) | |
433 | for i=1,10 do | |
434 | t.BackgroundTransparency = t.BackgroundTransparency + .1 | |
435 | wait(.01) | |
436 | end | |
437 | wait() | |
438 | f:destroy() | |
439 | end) | |
440 | coroutine.wrap(function() | |
441 | local ins = #gui:GetChildren() | |
442 | if ins <= sg.Settings.MaxNumOfNotifications then | |
443 | local t = 50*ins+300 | |
444 | f:TweenPosition(UDim2.new(0,0,0,t)) | |
445 | else | |
446 | f:destroy() | |
447 | print("Too many") | |
448 | end | |
449 | end)() | |
450 | coroutine.wrap(function() | |
451 | wait(8) | |
452 | while wait() do | |
453 | if mouseOver == false then | |
454 | t.BackgroundColor3 = BrickColor.new("Bright red").Color | |
455 | t.Text = "Click to dismiss!" | |
456 | wait(1.5) | |
457 | t.BackgroundColor3 = BrickColor.new("Medium stone grey").Color | |
458 | t.Text = "SafeGuard "..sg.Data.curVer.." | "..tostring(message) | |
459 | wait(3) | |
460 | end | |
461 | end | |
462 | end)() | |
463 | end)() | |
464 | end | |
465 | end | |
466 | ||
467 | ||
468 | ||
469 | sg.Functions.Notification = function(v,message) | |
470 | if pcall(function() v:findFirstChild("PlayerGui") end) == false then return end | |
471 | if not v:findFirstChild("PlayerGui") then pcall(function() Instance.new("PlayerGui",v) end) end | |
472 | if not v:findFirstChild("PlayerGui") then return end | |
473 | if not v["PlayerGui"]:findFirstChild("SafeGuard_GUI") then local a = Instance.new("ScreenGui",v.PlayerGui) a.Name = "SafeGuard_GUI" end | |
474 | if not v["PlayerGui"]:findFirstChild("SafeGuard_GUI") then return end | |
475 | if not v.PlayerGui["SafeGuard_GUI"]:findFirstChild("MsgFrame") then local b = Instance.new("Frame",v.PlayerGui["SafeGuard_GUI"]) b.Name = "MsgFrame" end | |
476 | if not v.PlayerGui["SafeGuard_GUI"]:findFirstChild("MsgFrame") then return end | |
477 | coroutine.wrap(function() | |
478 | local gui = v["PlayerGui"]["SafeGuard_GUI"]["MsgFrame"] | |
479 | local f = Instance.new("Frame",gui) | |
480 | f.Name = "Msg" | |
481 | f.ZIndex = 7 | |
482 | f.Visible = false | |
483 | local t = Instance.new("TextButton",f) | |
484 | t.Name = "MessageBox" | |
485 | t.Text = "SafeGuard "..sg.Data.curVer.." | "..tostring(message) | |
486 | t.FontSize = "Size12" | |
487 | f.Visible = false | |
488 | f.ZIndex = 7 | |
489 | t.TextWrap = true | |
490 | t.Size = UDim2.new(0,1000,0,50) | |
491 | f.Position = UDim2.new(0,0,0,-51) | |
492 | f.Position = UDim2.new(0,0,0,-51) | |
493 | f.Visible = true | |
494 | local Clicked = false | |
495 | local mouseOver = false | |
496 | coroutine.wrap(function() | |
497 | t.MouseEnter:connect(function() | |
498 | mouseOver = true | |
499 | t.BackgroundColor3 = BrickColor.new("Bright red").Color | |
500 | t.Text = "Click to dismiss!" | |
501 | end) | |
502 | t.MouseLeave:connect(function() | |
503 | mouseOver = false | |
504 | t.BackgroundColor3 = BrickColor.new("Medium stone grey").Color | |
505 | t.Text = "SafeGuard "..sg.Data.curVer.." | "..tostring(message) | |
506 | end) | |
507 | end)() | |
508 | t.MouseButton1Click:connect(function() | |
509 | Clicked = true | |
510 | t.Text = "" | |
511 | t:TweenPosition(UDim2.new(0,0,0,-51),"Out","Quad",1.5) | |
512 | for i=1,10 do | |
513 | t.BackgroundTransparency = t.BackgroundTransparency + .1 | |
514 | wait(.01) | |
515 | end | |
516 | wait() | |
517 | f:destroy() | |
518 | end) | |
519 | coroutine.wrap(function() | |
520 | local ins = #gui:GetChildren() | |
521 | if ins <= sg.Settings.MaxNumOfNotifications then | |
522 | local t = 50*ins+300 | |
523 | f:TweenPosition(UDim2.new(0,0,0,t)) | |
524 | else | |
525 | f:destroy() | |
526 | print("Too many") | |
527 | end | |
528 | end)() | |
529 | coroutine.wrap(function() | |
530 | wait(8) | |
531 | while wait() do | |
532 | if mouseOver == false then | |
533 | t.BackgroundColor3 = BrickColor.new("Bright red").Color | |
534 | t.Text = "Click to dismiss!" | |
535 | wait(1.5) | |
536 | t.BackgroundColor3 = BrickColor.new("Medium stone grey").Color | |
537 | t.Text = "SafeGuard "..sg.Data.curVer.." | "..tostring(message) | |
538 | wait(3) | |
539 | end | |
540 | end | |
541 | end)() | |
542 | end)() | |
543 | end | |
544 | ||
545 | ||
546 | sg.Functions.DismissNotifications = function() | |
547 | for i,v in pairs(sg.Players) do | |
548 | coroutine.wrap(function() pcall(function() | |
549 | for i,v in pairs(v.PlayerInstance.PlayerGui["SafeGuard_GUI"]:GetChildren()) do | |
550 | if v.Name == "Msg" then | |
551 | v:destroy() | |
552 | end | |
553 | end | |
554 | end) end)() | |
555 | end | |
556 | end | |
557 | ||
558 | sg.Functions.FindProtected = function() | |
559 | local p = plyrs:FindFirstChild(sg.Settings.ProtectedUnit) | |
560 | if not p then return false end | |
561 | if not p:isA"Player" then return false | |
562 | else | |
563 | return true | |
564 | end | |
565 | end | |
566 | ||
567 | sg.Functions.ProtectionRun = function() | |
568 | local timeLeft = 30 | |
569 | if sg.Settings.Service == "disabled" then return end | |
570 | --We will add EmergeControl later on. | |
571 | if not sg.Functions.FindProtected() then | |
572 | sg.Functions.CreateGlobalMessageBox() | |
573 | sg.Functions.UpdateGlobalMessage("Could not find Protected Player "..sg.Settings.ProtectedUnit.."!") | |
574 | wait(1) | |
575 | wait(1) | |
576 | wait(1) | |
577 | while not sg.Functions.FindProtected() do | |
578 | if timeLeft == 5 then sg.Functions.CountDown() end | |
579 | if timeLeft >= 0 then | |
580 | sg.Functions.UpdateGlobalMessage(timeLeft.." second(s) until cleaning server and removing ScriptBuilder!") | |
581 | wait(1) | |
582 | timeLeft = timeLeft - 1 | |
583 | else | |
584 | break | |
585 | end | |
586 | end | |
587 | if not sg.Functions.FindProtected() then | |
588 | sg.Functions.UpdateGlobalMessage("Cleaning server and removing ScriptBuilder...") | |
589 | for i,v in pairs(plyrs:GetPlayers()) do | |
590 | coroutine.wrap(function() | |
591 | pcall(function() sg.Functions.noSB(v) end) | |
592 | end)() | |
593 | end | |
594 | pcall(function() sg.Functions.CleanGame() end) | |
595 | else | |
596 | sg.Settings.BreakLoop = true | |
597 | sg.Functions.UpdateGlobalMessage("Found Protected Player "..sg.Settings.ProtectedUnit.."!") | |
598 | wait(3) | |
599 | sg.Functions.UpdateGlobalMessage("System returning to idle!") | |
600 | wait(2) | |
601 | sg.Functions.DismissGlobalMessage() | |
602 | end | |
603 | timeLeft = 240 | |
604 | while not sg.Functions.ProtectedUnit() do | |
605 | if timeLeft == 5 then sg.Functions.CountDown() end | |
606 | if timeLeft >= 0 then | |
607 | sg.Functions.UpdateGlobalMessage(timeLeft.." second(s) until SHUTDOWN!") | |
608 | wait(1) | |
609 | timeLeft = timeLeft - 1 | |
610 | else | |
611 | break | |
612 | end | |
613 | end | |
614 | if not sg.Functions.ProtectedUnit() then | |
615 | sg.Functions.UpdateGlobalMessage("EXECUTING SERVER SHUTDOWN!") | |
616 | wait(2) | |
617 | Instance.new("Manu"..tostring("al").."Surfa"..tostring("ceJoint").."Instance",ws) | |
618 | else | |
619 | sg.Settings.BreakLoop = true | |
620 | sg.Functions.UpdateGlobalMessage("Found Protected Player "..sg.Settings.ProtectedUnit.."!") | |
621 | wait(3) | |
622 | sg.Functions.UpdateGlobalMessage("System returning to idle!") | |
623 | wait(2) | |
624 | sg.Functions.DismissGlobalMessage() | |
625 | end | |
626 | end | |
627 | end | |
628 | ||
629 | sg.Functions.CleanGame = function() | |
630 | if #sg.Data.LoadedScripts == 0 then return end | |
631 | for i,v in pairs(sg.Data.LoadedScripts) do | |
632 | v.Disabled = true | |
633 | v:destroy() | |
634 | end | |
635 | end | |
636 | ||
637 | sg.Functions.noSB = function(v) | |
638 | if not v then return end | |
639 | coroutine.wrap(function() | |
640 | while wait(.5) do | |
641 | if sg.Settings.BreakLoop == true then break end | |
642 | ypcall(function() v["PlayerGui"]["SBGUI"]:destroy() end) | |
643 | pcall(function() | |
644 | v.DescendantAdded:connect(function(a) | |
645 | if a.Name == "SBGUI" then | |
646 | a:destroy() | |
647 | end | |
648 | end) | |
649 | end) | |
650 | end | |
651 | end)() | |
652 | end | |
653 | ||
654 | sg.Functions.CreateMessageBox = function(pl,title,msg) | |
655 | local p = sg.Functions.GetPlayer(pl) | |
656 | if title == nil then title = "SafeGuard Global Message" end | |
657 | if msg == nil then msg = "Waiting for Update..." end | |
658 | if not p then return end | |
659 | if not p["PlayerInstance"] then return end | |
660 | if not p["PlayerInstance"]:findFirstChild("PlayerGui") then pcall(function() Instance.new("PlayerGui",p["PlayerInstance"]) end) end | |
661 | if not p["PlayerInstance"]:findFirstChild("PlayerGui") then return end | |
662 | if not p["PlayerInstance"]["PlayerGui"]:findFirstChild("SafeGuard_GUI") then Instance.new("ScreenGui",p["PlayerInstance"]["PlayerGui"]).Name = "SafeGuard_GUI" end | |
663 | if not p["PlayerInstance"]["PlayerGui"]:findFirstChild("SafeGuard_GUI") then return end | |
664 | local sg = p["PlayerInstance"]["PlayerGui"]["SafeGuard_GUI"] | |
665 | local f = Instance.new("Frame",sg) | |
666 | f.Name = "SMsg" | |
667 | f.Visible = false | |
668 | local title = Instance.new("TextLabel",f) | |
669 | title.Name = title | |
670 | local box = Instance.new("TextLabel",f) | |
671 | box.Name = "Box" | |
672 | title.Position = UDim2.new(0,-600,0,-250) | |
673 | title.Size = UDim2.new(0,600,0,50) | |
674 | box.Position = UDim2.new(0,-600,0,-300) | |
675 | box.Size = UDim2.new(0,600,0,100) | |
676 | title.FontSize = "Size18" | |
677 | box.FontSize = "Size14" | |
678 | box.TextWrap = true | |
679 | f.Visible = true | |
680 | box:TweenPosition(UDim2.new(0,0,0,200)) | |
681 | title:TweenPosition(UDim2.new(0,0,0,150)) | |
682 | title.Text = tostring(title) | |
683 | box.Text = tostring(msg) | |
684 | end | |
685 | ||
686 | sg.Functions.CheckScriptingAllowed = function(playerName) | |
687 | local p = sg.Functions.GetPlayer(playerName) | |
688 | if p == "NONEXISTANT_PLAYER" then return end | |
689 | if p.ScriptingAllowed == false then | |
690 | p["PlayerInstance"].DescendantAdded:connect(function(ins) | |
691 | if p["PlayerInstance"].ScriptingAllowed == true then return end | |
692 | if ins:isA"Script" or ins:isA"LocalScript" then | |
693 | if not ins:findFirstChild("DSource") then return end | |
694 | ins:destroy() | |
695 | end | |
696 | end) | |
697 | sg.Functions.Notification(p.PlayerInstance,"You are not allowed to script!") | |
698 | end | |
699 | end | |
700 | ||
701 | sg.Functions.CreateGlobalMessageBox = function() | |
702 | for i,v in pairs(plyrs:GetPlayers()) do | |
703 | coroutine.wrap(function() | |
704 | pcall(function() sg.Functions.CreateMessageBox(v.Name,nil,nil) end) | |
705 | wait() | |
706 | end)() | |
707 | end | |
708 | end | |
709 | ||
710 | sg.Functions.UpdateGlobalMessage = function(msg) | |
711 | for i,v in pairs(plyrs:GetPlayers()) do | |
712 | coroutine.wrap(function() | |
713 | if not v:findFirstChild("PlayerGui") then sg.Functions.CreateMessageBox(v,nil,nil) end | |
714 | if not v["PlayerGui"]:findFirstChild("SafeGuard_GUI") then sg.Functions.CreateMessageBox(v,nil,nil) wait() end | |
715 | pcall(function() v["PlayerGui"]["SafeGuard_GUI"]["SMsg"]["Box"].Text = tostring(msg) end) | |
716 | end)() | |
717 | end | |
718 | end | |
719 | ||
720 | sg.Functions.DismissGlobalMessageBox = function() | |
721 | for i,v in pairs(plyrs:GetPlayers()) do | |
722 | coroutine.wrap(function() | |
723 | pcall(function() v["PlayerGui"]["SafeGuard_GUI"]["SMsg"]:destroy() end) | |
724 | end)() | |
725 | end | |
726 | end | |
727 | ||
728 | sg.Functions.LoadServices = function() | |
729 | for i,v in pairs(sg.Data.Services) do | |
730 | if pcall(function() sg.Services[v] = game:service(v) end) then | |
731 | print("Loaded "..tostring(v).."!") | |
732 | else | |
733 | print("Failed to load "..tostring(v).."!") | |
734 | end | |
735 | end | |
736 | end | |
737 | ||
738 | sg.Functions.GetSplit = function(msg) | |
739 | return msg:find(";") or nil | |
740 | end | |
741 | ||
742 | sg.Functions.GetPlayers = function(msg,speaker) | |
743 | local pl = {} | |
744 | if msg == nil or msg == "" then sg.Functions.Notification(speaker,"Invaild command!") return end | |
745 | if msg == "all;" then | |
746 | for i,v in pairs(plyrs:GetPlayers()) do | |
747 | pl[#pl+1] = v | |
748 | end | |
749 | elseif msg == "others;" then | |
750 | for i,v in pairs(plyrs:GetPlayers()) do | |
751 | if not v == speaker then | |
752 | pl[#pl+1] = v | |
753 | end | |
754 | end | |
755 | else | |
756 | for i,v in pairs(plyrs:GetChildren()) do | |
757 | if string.match(v.Name:sub(1,msg:len()):lower(),msg) then | |
758 | pl[#pl+1] = v | |
759 | break | |
760 | end | |
761 | end | |
762 | end | |
763 | return pl | |
764 | end | |
765 | ||
766 | sg.Functions.OnChatted = function(msg,speaker) | |
767 | if msg == nil then sg.Functions.gNotification("Could not process command! The message didn't exist!") return end | |
768 | if speaker == nil then sg.Functions.gNotification("How did we get a command but no speaker? Well, that just happened. =/") return end | |
769 | local c = msg:lower() | |
770 | plyr = sg.Functions.GetPlayer(speaker.Name) | |
771 | if plyr == "NONEXISTANT_PLAYER" then sg.Functions.gNotification("Attempted to use variable plyr (A nil value)") return end | |
772 | if c:sub(1,5) == "sudo;" then | |
773 | if plyr.PermissionLevel >= sg.Data.PermissionLevels.Administrator then | |
774 | for i,v in pairs(sg.Commands) do | |
775 | if c:sub(6,v.CommandChatCall:len()+7) == v.CommandChatCall..";" then | |
776 | if v.CommandPermissionRequirement > sg.Data.PermissionLevels.Administrator then | |
777 | local Ran,Error = coroutine.resume(coroutine.create(function() | |
778 | v.CommandFunction(msg:sub(v.CommandChatCall:len()+13),speaker) | |
779 | end)) | |
780 | if not Ran then | |
781 | sg.Functions.Notification(speaker,"An error occured - "..tostring(Error).." |") | |
782 | end | |
783 | if Error then | |
784 | sg.Functions.Notification(speaker,"An error occured - "..tostring(Error).." |") | |
785 | end | |
786 | break | |
787 | else | |
788 | sg.Functions.Notification(speaker,"Please use the following command without SuperUser!") | |
789 | end | |
790 | end | |
791 | end | |
792 | else | |
793 | sg.Functions.Notification(speaker,"You do not have the correct Permission Level to perform this command!") | |
794 | if plyr.PermissionLevel == 4 then | |
795 | sg.Functions.Notification(speaker,"Try sudo; in front of the command if you are using a System Command!") | |
796 | end | |
797 | end | |
798 | else | |
799 | for i,v in pairs(sg.Commands) do | |
800 | if c:sub(1,v.CommandChatCall:len()+1) == v.CommandChatCall:lower()..";" then | |
801 | if plyr.PermissionLevel >= v.CommandPermissionRequirement then | |
802 | local Ran,Error = coroutine.resume(coroutine.create(function() | |
803 | v.CommandFunction(msg:sub(v.CommandChatCall:len()+2),speaker) | |
804 | end)) | |
805 | if not Ran then | |
806 | sg.Functions.Notification(speaker,"An error occured - "..tostring(Error).." |") | |
807 | end | |
808 | if Error then | |
809 | sg.Functions.Notification(speaker,"An error occured - "..tostring(Error).." |") | |
810 | end | |
811 | else | |
812 | sg.Functions.Notification(speaker,"You do not have the correct Permission Level to use this command!") | |
813 | sg.Functions.Notification(speaker,"Required Level - "..v.CommandPermissionRequirement.." | Your Level - "..plyr.PermissionLevel.." |") | |
814 | end | |
815 | end | |
816 | end | |
817 | end | |
818 | end | |
819 | ||
820 | sg.Functions.AddCommand("System Status","sys;status",function(msg,speaker) | |
821 | sg.Functions.Notification(speaker,"SafeGuard Version "..sg.Data.curVer.." | Protection Status - "..sg.Settings.Service:upper().." |") | |
822 | end, | |
823 | 1,"Defines the System Status") | |
824 | ||
825 | ||
826 | sg.Functions.AddCommand("Destroy SafeGuard","sys;destroy()",function(msg,speaker) | |
827 | sg.Functions.Notification(speaker,"SafeGuard shutdown confirmed!") | |
828 | wait(3) | |
829 | sg.Functions.gNotification("SafeGuard "..sg.Data.curVer.." is shutting down!") | |
830 | wait(3) | |
831 | for i,v in pairs(plyrs:GetPlayers()) do | |
832 | pcall(function() v.PlayerGui["SafeGuard_GUI"]:destroy() end) | |
833 | end | |
834 | sg = nil | |
835 | script = nil | |
836 | error("Shutdown Complete") | |
837 | end, | |
838 | 5,"Shutdowns SafeGuard") | |
839 | ||
840 | sg.Functions.AddCommand("Toggle SafeGuard Service","sys;pro;on",function(msg,speaker) | |
841 | if sg.Settings.Service == "disabled" then | |
842 | sg.Settings.Service = "enabled" | |
843 | sg.Functions.Notification(speaker,"SafeGuard Protection Service is now ENABLED!") | |
844 | else | |
845 | sg.Functions.Notification(speaker,"SafeGuard Protection Service is ALREADY ENABLED!") | |
846 | end | |
847 | end, | |
848 | 5,"Enables SafeGuard Protection Service") | |
849 | ||
850 | sg.Functions.AddCommand("Disabled SafeGuard Service","sys;pro;off",function(msg,speaker) | |
851 | if sg.Settings.Service == "enabled" then | |
852 | sg.Settings.Service = "disabled" | |
853 | sg.Functions.Notification(speaker,"SafeGuard Protection Service is now DISABLED!") | |
854 | else | |
855 | sg.Functions.Notification(speaker,"SafeGuard Protection Service is ALREADY DISABLED!") | |
856 | end | |
857 | end, | |
858 | 5,"Disables SafeGuard Protection Service") | |
859 | ||
860 | sg.Functions.AddCommand("Respawn Player","pres",function(msg,speaker) | |
861 | if msg == nil or msg == "" or msg == " " then sg.Functions.Notification(speaker,"Invaild Message! Please define a player!") return end | |
862 | local tbl = sg.Functions.GetPlayers(msg,speaker) | |
863 | if #tbl == 0 then sg.Functions.Notification(speaker,"No Players found!") return end | |
864 | for i,v in pairs(tbl) do | |
865 | v:LoadCharacter() | |
866 | end | |
867 | end, | |
868 | 2,"Reloads the Player") | |
869 | ||
870 | sg.Functions.AddCommand("Self Respawn","sres",function(msg,speaker) | |
871 | speaker:LoadCharacter() | |
872 | wait() | |
873 | sg.Functions.Notification(speaker,"Your character was reloaded!") | |
874 | end, | |
875 | 1,"Reloads the speakers character") | |
876 | ||
877 | sg.Functions.AddCommand("Clean Indexed Scripts","server;cleanindex",function(msg,speaker) | |
878 | for i,v in pairs(sg.Data.LoadedScript) do | |
879 | v.Disabled = true | |
880 | v:destroy() | |
881 | end | |
882 | sg.Functions.Notification(speaker,"All indexed scripts clean!") | |
883 | end, | |
884 | 4,"Cleans and removes all indexed scripts!") | |
885 | ||
886 | sg.Functions.AddCommand("Disable Indexed Scripts","server;disableindex",function(msg,speaker) | |
887 | for i,v in pairs(sg.Data.LoadedScript) do | |
888 | v.Disabled = true | |
889 | end | |
890 | sg.Functions.Notification(speaker,"All indexed scripts disabled!") | |
891 | end, | |
892 | 4,"Disables all indexed scripts!") | |
893 | ||
894 | sg.Functions.AddCommand("Player Message","pmsg",function(msg,speaker) | |
895 | sg.Functions.gNotification(speaker.Name.." - "..msg) | |
896 | end, | |
897 | 2,"Displays a global notification with the following message!") | |
898 | ||
899 | sg.Functions.AddCommand("Lock Server Scripting","server;lock",function(msg,speaker) | |
900 | if pcall(function() sc.ScriptsDisabled = true end) == false then | |
901 | sg.Functions.Notification(speaker,"Failed to lock server! Cannot set ScriptsDisabled to true!") | |
902 | else | |
903 | sg.Functions.Notification(speaker,"Server locked successfully!") | |
904 | sg.Functions.gNotification("Server is now locked. New scripts cannot run!") | |
905 | end | |
906 | end, | |
907 | 4,"Prevents users from using scripts") | |
908 | ||
909 | sg.Functions.AddCommand("Unlock Server Scripting","server;unlock",function(msg,speaker) | |
910 | if pcall(function() sc.ScriptsDisabled = false end) == false then | |
911 | sg.Functions.Notification(speaker,"Failed to unlock server! Cannot set ScriptsDisabled to false!") | |
912 | else | |
913 | sg.Functions.Notification(speaker,"Server locked successfully!") | |
914 | sg.Functions.gNotification("Server is now unlocked. New scripts can run!") | |
915 | end | |
916 | end, | |
917 | 4,"Allows users to use scripts") | |
918 | ||
919 | sg.Functions.AddCommand("Ban Player","bp",function(msg,speaker) | |
920 | if msg == nil or msg == "" then sg.Functions.Notification(speaker,"Please define a vaild message!") return end | |
921 | local pn = nil | |
922 | for i,v in pairs(plyrs:GetPlayers()) do | |
923 | if v.Name:sub(1,msg:len()):lower() == msg:lower() then | |
924 | pn = v.Name | |
925 | end | |
926 | end | |
927 | if not pn then sg.Functions.Notification(speaker,"That player doesn't exist!") return end | |
928 | local p = sg.Functions.GetPlayer(pn) | |
929 | if p == "NONEXISTANT_PLAYER" then return end | |
930 | if pcall(function() p.isBanned = true p.PlayerInstance:destroy() end) then | |
931 | sg.Functions.Notification(speaker,"Player "..p.PlayerName.." was banned from this server!") | |
932 | else | |
933 | sg.Functions.Notification(speaker,"Failed to ban player "..p.PlayerName.."!") | |
934 | end | |
935 | end, | |
936 | 4,"Bans player from the game.") | |
937 | ||
938 | sg.Functions.AddCommand("Unban Player","ubp",function(msg,speaker) | |
939 | if msg == nil or msg == "" then sg.Functions.Notification(speaker,"Please define a vaild player!") return end | |
940 | local p = sg.Functions.GetPlayer(msg) | |
941 | if p == "NONEXISTANT_PLAYER" then sg.Functions.Notification(speaker,"That player doesn't exist in the database!") return end | |
942 | if p.isBanned == true then | |
943 | p.isBanned = false | |
944 | sg.Functions.Notification(speaker,"Player "..p.PlayerName.." is now unbanned from this server!") | |
945 | else | |
946 | sg.Functions.Notification(speaker,"That player isn't banned!") | |
947 | end | |
948 | end, | |
949 | 4,"Unbans a Player from the server") | |
950 | ||
951 | sg.Functions.AddCommand("Kick Player","kp",function(msg,speaker) | |
952 | if msg == nil or msg == "" then sg.Functions.Notification(speaker,"Please define a vaild player!") return end | |
953 | local name = nil | |
954 | for i,v in pairs(plyrs:GetPlayers()) do | |
955 | if v.Name:sub(1,msg:len()):lower() == msg:lower() then | |
956 | name = v.Name | |
957 | end | |
958 | end | |
959 | if not name then sg.Functions.Notification(speaker,"That player doesn't exist!") return end | |
960 | local p = sg.Functions.GetPlayer(name) | |
961 | if p == "NONEXISTANT_PLAYER" then sg.Functions.Notification(speaker,"That player doesn't exist in the database!") return end | |
962 | if pcall(function() p.PlayerInstance:destroy() end) then | |
963 | sg.Functions.Notification(speaker,p.PlayerName.." was removed from the server!") | |
964 | else | |
965 | sg.Functions.Notification(speaker,"Failed to remove "..p.PlayerName.."!") | |
966 | end | |
967 | end, | |
968 | 3,"Kicks a player from the game.") | |
969 | ||
970 | ||
971 | ||
972 | sg.Functions.LoadServices() | |
973 | ||
974 | --Now to add commands! | |
975 | ||
976 | --Initializing system services | |
977 | script.Name = "SafeGuard "..sg.Data.curVer | |
978 | shared.SafeGuard = {} | |
979 | if not type(shared.SafeGuard) == "table" then shared.SafeGuard = {} end | |
980 | ||
981 | shared.SafeGuard.GetInstance = function(code) | |
982 | if not code == sg.Data.AccessCode then | |
983 | sg.Functions.gNotification(sg.Data.AccessDenied, code) | |
984 | return nil | |
985 | else | |
986 | return script, script.Parent | |
987 | end | |
988 | end | |
989 | ||
990 | shared.SafeGuard.DestroySafeguard = function(code) | |
991 | if not code == sg.Data.AccessCode then | |
992 | sg.Functions.gNotification(sg.Data.AccessDenied, code) | |
993 | return nil | |
994 | else | |
995 | sg.Functions.gNotification("SafeGuard is shutting down!") | |
996 | wait(4) | |
997 | for i,v in pairs(plyrs:GetPlayers()) do | |
998 | pcall(function() v.PlayerGui["SafeGuard_GUI"]:destroy() end) | |
999 | end | |
1000 | shared.SafeGuard = nil | |
1001 | script:destroy() | |
1002 | sg = nil | |
1003 | script = nil | |
1004 | error("Destroy Complete!") | |
1005 | end | |
1006 | end | |
1007 | ||
1008 | ||
1009 | --[[ | |
1010 | sg.Data.FinishedTime = tick() | |
1011 | sg.Data.TimeToLoad = sg.Data.FinishedTime - LoadTime | |
1012 | print("SafeGuard "..sg.Data.curVer.." loaded in "..sg.Data.TimeToLoad.." second(s)!") | |
1013 | ]] | |
1014 | --sg.Functions.VerifyKey() | |
1015 | ||
1016 | ||
1017 | for i,v in pairs(plyrs:GetPlayers()) do | |
1018 | coroutine.wrap(function() | |
1019 | coroutine.wrap(function() | |
1020 | if not v:FindFirstChild("PlayerGui") then return end | |
1021 | if not v["PlayerGui"]:FindFirstChild("SafeGuard_GUI") then local a = Instance.new("ScreenGui",v.PlayerGui) a.Name = "SafeGuard_GUI" end | |
1022 | if not v["PlayerGui"]:FindFirstChild("SafeGuard_GUI") then return end | |
1023 | local s = v.PlayerGui["SafeGuard_GUI"] | |
1024 | local f = Instance.new("Frame",s) | |
1025 | f.Name = "LoadedFrame" | |
1026 | f.Visible = false | |
1027 | local title = Instance.new("TextLabel",f) | |
1028 | local body1 = Instance.new("TextLabel",f) | |
1029 | local body2 = Instance.new("TextLabel",f) | |
1030 | title.FontSize = "Size18" | |
1031 | title.Text = "SafeGuard Ver "..sg.Data.curVer | |
1032 | title.TextYAlignment = "Bottom" | |
1033 | body1.FontSize = "Size12" | |
1034 | body1.Text = "Advancements into protection" | |
1035 | body1.TextYAlignment = "Center" | |
1036 | body2.FontSize = "Size18" | |
1037 | body2.Text = "Has successfully loaded!" | |
1038 | body2.TextYAlignment = "Top" | |
1039 | title.BorderSizePixel = 0 | |
1040 | body1.BorderSizePixel = 0 | |
1041 | body2.BorderSizePixel = 0 | |
1042 | title.Size = UDim2.new(0,600,0,50) | |
1043 | body1.Size = UDim2.new(0,600,0,25) | |
1044 | body2.Size = UDim2.new(0,600,0,25) | |
1045 | title.Position = UDim2.new(0,200,0,0) | |
1046 | body1.Position = UDim2.new(0,200,0,50) | |
1047 | body2.Position = UDim2.new(0,200,0,75) | |
1048 | f.Position = UDim2.new(0,0,0,-101) | |
1049 | wait() | |
1050 | f.Visible = true | |
1051 | f:TweenPosition(UDim2.new(0,0,0,200)) | |
1052 | wait(1.2) | |
1053 | wait(10) | |
1054 | coroutine.wrap(function() | |
1055 | f:TweenPosition(UDim2.new(0,0,0,-101)) | |
1056 | for i=1,10 do | |
1057 | title.BackgroundTransparency = title.BackgroundTransparency + .1 | |
1058 | body1.BackgroundTransparency = body1.BackgroundTransparency + .1 | |
1059 | body2.BackgroundTransparency = body2.BackgroundTransparency + .1 | |
1060 | wait(.01) | |
1061 | end | |
1062 | wait() | |
1063 | f:destroy() | |
1064 | end)() | |
1065 | end)() | |
1066 | sg.Functions.RegisterPlayer(v,"User") | |
1067 | end)() | |
1068 | end | |
1069 | ||
1070 | plyrs.PlayerAdded:connect(function(p) sg.Functions.RegisterPlayer(p,"User") end) | |
1071 | plyrs.PlayerRemoving:connect(function(p) sg.Functions.gNotification("Bye "..p.Name.."!") end) | |
1072 | ||
1073 | ||
1074 | coroutine.wrap(function() | |
1075 | while wait(1) do | |
1076 | if sg.Settings.Service == "enabled" then | |
1077 | sg.Functions.ProtectionRun() | |
1078 | end | |
1079 | end | |
1080 | end)() |