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
function btp(id,sx,sy,ex,ey,mode)
local prp
if mode==1 then prp="" elseif mode==2 then prp="tile" end
return (player(id,"exists") and player(id,prp.."x")>sx and player(id,prp.."x")<ex and player(id,prp.."y")>sy and player(id,prp.."y")<ey)
end
dofile("sys/lua/configs.lua")
function initArray(m)
	local array = {}
	for i = 1, m do
		array[i] = 0
	end
return array
end
oldx=initArray(32)
oldy=initArray(32)
timer=initArray(32)
buy=initArray(32)
addhook("minute","addtime")
function addtime()
	for i=1,#house do
		timer[i]=timer[i]-1
	end
end
addhook("move","housecheck")
function housecheck(id,x,y,mode)
	for i=1,#house do
		if btp(id,house[i].x1,house[i].y1,house[i].x2,house[i].y2,2) then
			if (house[i].owner==player(id,"usgn"))==false then
				msg2(id,"Its not your house!")
				parse("setpos "..id.." "..oldx[id].." "..oldy[id])
			elseif (house[i].owner==player(id,"usgn"))==true then
				msg2(id,"Welcome home!")
			end
		else
			oldx[id]=x
			oldy[id]=y
		end
		if btp(id,house[i].infox,house[i].infoy,house[i].infox,house[i].infoy,2) then
			buy[id]=1
			oldx[id]=x
			oldy[id]=y
		else
			buy[id]=0
			oldx[id]=x
			oldy[id]=y
		end
	end
end
addhook("say","housefuncs")
function housefunc(id,text)
	for i=1,#house do
		if (text=="!housebuy") then
			if buy[id]==1 then
				if house[i].owner==nil then
					if player(id,"money")>=house[i].amount then
						house[i].owner=player(id,"usgn")
						msg2(id,"Gratz you purchase that house!")
					else
						msg2(id,"You dont have money to purchase that house!")
					end
				else
					msg2(id,"That house already buyed by someone!")
				end
			end
		end
	end
end