User:Anaminus/Script:Messages: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
m
no edit summary
>Anaminus
No edit summary
 
>Anaminus
mNo edit summary
Line 1: Line 1:
<pre>
<pre>
-- Anaminus
speakers = {"Anaminus"}
 
print("Chat: Messages")
 
 
permission = {"Anaminus"}


function check(name)
function check(name)
if table.maxn(permission) == 0 then print("No admins") return true end --Remove all names from permission to allow all players to use command.
for i,v in pairs(speakers) do
for i = 1,#permission do
if (string.upper(name) == string.upper(v)) then return true end
if (string.upper(name) == string.upper(permission[i].Name)) then return true end
end
end
return false
return false
end
end


function DebugMessages()
function debug(p)
local workspace = game.Workspace:GetChildren()
for i,v in pairs(p:GetChildren()) do
for i = 1,#workspace do
if v.className == "Message" or v.className == "Hint" then
if workspace[i].className == "Message" or workspace[i].className == "Hint" then
v:Remove()
workspace[i].Parent = nil
else
debug(v)
end
end
end
end
end


local player = game.Players:GetChildren()
game.Players.PlayerAdded:connect(function(newPlayer)
for i = 1,#player do
newPlayer.Chatted:connect(function(msg)
local child = player[i]:GetChildren()
local source,msg = string.lower(newPlayer.Name),string.lower(msg)
for p = 1,#child do
if not check(source) then return end
if child[p].className == "Message" or child[p].className == "Hint" then
if msg:sub(1,3) == "/m " then
child[p].Parent = nil
local message = Instance.new("Message")
message.Text = msg:sub(4)
message.Parent = workspace
wait(5)
message.Parent = nil
end
if msg:sub(1,3) == "/h " then
local hint = workspace:FindFirstChild("Hint")
if hint == nil then
hint = Instance.new("Hint")
hint.Parent = workspace
end
hint.Text = msg:sub(4)
end
if msg:sub(1,3) == "/rh" then
local hint = workspace:FindFirstChild("Hint")
if hint ~= nil then
hint:Remove()
end
end
end
end
end
if msg:sub(1,3) == "/dm" then
end
debug(game)
 
end
function DisplayMessage(text, Wait, parent)
end)
local message = Instance.new("Message")
end)</pre>
message.Text = text
message.Name = "Message"
message.Parent = parent
wait(Wait)
message.Parent = nil
end
 
function DisplayHint(text, parent)
local hint = parent:FindFirstChild("Hint")
if hint == nil then
hint = Instance.new("Hint")
hint.Name = "Hint"
hint.Parent = parent
end
hint.Text = text
end
 
function RemoveHint(parent)
local hint = parent:FindFirstChild("Hint")
if hint ~= nil then
hint.Parent = nil
end
end
 
function onChatted(msg, recipient, speaker)
 
-- convert to all lower case
local source = string.lower(speaker.Name)
msg = string.lower(msg)
 
-- Below is only for Admins
if not check(source) then return end
if string.sub(norm,1,3)=="/m " then --Create a game message
DisplayMessage(string.sub(norm,4),5, game.Workspace)
end
 
if string.sub(norm,1,3)=="/h " then --Create a game hint
DisplayHint(string.sub(norm,4), game.Workspace)
end
 
if string.sub(norm,1,3)=="/rh" then --Remove a game hint
RemoveHint(game.Workspace)
end
 
if string.sub(norm,1,3)=="/dm" then --Debugs all messages and hints in players and workspace
DebugMessages()
end
end
 
function onPlayerEntered(newPlayer)
newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end)
end
 
game.Players.ChildAdded:connect(onPlayerEntered)
</pre>
Anonymous user

Navigation menu