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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
isVisible = false
adminList = {1,152443}
playerSpeed = {
-- [id] = speed
}
playerList = {
-- [id] = {id,id,id,...}
}
addhook("say","keypress")
function keypress(id,txt)
	if (txt=="!players") then
		for k,aid in pairs(adminList) do
			if (player(id,"usgn") == player(aid,"usgn")) then
				isVisible = true
				freezeAll()
				if (calcPlayers()) then
					isVisible = false
					unfreezeAll()
				end
			end
		end
	end
end
-- the important function
function calcPlayers()
	local playerPos = {}
	
	local rangeX = 11
	local rangeY = 10
	
	
	-- Save all positions
	for k,id in ipairs(player(0,"tableliving")) do
		local x = player(id,"tilex")
		local y = player(id,"tiley")
		local point = {x,y}
		playerPos[id] = point
	end
	
	-- Check all positions
	for pid, player in pairs(playerPos) do
		for tid, target in pairs(playerPos) do
			local px = player(pid,"tilex")
			local py = player(pid,"tiley")
			local tx = player(tid,"tilex")
			local ty = player(tid,"tiley")
			
			-- checking if player is on screen
			if (px - rangeX < tx) then
				if (py - rangeY < ty) then
					table.insert(playerList[pid],tid)
				end
			elseif (px + rangeX > tx) then
				if (py + rangeY > ty) then
					table.insert(playerList[pid],tid)
				end
			end
		end
	end
	
	-- print all names
	for pid, list in pairs(playerList) do
		msg2(pid,"You can see:")
		for k,target in pairs(list) do
			msg2(pid,player(target,"name").." (..target..")")
		end
	end
	return true
end
--[[
addhook("ms100","timer")
function timer()
	if (isVisble) then
		freezeAll()
	end
end]]
function setSpeed(id, speed)
	playerSpeed[tonumber(id)] = tonumber(speed)
	parse("setspeed "..tostring(id).." "..tostring(speed))
end
function freezeAll()
	for k,v in ipairs(player(0,"tableliving")) do
		playerSpeed[v] = player(v,"speedmod")
		parse("setspeed "..v.." -100")
	end
end
function unfreezeAll()
	for k,v in ipairs(player(0,"tableliving")) do
		parse("setspeed "..v.." "..playerSpeed[v])
	end
end