Skip to content
3 changes: 2 additions & 1 deletion [admin]/admin2/client/admin_session.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ addEventHandler(
end

aSession = data

aMap.UpdatePermissions()

if (hasPermissionTo("general.adminpanel")) then
outputChatBox("Press 'p' to open your admin panel", player)
bindKey("p", "down", "adminpanel")
Expand Down
27 changes: 22 additions & 5 deletions [admin]/admin2/client/main/admin_map.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
* Original File by lil_Toady
*
**************************************]]
local aMap = {
aMap = {
check = 0,
permission = true,
permission = false,
players = false,
coords = false,
cursor = false,
last = false
last = false,
teleportHeight = 527
}

addEventHandler(
Expand Down Expand Up @@ -88,13 +89,19 @@ addEventHandler(
"onClientClick",
root,
function(button, state, x, y)
if (isPlayerMapVisible() and button == "left") then
if (not aMap.permission) then
return
end
if (isPlayerMapVisible() and button == "left" and state == "down") then
local minX, minY, maxX, maxY = getPlayerMapBoundingBox()
if ((x >= minX and x <= maxX) and (y >= minY and y <= maxY)) then
local msx, msy = -(minX - maxX), -(minY - maxY)
local px = 6000 * ((x - minX) / msx) - 3000
local py = 3000 - 6000 * ((y - minY) / msy)
setElementPosition(localPlayer, px, py, 10)
enginePreloadWorldArea(px, py, aMap.teleportHeight, "collisions")

local pz = getGroundPosition(px, py, aMap.teleportHeight) or 10
triggerServerEvent("aMapWarp", resourceRoot, px, py, pz + 1)
end
end
end
Expand All @@ -104,6 +111,9 @@ bindKey(
"mouse2",
"both",
function(key, state)
if (not aMap.permission) then
return
end
if (isPlayerMapVisible()) then
showCursor(state == "down")
aMap.cursor = state == "down"
Expand All @@ -115,6 +125,9 @@ bindKey(
"num_7",
"down",
function(key, state)
if (not aMap.permission) then
return
end
if (isPlayerMapVisible()) then
aMap.players = not aMap.players
end
Expand All @@ -130,3 +143,7 @@ bindKey(
end
end
)

function aMap.UpdatePermissions()
aMap.permission = hasPermissionTo("general.adminMapWarp")
end
4 changes: 4 additions & 0 deletions [admin]/admin2/conf/ACL.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<right name="general.tab_bans" access="true" />
<right name="general.tab_adminchat" access="true" />
<right name="general.tab_acl" access="true" />
<!-- Utils -->
<right name="general.adminMapWarp" access="true" />
<!--Player Related-->
<right name="command.kick" access="true" />
<right name="command.freeze" access="true" />
Expand Down Expand Up @@ -101,6 +103,8 @@
<right name="general.tab_bans" access="true" />
<right name="general.tab_adminchat" access="true" />
<right name="general.tab_acl" access="false" />
<!-- Utils -->
<right name="general.adminMapWarp" access="true" />
<!--Player Related-->
<right name="command.kick" access="true" />
<right name="command.freeze" access="true" />
Expand Down
21 changes: 20 additions & 1 deletion [admin]/admin2/server/admin_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -435,4 +435,23 @@ addCommandHandler(get("adminChatCommandName"),
triggerEvent("aAdminChat", thePlayer, table.concat(arg, " "))
end
end
)
)

addEvent("aMapWarp", true)
addEventHandler(
"aMapWarp",
resourceRoot,
function(x, y, z)
local pX, pY, pZ = tonumber(x), tonumber(y), tonumber(z)
if not pX or not pY or not pZ then
return
end

if (not hasObjectPermissionTo(client, "general.adminMapWarp", false)) then
return
end

setElementPosition(client, pX, pY, pZ)
outputServerLog("ADMIN: ".. getPlayerName(client) .. " warped to map coordinates: " .. tostring(pX) .. ", " .. tostring(pY) .. ", " .. tostring(pZ))
end
)