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
spawn = { -- Global table
	player = {}; -- Subtable for storing player data
	hooks = { -- Subtable for storing hooked functions
		join = function(id) -- Function for join hook
			-- Setting player's data
			spawn.player[id] = {
				spawnPoint = false;
				-- Spawn point isn't set by deffault
			};
		end;
		say = function(id, text) -- Function for say hook
			if text == '!setspawn' then -- If player says '!setspawn', then...
				spawn.player[id].spawnPoint = {player(id, 'tilex'), player(id, 'tiley')} -- Set player's spawn point
				return 1 -- Command won't be printed to the chat
			end
		end;
		spawn = function(id) -- Function for spawn hook
			if spawn.player[id].spawnPoint then -- If player has set his spawn point, then...
				parse('setspawn '.. id ..' '.. spawn.player[id].spawnPoint[1] ..' '.. spawn.player[id].spawnPoint[2]) -- Teleport him to his spawn point
			end
		end;
	};
}
-- Adding required hooks
addhook('join', 'spawn.hooks.join')
addhook('say', 'spawn.hooks.say')
addhook('spawn', 'spawn.hooks.spawn')