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
--[[
Password for doors - lock doors on your map!
By Avobolt (USGN#88318)
]]--
function Array(m, v)
local T = {}
for i = 1, m do
T[i] = v
end
return T
end
AnglePosition = function(rot, x, y, factor)
if rot < -90 then rot = rot + 360 end
local angle = math.rad(math.abs(rot + 90)) - math.pi
local x = x + (math.cos(angle) * factor)
local y = y + (math.sin(angle) * factor)
return x, y
end
pkl = {}
pkl.Comb = Array(32, { "" , "", {0, 0} } ) -- [ 1 ] - password, [ 2 ] - inserted password, [3] - position
pkl.Chars = {"1","2","3","4","5","6","7","8","9"} -- up to 9 chars, I was too lazy to unclude inf menus
addhook("use","pkl.HookUse")
pkl.HookUse = function(id)
local x, y = AnglePosition(player(id, "rot"), player(id, "x"), player(id, "y"), 32)
x, y = math.floor(x/32), math.floor(y/32)
local name = entity(x, y, "name")
if tile(x,y, "entity") and type(entity(x, y, "name")) == "string" and entity(x, y, "name"):sub(1,5) == "lock:" then
local name = entity(x, y, "name")
if entity(x, y, "state") == false then
if #name <= 5 then return end
pkl.Comb[id][1] = name:sub(6)
pkl.Comb[id][2] = ""
pkl.Comb[id][3] = {x, y}
pkl.OpenMenu(id)
else
parse("triggerposition "..x.." "..y)
end
end
end
pkl.OpenMenu = function(id, step)
if not step then step = 1 end
local x, y = unpack(pkl.Comb[id][3])
if entity(x, y, "state") == false then
menu(id, "Lock - step "..step..","..table.concat(pkl.Chars, ","))
end
end
addhook("menu", "pkl.HookMenu")
pkl.HookMenu = function(id,title,b)
if title:sub(1, 12) == "Lock - step " then
if b == "x" or b == 0 then return end
local step = tonumber(title:sub(13))
local ch = pkl.Chars[b]
pkl.Comb[id][2] = pkl.Comb[id][2]..ch
if #pkl.Comb[id][1] == #pkl.Comb[id][2] then
parse("triggerposition "..pkl.Comb[id][3][1].." "..pkl.Comb[id][3][2])
else
if pkl.Comb[id][2] == pkl.Comb[id][1]:sub(1, #pkl.Comb[id][2]) then
parse("sv_sound2 "..id.."\"wpn_select.wav\"")
pkl.OpenMenu(id, step + 1)
else
parse("sv_sound2 "..id.."\"wpn_denyselect.wav\"")
			pkl.OpenMenu(id)
end
end
end
end