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
pl = {}
for id = 1,32 do
pl[id] = {}
pl[id] =
{
	tpask=false,
	tprequest=false,
	targetID=0,
	savetargetID=0,
	tptimer=0,
}
end
addhook("say","_say")
function _say(id,txt)
	if string.lower(string.sub(txt,1,4))=="!tpr" then
	local target = string.sub(txt,6); local tid =string.match(""..target.."","%d+")
		if tonumber(tid)~=id then
			if tonumber(tid)>=1 and tonumber(tid)<=32 then
				if player(tonumber(tid),"exists")==true then
					if pl[id].tpask==false and pl[id].tprequest==false then
						if pl[tonumber(tid)].tprequest==false then
						pl[id].tpask=true; pl[tonumber(tid)].tprequest=true; pl[tonumber(tid)].targetID=id; pl[id].savetargetID=tonumber(tid)
						msg2(id,"\169197185101You sent teleport request to "..player(tonumber(tid),"name")..".")
						msg2(tonumber(tid),"\169220223074 "..player(id,"name").." has requested to you to teleport to you")
						msg2(tonumber(tid),"\169172225072 To accept, type !tpaccept")
						msg2(tonumber(tid),"\169224141073 To deny, type !tpdeny")
						pl[id].tptimer=15
						else
						msg2(id,"\169235040040Target player already got request from someone else! try later")
						end
					else
					msg2(id,"\169235040040You sent request to other player already!")
					end
				else
				msg2(id,"\169235040040Player ID : "..tonumber(tid).." does not exist!")
				end
			else
			msg2(id,"\169235040040The Number is invalid!")
			end
		else
		msg2(id,"\169235040040You can't send request yourself!")
		end
	return 1
	end
	if string.lower(string.sub(txt,1,9))=="!tpaccept" then
		if pl[id].tprequest==true then
		local pidX = player(id,"x")
		local pidY = player(id,"y")
		parse("setpos "..pl[id].targetID.." "..pidX.." "..pidY)
		msg2(pl[id].targetID,"\169040235040"..player(id,"name").." accepted your request.")
		msg2(id,"\169040235040"..player(id,"name").." Successfully teleported to you.")
		pl[pl[id].targetID].tpask=false; pl[id].tprequest=false; pl[id].tptimer=0
		else
		msg2(id,"\169235040040No request has found.")
		end
	return 1
	end
	if string.lower(string.sub(txt,1,7))=="!tpdeny" then
		if pl[id].tprequest==true then
		msg2(pl[id].targetID,"\169235040040"..player(id,"name").." denied your request.")
		pl[pl[id].targetID].tpask=false; pl[id].tprequest=false; pl[id].tptimer=0
		else
		msg2(id,"\169235040040No request has found.")
		end
	return 1
	end
end
addhook("second","_second")
function _second()
	for _,id in ipairs(player(0,"table")) do
		if pl[id].tptimer>0 and pl[id].tpask==true then
		pl[id].tptimer=pl[id].tptimer-1
			if pl[id].tptimer==0 then
			local tid = pl[id].savetargetID
			pl[id].tpask=false; pl[tonumber(tid)].tprequest=false;
			msg2(tonumber(tid),"Request has canceled. ( No response )")
			msg2(id,"Request has canceled. ( No response )")
			end
		end
	end
end