2012-01-26 17:44:37 -05:00
|
|
|
function HandleMOTDCommand( Split, Player )
|
|
|
|
ShowMOTDTo( Player )
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2013-07-06 14:24:33 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2013-07-05 15:56:32 -04:00
|
|
|
function LoadMotd()
|
|
|
|
local File = io.open("motd.txt", "r")
|
2013-07-06 14:24:33 -04:00
|
|
|
-- Check if the file 'motd.txt' exists, else create it.
|
2013-07-05 15:56:32 -04:00
|
|
|
if not File then
|
|
|
|
CreateFile = io.open("motd.txt", "w")
|
|
|
|
CreateFile:write("@6Welcome to the MCServer test server!\n@6http://www.mc-server.org/\n@6Type /help for all commands")
|
|
|
|
CreateFile:close()
|
|
|
|
else
|
|
|
|
File:close()
|
|
|
|
end
|
|
|
|
for line in io.lines("motd.txt") do
|
2013-07-06 07:13:29 -04:00
|
|
|
local TempMessage = line
|
2013-07-06 14:24:33 -04:00
|
|
|
-- Do a for loop that goes to each char in the line.
|
2013-07-06 07:13:29 -04:00
|
|
|
for I=1, string.len(TempMessage) do
|
2013-07-06 14:24:33 -04:00
|
|
|
-- If the char is a '@' then check if the next char represents a color.
|
2013-07-06 07:13:29 -04:00
|
|
|
if string.sub(TempMessage, I, I) == "@" then
|
2013-07-06 14:24:33 -04:00
|
|
|
local Char = string.sub(TempMessage, I + 1, I + 1)
|
|
|
|
local Color = ReturnColorFromChar(TempMessage, Char)
|
|
|
|
-- If the next char represented a color then put the color in the string.
|
|
|
|
if (Color ~= nil) then
|
2013-07-06 07:13:29 -04:00
|
|
|
TempMessage = string.gsub(TempMessage, "@" .. Char, Color)
|
2013-07-05 15:56:32 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-07-06 14:24:33 -04:00
|
|
|
-- Add the message to the list of messages.
|
2013-07-05 15:56:32 -04:00
|
|
|
Messages[#Messages + 1] = TempMessage
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-07-06 14:24:33 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2012-01-26 17:44:37 -05:00
|
|
|
function ShowMOTDTo( Player )
|
2013-07-05 15:56:32 -04:00
|
|
|
for I=1, #Messages do
|
|
|
|
Player:SendMessage(Messages[I])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-07-06 14:24:33 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function ReturnColorFromChar( Split, char )
|
|
|
|
-- Check if the char represents a color. Else return nil.
|
2013-07-06 09:30:10 -04:00
|
|
|
if char == "0" then
|
2013-07-06 14:24:33 -04:00
|
|
|
return cChatColor.Black
|
2013-07-06 09:30:10 -04:00
|
|
|
elseif char == "1" then
|
2013-07-06 14:24:33 -04:00
|
|
|
return cChatColor.Navy
|
2013-07-06 09:30:10 -04:00
|
|
|
elseif char == "2" then
|
2013-07-06 14:24:33 -04:00
|
|
|
return cChatColor.Green
|
2013-07-06 09:30:10 -04:00
|
|
|
elseif char == "3" then
|
2013-07-06 14:24:33 -04:00
|
|
|
return cChatColor.Blue
|
2013-07-06 09:30:10 -04:00
|
|
|
elseif char == "4" then
|
2013-07-06 14:24:33 -04:00
|
|
|
return cChatColor.Red
|
2013-07-06 09:30:10 -04:00
|
|
|
elseif char == "5" then
|
2013-07-06 14:24:33 -04:00
|
|
|
return cChatColor.Purple
|
2013-07-06 09:30:10 -04:00
|
|
|
elseif char == "6" then
|
2013-07-06 14:24:33 -04:00
|
|
|
return cChatColor.Gold
|
2013-07-06 09:30:10 -04:00
|
|
|
elseif char == "7" then
|
2013-07-06 14:24:33 -04:00
|
|
|
return cChatColor.LightGray
|
2013-07-06 09:30:10 -04:00
|
|
|
elseif char == "8" then
|
2013-07-06 14:24:33 -04:00
|
|
|
return cChatColor.Gray
|
2013-07-06 09:30:10 -04:00
|
|
|
elseif char == "9" then
|
2013-07-06 14:24:33 -04:00
|
|
|
return cChatColor.DarkPurple
|
2013-07-06 09:30:10 -04:00
|
|
|
elseif char == "a" then
|
2013-07-06 14:24:33 -04:00
|
|
|
return cChatColor.LightGreen
|
2013-07-06 09:30:10 -04:00
|
|
|
elseif char == "b" then
|
2013-07-06 14:24:33 -04:00
|
|
|
return cChatColor.LightBlue
|
2013-07-06 09:30:10 -04:00
|
|
|
elseif char == "c" then
|
2013-07-06 14:24:33 -04:00
|
|
|
return cChatColor.Rose
|
2013-07-06 09:30:10 -04:00
|
|
|
elseif char == "d" then
|
2013-07-06 14:24:33 -04:00
|
|
|
return cChatColor.LightPurple
|
2013-07-06 09:30:10 -04:00
|
|
|
elseif char == "e" then
|
2013-07-06 14:24:33 -04:00
|
|
|
return cChatColor.Yellow
|
2013-07-06 09:30:10 -04:00
|
|
|
elseif char == "f" then
|
2013-07-06 14:24:33 -04:00
|
|
|
return cChatColor.White
|
|
|
|
elseif char == "k" then
|
|
|
|
return cChatColor.Random
|
|
|
|
elseif char == "l" then
|
|
|
|
return cChatColor.Bold
|
|
|
|
elseif char == "m" then
|
|
|
|
return cChatColor.Strikethrough
|
|
|
|
elseif char == "n" then
|
|
|
|
return cChatColor.Underlined
|
|
|
|
elseif char == "o" then
|
|
|
|
return cChatColor.Italic
|
|
|
|
elseif char == "r" then
|
|
|
|
return cChatColor.Plain
|
2013-07-05 15:56:32 -04:00
|
|
|
end
|
2012-01-26 17:44:37 -05:00
|
|
|
end
|