Skip to content

Commit 4423fa5

Browse files
admin2: refine radar teleport functionality (#706)
* admin2: refine radar teleport functionality * admin2: add missed button state check in map teleport * admin2: increased the Z coordinate in enginePreloadWorldArea to handle high points on the map * admin2: Code-style fixes * admin2: Use 527 as Z coord in getGroundPosition * Fix linter warnings * admin2: Fix linter warnings (trailing whitespace) * admin2: removing magic numbers
1 parent b5ccbd8 commit 4423fa5

File tree

4 files changed

+48
-7
lines changed

4 files changed

+48
-7
lines changed

[admin]/admin2/client/admin_session.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ addEventHandler(
2222
end
2323

2424
aSession = data
25-
25+
aMap.UpdatePermissions()
26+
2627
if (hasPermissionTo("general.adminpanel")) then
2728
outputChatBox("Press 'p' to open your admin panel", player)
2829
bindKey("p", "down", "adminpanel")

[admin]/admin2/client/main/admin_map.lua

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
* Original File by lil_Toady
88
*
99
**************************************]]
10-
local aMap = {
10+
aMap = {
1111
check = 0,
12-
permission = true,
12+
permission = false,
1313
players = false,
1414
coords = false,
1515
cursor = false,
16-
last = false
16+
last = false,
17+
teleportHeight = 527
1718
}
1819

1920
addEventHandler(
@@ -88,13 +89,19 @@ addEventHandler(
8889
"onClientClick",
8990
root,
9091
function(button, state, x, y)
91-
if (isPlayerMapVisible() and button == "left") then
92+
if (not aMap.permission) then
93+
return
94+
end
95+
if (isPlayerMapVisible() and button == "left" and state == "down") then
9296
local minX, minY, maxX, maxY = getPlayerMapBoundingBox()
9397
if ((x >= minX and x <= maxX) and (y >= minY and y <= maxY)) then
9498
local msx, msy = -(minX - maxX), -(minY - maxY)
9599
local px = 6000 * ((x - minX) / msx) - 3000
96100
local py = 3000 - 6000 * ((y - minY) / msy)
97-
setElementPosition(localPlayer, px, py, 10)
101+
enginePreloadWorldArea(px, py, aMap.teleportHeight, "collisions")
102+
103+
local pz = getGroundPosition(px, py, aMap.teleportHeight) or 10
104+
triggerServerEvent("aMapWarp", resourceRoot, px, py, pz + 1)
98105
end
99106
end
100107
end
@@ -104,6 +111,9 @@ bindKey(
104111
"mouse2",
105112
"both",
106113
function(key, state)
114+
if (not aMap.permission) then
115+
return
116+
end
107117
if (isPlayerMapVisible()) then
108118
showCursor(state == "down")
109119
aMap.cursor = state == "down"
@@ -115,6 +125,9 @@ bindKey(
115125
"num_7",
116126
"down",
117127
function(key, state)
128+
if (not aMap.permission) then
129+
return
130+
end
118131
if (isPlayerMapVisible()) then
119132
aMap.players = not aMap.players
120133
end
@@ -130,3 +143,7 @@ bindKey(
130143
end
131144
end
132145
)
146+
147+
function aMap.UpdatePermissions()
148+
aMap.permission = hasPermissionTo("general.adminMapWarp")
149+
end

[admin]/admin2/conf/ACL.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
<right name="general.tab_bans" access="true" />
1515
<right name="general.tab_adminchat" access="true" />
1616
<right name="general.tab_acl" access="true" />
17+
<!-- Utils -->
18+
<right name="general.adminMapWarp" access="true" />
1719
<!--Player Related-->
1820
<right name="command.kick" access="true" />
1921
<right name="command.freeze" access="true" />
@@ -101,6 +103,8 @@
101103
<right name="general.tab_bans" access="true" />
102104
<right name="general.tab_adminchat" access="true" />
103105
<right name="general.tab_acl" access="false" />
106+
<!-- Utils -->
107+
<right name="general.adminMapWarp" access="true" />
104108
<!--Player Related-->
105109
<right name="command.kick" access="true" />
106110
<right name="command.freeze" access="true" />

[admin]/admin2/server/admin_server.lua

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,4 +435,23 @@ addCommandHandler(get("adminChatCommandName"),
435435
triggerEvent("aAdminChat", thePlayer, table.concat(arg, " "))
436436
end
437437
end
438-
)
438+
)
439+
440+
addEvent("aMapWarp", true)
441+
addEventHandler(
442+
"aMapWarp",
443+
resourceRoot,
444+
function(x, y, z)
445+
local pX, pY, pZ = tonumber(x), tonumber(y), tonumber(z)
446+
if not pX or not pY or not pZ then
447+
return
448+
end
449+
450+
if (not hasObjectPermissionTo(client, "general.adminMapWarp", false)) then
451+
return
452+
end
453+
454+
setElementPosition(client, pX, pY, pZ)
455+
outputServerLog("ADMIN: ".. getPlayerName(client) .. " warped to map coordinates: " .. tostring(pX) .. ", " .. tostring(pY) .. ", " .. tostring(pZ))
456+
end
457+
)

0 commit comments

Comments
 (0)