Advertisement
DefeatedPurpose

Tohru GSE

Dec 16th, 2019
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.43 KB | None | 0 0
  1. local loadtime = tick()
  2. -- Welcome to Tohru's GSE (Global Script Executer)
  3. -- Essentially, this script will allow for other people in your lobby to execute scripts via your client
  4. -- This does not have protection so be careful who you whitelist for your script!
  5. -- Example(Player: ;run [script] Script will not run because player is not whitelisted)
  6. -- (You: ;whitelist Player|Player: ;run [script] Script will now run because player is now whitelisted)
  7. local Version = '1.0'
  8. local Players = game:GetService("Players")
  9. _G.ran = false
  10. local LP = Players.LocalPlayer
  11. function has(sample, text)
  12. sample = sample or "Sample Text"
  13. text = text or "Sample"
  14. if (string.match(sample, text) and true or false) then
  15. return true
  16. else
  17. return false
  18. end
  19. end
  20. function genlog(user, whitelist, code)
  21. return "LOG|User: "..tostring(user).."|Whitelisted? "..tostring(whitelist).."|Input: [' "..tostring(code).." ']|Time: "..currenttime().."|"
  22. end
  23. function findplayer(input)
  24. input = tostring(input)
  25. local matched_players = {}
  26. for i,v in pairs(game:GetService("Players"):GetPlayers()) do
  27. if input == "all" then
  28. table.insert(matched_players, v)
  29. elseif input == "others" then
  30. if v.Name ~= game:GetService("Players").LocalPlayer.Name then
  31. table.insert(matched_players, v)
  32. end
  33. elseif input == "me" then
  34. if v.Name == game:GetService("Players").LocalPlayer.Name then
  35. table.insert(matched_players, v)
  36. end
  37. else
  38. if string.sub(string.lower(v.Name),1,#input) == string.lower(input) then
  39. table.insert(matched_players, v)
  40. end
  41. end
  42. end
  43. if #matched_players ~= 0 then
  44. return matched_players else return false
  45. end
  46. end
  47. function SendMsg(String)
  48. String = tostring(String) or "Hello!"
  49. game:GetService("ReplicatedStorage").DefaultChatSystemChatEvents.SayMessageRequest:FireServer(String, "all")
  50. end
  51. function Notify(Text)
  52. Text = Text or "Return: nil"
  53. game.StarterGui:SetCore("SendNotification", {Title = "Tohru GSE"; Text = Text})
  54. end
  55. function split(text, divider)
  56. local seperated = {}
  57. for i in text:gmatch("[^".. divider .."]+") do
  58. table.insert(seperated,i)
  59. end
  60. return seperated
  61. end
  62. function runscript(code)
  63. _G.ran = true
  64. code = tostring(code)
  65. loadstring(code)()
  66. _G.ran = false
  67. end
  68. function stringify(t)
  69. ta = {}
  70. for i,v in pairs(t) do
  71. if i ~= #t then
  72. table.insert(ta, t[i]..", ")
  73. else
  74. table.insert(ta, t[i])
  75. end
  76. end
  77. return table.concat(ta)
  78. end
  79. function currenttime()
  80. the_hour = math.floor((tick() % 86400) / 3600)
  81. the_minute = math.floor((tick() % 3600) / 60)
  82. the_second = math.floor(tick() % 60)
  83. the_time_of_day = the_hour > 11 and 'PM' or 'AM'
  84. the_hour = (the_hour % 12 == 0 and 12 or the_hour % 12)
  85. the_hour = the_hour < 10 and '0' .. the_hour or the_hour
  86. the_minute = the_minute < 10 and '0' .. the_minute or the_minute
  87. the_second = the_second < 10 and '0' .. the_second or the_second
  88. return the_hour .. ':' .. the_minute .. ':' .. the_second .. ' ' .. the_time_of_day
  89. end
  90. local old1
  91. local function hook1(p)
  92. if _G.ran then
  93. SendMsg("OP {P}: "..tostring(p))
  94. end
  95. return old1(tostring(p))
  96. end
  97. old1 = hookfunction(print, hook1)
  98. local old2
  99. local function hook2(w)
  100. if _G.ran then
  101. if #split(tostring(w), ":") > 2 then
  102. wrn = split(tostring(w), ":")
  103. warnline = wrn[2]
  104. warnmsg = wrn[3]
  105. SendMsg("OP {W @ Line "..warnline.."}:"..warnmsg)
  106. else
  107. SendMsg("OP {W}: "..tostring(w))
  108. end
  109. end
  110. return old2(tostring(w))
  111. end
  112. old2 = hookfunction(warn, hook2)
  113. game:GetService("ScriptContext").Error:Connect(function(fail)
  114. if _G.ran then
  115. if #split(tostring(fail), ":") > 2 then
  116. failer = split(tostring(fail), ":")
  117. errline = failer[2]
  118. errmsg = failer[3]
  119. SendMsg("OP {E @ Line "..errline.."}:"..errmsg)
  120. else
  121. SendMsg("OP {E}: "..tostring(fail))
  122. end
  123. end
  124. end)
  125. WL = {Players.LocalPlayer.Name}
  126. whitelist_logs = {}
  127. script_logs = {}
  128. prefix = ";"
  129. function cmdcheck(input, cmd, checktype)
  130. if checktype == "multiple" or checktype == "m" then
  131. if has(input:lower(), prefix..""..cmd.." ") and input:sub(1,1) == prefix and input:sub(2, (cmd):len() + 1) == cmd then
  132. return true else return false
  133. end
  134. elseif checktype == "single" or checktype == "s" then
  135. if input == prefix..""..cmd then
  136. return true else return false
  137. end
  138. end
  139. end
  140. function getargs(input, cmd)
  141. return input:sub(prefix:len() + cmd:len() + 2 )
  142. end
  143. local Users = Instance.new("Folder")
  144. local Players = game:GetService("Players")
  145. local CoreGui = game:GetService("CoreGui")
  146. Users.Name = "GSE Users"
  147. Users.Parent = CoreGui
  148. Users.ChildAdded:Connect(function(child)
  149. wait(0.1)
  150. for i,v in ipairs(Users:GetChildren()) do
  151. if v.Name == child.Name then
  152. v:Destroy()
  153. end
  154. end
  155. Players[child.Name].Chatted:Connect(function(msg)
  156. if cmdcheck(msg, "whitelist", 'm') then
  157. if tostring(Players[child.Name]) == tostring(LP.Name) then
  158. msg = getargs(msg, "whitelist")
  159. placeholder1 = {}
  160. placeholder2 = {}
  161. placeholder3 = {}
  162. for i,v in pairs( split(msg, ", ") ) do
  163. if findplayer(v) then
  164. for a, b in pairs(findplayer(v)) do
  165. if b.Name ~= LP.Name then
  166. table.insert(placeholder1, b.Name)
  167. end
  168. end
  169. elseif not findplayer(v) then
  170. table.insert(placeholder2, tostring(v))
  171. end
  172. end
  173. for i,v in pairs(placeholder1) do
  174.     for h,j in pairs(WL) do
  175.     if v == j then
  176. table.insert(placeholder3, v)
  177. placeholder1[i] = nil
  178. end
  179. end
  180. end
  181. for i,v in pairs(placeholder1) do
  182. table.insert(WL, tostring(v))
  183. end
  184. if #placeholder1 ~= 0 then
  185. Notify("Whitelisted: ".. stringify(placeholder1))
  186. table.insert(whitelist_logs, "LOG|Whitelisted '".. stringify(placeholder1) .."' at ".. currenttime())
  187. end
  188. if #placeholder2 ~= 0 then
  189. Notify("Failed to find '"..stringify(placeholder2).."'!")
  190. end
  191. if #placeholder3 ~= 0 then
  192. Notify('"'.. stringify(placeholder3) ..'" is already whitelisted!')
  193. end
  194. end
  195. end
  196. if cmdcheck(msg, "whitelisted", 's') then
  197. if tostring(Players[child.Name]) == tostring(LP.Name) then
  198. Notify("Whitelisted : ".. stringify(WL))
  199. print('[-----[WHITELISTED USERS #'.. #WL ..']-----]')
  200. for i,v in pairs(WL) do
  201. print(v)
  202. end
  203. print('[-----[WHITELISTED USERS #'.. #WL ..']-----]')
  204. end
  205. end
  206. if cmdcheck(msg, "blacklist", 'm') then
  207. if tostring(Players[child.Name]) == tostring(LP.Name) then
  208. msg = getargs(msg, "blacklist")
  209. if msg == "all" or msg == "others" then
  210. for i = 1, #WL do
  211. if WL[i] ~= LP.Name then
  212. WL[i] = nil
  213. end
  214. end
  215. table.insert(whitelist_logs, "LOG|Cleared Whitelist table at ".. currenttime())
  216. Notify("Cleared Whitelist Table")
  217. else
  218. placeholder1 = {}
  219. placeholder2 = {}
  220. for i, v in pairs( split(msg, ", ") ) do
  221. for a, b in pairs(WL) do
  222. if b ~= LP.Name then
  223. if string.sub(string.lower(b), 1, #msg) == string.lower(msg) then
  224. table.insert(placeholder1, b)
  225. else
  226. table.insert(placeholder2, v)
  227. end
  228. end
  229. end
  230. end
  231. if #placeholder1 ~= 0 then
  232. for i,v in pairs(placeholder1) do
  233. for a = 1, #WL do
  234. if v == WL[a] then
  235. WL[a] = nil
  236. end
  237. end
  238. end
  239. Notify("Blacklisted : ".. stringify(placeholder1))
  240. table.insert(whitelist_logs, "LOG|Blacklisted '".. stringify(placeholder1) .."' at ".. currenttime())
  241. end
  242. if #placeholder2 ~= 0 then
  243. Notify("Failed to find '".. stringify(placeholder2) .."'!")
  244. end
  245. end
  246. end
  247. end
  248. if cmdcheck(msg, "s", "m") then
  249. WL_Check = 'false'
  250. msg = getargs(msg, "s")
  251. for i,v in pairs(WL) do
  252. if tostring(Players[child.Name]) == v then
  253. spawn (function()
  254. wait()
  255. runscript(tostring(msg))
  256. end)
  257. WL_Check = 'true'
  258. else
  259. WL_Check = "false"
  260. end
  261. end
  262. table.insert(script_logs, genlog(tostring( Players[child.Name] ), WL_Check, tostring(msg) ))
  263. end
  264. if cmdcheck(msg, "logs", "s") then
  265. if tostring(Players[child.Name]) == tostring(LP.Name) then
  266. if #script_logs == 0 and #whitelist_logs == 0 then
  267. Notify("No logs found!")
  268. else
  269. Notify("Script Logs: #".. #script_logs .."|Whitelist Logs: #".. #whitelist_logs .."|Total Logs: #".. #script_logs + #whitelist_logs .."")
  270. print("[-----[WHITELIST LOGS #".. #whitelist_logs .."]-----]")
  271. for i,v in pairs(whitelist_logs) do
  272. print(v)
  273. end
  274. print("[-----[WHITELIST LOGS #".. #whitelist_logs .."]-----]")
  275. print("[-----[SCRIPT LOGS #".. #script_logs .."]-----]")
  276. for i,v in pairs(script_logs) do
  277. print(v)
  278. end
  279. print("[-----[SCRIPT LOGS #".. #script_logs .."]-----]")
  280. end
  281. end
  282. end
  283. end)
  284. end)
  285. for i = 1, #Players:GetPlayers() do
  286. Instance.new("BoolValue", Users).Name = Players:GetPlayers()[i].Name
  287. end
  288. Players.PlayerAdded:Connect(function(plr)
  289. Instance.new("BoolValue", Users).Name = plr.Name
  290. end)
  291. Players.PlayerRemoving:Connect(function(plr)
  292. for i = 1, #Users:GetChildren() do
  293. if Users:GetChildren()[i].Name == plr.Name then
  294. Users:GetChildren()[i]:Destroy()
  295. end
  296. end
  297. end)
  298. Notify("Tohru GSE "..Version.." ran successfully!")
  299. print("Tohru GSE Version ["..Version.."] | LoadTime  [".. tick() - loadtime .."]")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement