1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
function HandleMOTDCommand( Split, Player )
ShowMOTDTo( Player )
return true
end
function LoadMotd()
local File = io.open("motd.txt", "r")
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
local TempMessage = line
for I=1, string.len(TempMessage) do
if string.sub(TempMessage, I, I) == "@" then
local Color, Char = ReturnColor(TempMessage, I + 1)
if (Color ~= "") then
TempMessage = string.gsub(TempMessage, "@" .. Char, Color)
end
end
end
Messages[#Messages + 1] = TempMessage
end
end
function ShowMOTDTo( Player )
for I=1, #Messages do
Player:SendMessage(Messages[I])
end
end
function ReturnColor( Split, char )
if string.sub( Split, char, char ) == "0" then
return cChatColor.Black, 0
elseif string.sub( Split, char, char ) == "1" then
return cChatColor.Navy, 1
elseif string.sub( Split, char, char ) == "2" then
return cChatColor.Green, 2
elseif string.sub( Split, char, char ) == "3" then
return cChatColor.Blue, 3
elseif string.sub( Split, char, char ) == "4" then
return cChatColor.Red, 4
elseif string.sub( Split, char, char ) == "5" then
return cChatColor.Purple, 5
elseif string.sub( Split, char, char ) == "6" then
return cChatColor.Gold, 6
elseif string.sub( Split, char, char ) == "7" then
return cChatColor.LightGray, 7
elseif string.sub( Split, char, char ) == "8" then
return cChatColor.Gray, 8
elseif string.sub( Split, char, char ) == "9" then
return cChatColor.DarkPurple, 9
elseif string.sub( Split, char, char ) == "a" then
return cChatColor.LightGreen, "a"
elseif string.sub( Split, char, char ) == "b" then
return cChatColor.LightBlue, "b"
elseif string.sub( Split, char, char ) == "c" then
return cChatColor.Rose, "c"
elseif string.sub( Split, char, char ) == "d" then
return cChatColor.LightPurple, "d"
elseif string.sub( Split, char, char ) == "e" then
return cChatColor.Yellow, "e"
elseif string.sub( Split, char, char ) == "f" then
return cChatColor.White, "f"
else
return ""
end
end
|