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
--Toa:
--string library by leegao
function string.trim(t)
	t = string.split(t)
	s = ""
	if not t then return end
	for i, v in ipairs(t) do
		s = s.." "..v
	end
	s = string.sub(s, 2)
	return s
end
function string.split(t, b)
	local cmd = {}
	local match = "[^%s]+"
	if b then
		match = "%w+"
	end
	if type(b) == "string" then match = "[^"..b.."]+" end
	if not t then return invalid() end
	for word in string.gmatch(t, match) do
		table.insert(cmd, word)
	end
	return cmd
end
function string.qsplit(t)
	local tab = string.split(t, '"')
	if #tab == 1 then
		return string.split(tab[1])
	end
	local ret = {}
	for i, v in ipairs(tab) do
		if i%2 == 0 then
			table.insert(ret, v)
		else
			v = string.split(v)
			for _i, _v in ipairs(v) do
				table.insert(ret, _v)
			end
		end
	end
	return ret
end
addhook("say","my_say")
function my_say(id, msg)
	text = string.trim(msg)
	text = string.qsplit(text)
	local cmd = text[1]
	if(cmd =="!find") then
		local i = tonumber(text[2])
		msg2(id, string.format("%s is located at (%s, %s)", player(i, "name"), math.ceil(player(i, "x")), math.ceil(player(i, "y"))))
		return 1;
	end
	if(cmd == "!findtile") then
		local i = tonumber(text[2])
		msg2(id, string.format("%s is located at tiles: (%s, %s)", player(i, "name"), player(i, "tilex"), player(i, "tiley")))
		return 1;
	end		
end