-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunctions.lua
More file actions
177 lines (158 loc) · 5.81 KB
/
functions.lua
File metadata and controls
177 lines (158 loc) · 5.81 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
function LoadSettings(Path)
SettingsIni = cIniFile()
SettingsIni:ReadFile(Path)
ShowAdminBreach = SettingsIni:GetValueSetB("General", "ShowAdminBreach", false)
if ShowAdminBreach == nil then
return true
end
end
function isAtChest(BlockX, BlockY, BlockZ, World)
local sides = getAllSideCoords(BlockX, BlockY, BlockZ)
local i
for key, value in pairs(sides) do
if World:GetBlock(value['x'], value['y'], value['z']) == 54 then
i = World:GetBlockMeta(BlockX, BlockY, BlockZ) + value['f']
if World:GetBlockMeta(BlockX, BlockY, BlockZ) + value['f'] == 9 or 5 then
return true
end
end
end
return false
end
function getChestFromSign(BlockX, BlockY, BlockZ, World)
local sides = getAllSideCoords(BlockX, BlockY, BlockZ)
local i
local chest = {}
for key, value in pairs(sides) do
if World:GetBlock(value['x'], value['y'], value['z']) == 54 then
i = World:GetBlockMeta(BlockX, BlockY, BlockZ) + value['f']
if World:GetBlockMeta(BlockX, BlockY, BlockZ) + value['f'] == 9 or 5 then
chest[1] = { x = BlockX, y = BlockY, z = BlockZ }
print("test")
print(chest[1]['x'], chest[1]['y'], chest[1]['z'])
return chest
end
end
end
end
function getSigns(BlockX, BlockY, BlockZ, World)
-- alle Schilder des Komplexes
-- signs = x y z f(Ausrichtung/Meta)
local signs = {}
local i = 1
local sides = {}
local chests = getChests(BlockX, BlockY, BlockZ, World)
local signLines = {}
for key, value in pairs(chests) do
sides = getAllSideCoords(value['x'], value['y'], value['z'])
for key, value in pairs(sides) do
if World:GetBlock(value['x'], value['y'], value['z']) == 68 and
World:GetBlockMeta(value['x'], value['y'], value['z']) == value['f'] then
signLines = { World:GetSignLines(value['x'], value['y'], value['z']) }
if signLines[2] == "[P]" or signLines[2] == "[Private]" then
print("getSigns")
print(value['x'], value['y'], value['z'])
signs[i] = { x = value['x'], y = value['y'], z = value['z'], f = World:GetBlockMeta(value['x'], value['y'], value['z']) }
i = i + 1
end
end
end
end
return signs
end
function getChests(BlockX, BlockY, BlockZ, World)
-- alle Truhen des Komplexes
local chests = {}
-- chests = x y z
local sides = {}
if World:GetBlock(BlockX, BlockY, BlockZ) == 54 then -- Block ist Truhe
chests[1] = { x = BlockX, y = BlockY, z = BlockZ }
else -- Block ist Schild
chests = getChestFromSign(BlockX, BlockY, BlockZ, World)
if chests[1] ~= nil then print(chests[1]['x'], chests[1]['y'], chests[1]['z']) end
-- sides = getAllSideCoords(BlockX, BlockY, BlockZ)
-- for key, value in pairs(sides) do
-- if World:GetBlock(value['x'], value['y'], value['z']) == 54 then
-- chests[1] = { x = value['x'], y = value['y'], z = value['z'] }
-- end
-- end
end
sides = getAllSideCoords(chests[1]['x'], chests[1]['y'], chests[1]['z']) -- Zweite Truhe
for key, value in pairs(sides) do
if World:GetBlock(value['x'], value['y'], value['z']) == 54 then
-- if value['x'] ~= chests[1]['x'] or value['y'] ~= chests[1]['y'] or value['z'] ~= chests[1]['z'] then
chests[2] = { x = value['x'], y = value['y'], z = value['z'] }
-- end
end
end
print("getChests")
if chests[1] ~= nil then print(chests[1]['x'], chests[1]['y'], chests[1]['z']) end
if chests[2] ~= nil then print(chests[2]['x'], chests[2]['y'], chests[2]['z']) end
return chests
end
function getAllSideCoords(BlockX, BlockY, BlockZ)
local sides = {}
sides['+x'] = { x = BlockX + 1, y = BlockY, z = BlockZ, f = 5, s = '+x' }
sides['-x'] = { x = BlockX - 1, y = BlockY, z = BlockZ, f = 4, s = '-x' }
sides['+z'] = { x = BlockX, y = BlockY, z = BlockZ + 1, f = 3, s = '+z' }
sides['-z'] = { x = BlockX, y = BlockY, z = BlockZ - 1, f = 2, s = '-z' }
-- print(sides['-x']['x'], sides['-x']['y'], sides['-x']['z'], sides['-x']['f'], sides['-x']['s'])
return sides;
end
-- 4 Anwendungsfälle: Schild wird gesetzt, Schild wird zerstört, Truhe wird benutzt, Truhe wird zerstört
-- REMINDER: Damit Owner immer gleich force: Line2 = User + destroy: nur von User in Line2
function PlayerHasBlockAccess(Player, BlockX, BlockY, BlockZ, World, PermissionType)
local signs = getSigns(BlockX, BlockY, BlockZ, World)
if signs[1] == nil then
return true
end
local sign = {}
for key, value in pairs(signs) do
sign = { World:GetSignLines(value['x'], value['y'], value['z']) }
if PermissionType == 'Owner' then
if CheckSignOwner(sign, Player) then
return true
end
elseif PermissionType == 'User' then
if CheckSignPermission(sign, Player) then
return true
end
end
end
return false
end
function CheckProtectedSign(BlockX, BlockY, BlockZ, World)
if World:GetBlock(BlockX, BlockY, BlockZ) == 68 then
local Read, Line1 = World:GetSignLines(BlockX, BlockY, BlockZ)
if Line1 == "[P]" or Line1 == "[Private]" then
return true
end
end
return false
end
function CheckSignOwner(Sign, Player)
local playerName = Player:GetName();
if (Sign[2] == "[P]" or Sign[2] == "[Private]") then
if Sign[3] == playerName then
return true
end
if Player:HasPermission("KiwiLock.Bypass") then
cRoot:Get():BroadcastChat(cChatColor.Rose .. "Player " .. Player:GetName() .. " bypassed a block owned by somebody else")
return true
end
return false;
end
end
function CheckSignPermission(Sign, Player)
local playerName = Player:GetName();
if (Sign[2] == "[P]" or Sign[2] == "[Private]") then
if Sign[3] == playerName or Sign[4] == playerName or Sign[5] == playerName then
return true
end
if Player:HasPermission("KiwiLock.Bypass") then
cRoot:Get():BroadcastChat(cChatColor.Rose .. "Player " .. Player:GetName() .. " bypassed a block owned by somebody else")
return true
end
return false;
end
end