Advertisement
ttyyuu12345

The Working Chatbar

Nov 16th, 2014
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.42 KB | None | 0 0
  1. launchers = {
  2. {["Name"] = "Mobile Mode",["Exec"]=function(player) Update_Interface_Type(player,"Phone") end},
  3. {["Name"] = "Computer Mode",["Exec"]=function(player) Update_Interface_Type(player,"Computer") end},
  4. {["Name"] = "Chat",["Exec"]=function(player) ChatWindow(player) end},
  5. {["Name"] = "Status",["Exec"]=function(player) StatusWindow(player) end},
  6. }
  7. message_history = {}
  8. player_index = {}
  9. Get_Player_Index = function(playe)
  10. local tbl = {}
  11. local num = 0
  12. for i,v in pairs(player_index) do
  13. if v["Player"]==playe.Name then
  14. tbl = v["Chat_Index"]
  15. end
  16. end
  17. return tbl
  18. end
  19. Update_Interface_Type = function(playe,type)
  20. for i,v in pairs(player_index) do
  21. if v["Player"]==playe.Name then
  22. v["DeviceType"] = type
  23. end
  24. end
  25. end
  26. Get_Interface_Type = function(playe)
  27. local type = ""
  28. for i,v in pairs(player_index) do
  29. if v["Player"]==playe.Name then
  30. type = v["DeviceType"]
  31. end
  32. end
  33. return type
  34. end
  35. Update_Player_Index = function(playe,tbl)
  36. for i,v in pairs(player_index) do
  37. if v["Player"]==playe.Name then
  38. v["Chat_Index"]={}
  39. for i=1,#tbl do
  40. table.insert(v["Chat_Index"],tbl[i])
  41. end
  42. end
  43. end
  44. end
  45. CreateWindow = function(player,size,pos,title,par)
  46. local root = nil
  47. local gui=Instance.new("ScreenGui",player.PlayerGui)
  48. gui.Name = "EWindowGui"
  49. local frame=Instance.new("Frame")
  50. if par==nil then
  51. frame.Parent = gui
  52. root = gui
  53. else
  54. frame.Parent = par
  55. root = frame
  56. gui:Remove()
  57. end
  58. frame.BackgroundColor3 = Color3.new ( 141/255, 200/255, 251/255)
  59. frame.Position = pos
  60. frame.Size = size
  61. frame.Active = true
  62. frame.Draggable = true
  63. if Get_Interface_Type(player)=="Phone" then
  64. frame.Size = UDim2.new( 1, 0, 1, 0)
  65. frame.Position = UDim2.new( 0, 0, 0, 0)
  66. frame.Active = false
  67. frame.Draggable = false
  68. end
  69. frame.BackgroundTransparency = 0.4
  70. local tl=Instance.new("TextLabel",frame)
  71. tl.BackgroundTransparency = 1
  72. tl.Position = UDim2.new ( 0, 0, 0, 0)
  73. tl.Size = UDim2.new ( 1, 0, 0, 22)
  74. tl.FontSize = "Size14"
  75. tl.Text = title
  76. tl.TextColor3 = Color3.new ( 0, 0, 0)
  77. tl.TextXAlignment = "Left"
  78. local exit = Instance.new("TextButton",frame)
  79. exit.AutoButtonColor = false
  80. exit.BorderSizePixel = 0
  81. exit.BackgroundColor3 = Color3.new ( 199/255, 80/255, 80/255)
  82. exit.Size = UDim2.new ( 0, 56, 0, 22)
  83. exit.Position = UDim2.new ( 1, -64, 0, 0)
  84. exit.Text = "X"
  85. exit.FontSize = Enum.FontSize.Size18
  86. exit.TextColor3 = Color3.new ( 1, 1, 1)
  87. exit.MouseButton1Click:connect(function()
  88. root:Remove()
  89. end)
  90. local Window_Elements = Instance.new("Frame",frame)
  91. Window_Elements.Size = UDim2.new( 1, -8, 1, -30)
  92. Window_Elements.Position = UDim2.new ( 0, 4, 0, 26)
  93. Window_Elements.BackgroundColor3 = Color3.new(1, 1, 1)
  94. return Window_Elements, root
  95. end
  96. CMessage = function(player,title,text,par)
  97. local frame,sgui = CreateWindow(player,UDim2.new(0,400,0,150),UDim2.new (0.5,-200,0.5,-75),title,par)
  98. local text1 = Instance.new("TextLabel",frame)
  99. text1.BackgroundTransparency = 1
  100. text1.Size = UDim2.new ( 0.9, 0, 0.65, 0)
  101. text1.TextWrapped = true
  102. text1.Position = UDim2.new ( 0, 0, 0, 0)
  103. text1.Text = text
  104. text1.TextColor3 = Color3.new ( 0, 0, 0)
  105. text1.TextXAlignment = Enum.TextXAlignment.Left
  106. text1.TextYAlignment = Enum.TextYAlignment.Top
  107. text1.FontSize = "Size14"
  108. local ok = Instance.new("TextButton",frame)
  109. ok.AutoButtonColor = false
  110. ok.BorderColor3 = Color3.new(41/255, 200/255, 251/255)
  111. ok.BackgroundColor3 = Color3.new ( 1, 1, 1)
  112. ok.Size = UDim2.new ( 0.5, 0, 0.3, 0)
  113. ok.Position = UDim2.new ( 0.25, 0, 0.65, 0)
  114. ok.Text = "OK"
  115. ok.FontSize = Enum.FontSize.Size18
  116. ok.TextColor3 = Color3.new ( 0, 0, 0)
  117. ok.MouseButton1Click:connect(function()
  118. sgui:Remove()
  119. end)
  120. end
  121. ChatWindow = function(player)
  122. local chatele,fullgui=CreateWindow(player,UDim2.new( 0, 400, 0, 250),UDim2.new( 1, -450, 1, -300),"Roblox.Chat")
  123. local update=function()
  124. chatele:ClearAllChildren()
  125. for i,v in pairs(message_history) do
  126. local tl=Instance.new("TextLabel",chatele)
  127. tl.Position = UDim2.new( 0, 0, (#chatele:GetChildren()-1)*.05, 0)
  128. tl.Size = UDim2.new ( 1, 0, 0.05, 0)
  129. tl.BackgroundTransparency = 1
  130. tl.TextXAlignment = "Left"
  131. tl.Text = v["Player"] .. " : " .. v["Message"]
  132. end
  133. end
  134. coroutine.resume(coroutine.create(function()
  135. while wait() do
  136. if Get_Player_Index(player)~=message_history then
  137. update()
  138. Update_Player_Index(player,message_history)
  139. end
  140. end
  141. end))
  142. end
  143. Get_Status = function(player)
  144. local tabl = {}
  145. local hum = player.Character:FindFirstChild("Humanoid")
  146. if hum~=nil then
  147. table.insert(tabl,"Health: " .. hum.Health)
  148. table.insert(tabl,"MaxHealth: " .. hum.MaxHealth)
  149. table.insert(tabl,"WalkSpeed: " .. hum.WalkSpeed)
  150. end
  151. table.insert(tabl,"AccountAge: " .. player.AccountAge)
  152. return tabl
  153. end
  154. StatusWindow = function(player)
  155. local statusele,statuswin = CreateWindow(player,UDim2.new( 0, 150, 0, 200),UDim2.new( 0, 20, 1, -300),"State")
  156. local create = function()
  157. statusele:ClearAllChildren()
  158. for i=1,10 do
  159. local tl = Instance.new("TextLabel",statusele)
  160. tl.Size = UDim2.new( 1, 0, 0.1, 0)
  161. tl.Position = UDim2.new( 0, 0, (i-1)*.1, 0)
  162. tl.BackgroundTransparency = 1
  163. tl.Text = ""
  164. tl.TextXAlignment = "Left"
  165. end
  166. end
  167. local update = function()
  168. local tbl = Get_Status(player)
  169. local chil = statusele:GetChildren()
  170. for i=1,#tbl do
  171. chil[i].Text = tbl[i]
  172. end
  173. if #chil>=#tbl+1 then
  174. for i=#tbl+1,#chil do
  175. chil[i].Text = ""
  176. end
  177. end
  178. end
  179. create()
  180. coroutine.resume(coroutine.create(function()
  181. while wait() do
  182. update()
  183. end
  184. end))
  185. end
  186. function Update_History(playername, message)
  187. if #message_history>=20 then
  188. table.remove(message_history,1)
  189. end
  190. table.insert(message_history,{["Player"]=playername,["Message"] = message})
  191. end
  192. function Chat(speaker, message)
  193. message = message
  194. if string.sub((message),1,3)=="/e " then
  195. message = "[Roblox Emotion]"
  196. end
  197. Update_History(speaker.Name, message)
  198. end
  199. function Launcher(player)
  200. local gui = Instance.new("ScreenGui",player.PlayerGui)
  201. local ib = Instance.new("ImageButton",gui)
  202. ib.Size = UDim2.new( 0, 50, 0, 50)
  203. ib.Position = UDim2.new ( 1, -50, 1, -50)
  204. ib.Image = "http://www.roblox.com/asset/?id=108116980"
  205. ib.MouseButton1Click:connect(function()
  206. local buttonhold,corelaunch = CreateWindow(player,UDim2.new( 0, 400, 0, 300),UDim2.new(0,100,0,100),"Select action",gui)
  207. local itemnum = #launchers
  208. for i,v in pairs(launchers) do
  209. local tb = Instance.new("TextButton",buttonhold)
  210. tb.Size = UDim2.new(1, 0, 1/itemnum, 0)
  211. tb.BorderSizePixel = 0
  212. tb.Position = UDim2.new(0, 0,(i-1)*(1/itemnum), 0)
  213. tb.Text = v["Name"]
  214. tb.BackgroundColor3 = Color3.new ( 1, 1, 1)
  215. tb.TextScaled = true
  216. tb.MouseButton1Click:connect(function()
  217. v["Exec"](player)
  218. corelaunch:Remove()
  219. end)
  220. end
  221. end)
  222. end
  223. function OnEnter(player,need)
  224. player.Chatted:connect(function(msg) Chat(player, msg) end)
  225. if need==true then
  226. Launcher(player)
  227. end
  228. table.insert(player_index,{["Player"]=player.Name,["DeviceType"]="Computer",["Chat_Index"]={}})
  229. player.CharacterAdded:connect(function(ch) Launcher(player) end)
  230. end
  231. game.Players.PlayerAdded:connect(function(pl) OnEnter(pl,false) Update_History("[System]",pl.Name .. " has entered the game") end)
  232. plsr = game.Players:GetChildren()
  233. for i=1,#plsr do
  234. OnEnter(plsr[i],true)
  235. end
  236. game.Players.PlayerRemoving:connect(function(player)
  237. for i,v in pairs(player_index) do
  238. if v["Player"]==player.Name then
  239. table.remove(player_index,i)
  240. end
  241. end
  242. Update_History("[System]",player.Name .. " has left the game")
  243. end)
  244. _G.Fetch = function(player)
  245. for i,v in pairs(message_history) do
  246. print(v["Player"] .. " : " .. v["Message"])
  247. end
  248. for i,v in pairs(Get_Player_Index(player)) do
  249. print(v["Player"] .. " : " .. v["Message"])
  250. end
  251. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement