-- Left-click on the minimap teleports gamemasters and above. -- The client (gamelib/ui/uiminimap.lua) only sends the request after the -- server says on login that this player is allowed to use it. local OPCODE_ADMIN_MINIMAP_TELEPORT = 215 local function canUseMinimapTeleport(player) return player:getGroup():getAccess() end local loginEvent = CreatureEvent("AdminMinimapTeleportLogin") function loginEvent.onLogin(player) player:registerEvent("AdminMinimapTeleportOpcode") player:sendExtendedOpcode(OPCODE_ADMIN_MINIMAP_TELEPORT, json.encode({ action = "access", enabled = canUseMinimapTeleport(player) })) return true end loginEvent:register() local opcodeEvent = CreatureEvent("AdminMinimapTeleportOpcode") function opcodeEvent.onExtendedOpcode(player, opcode, buffer) if opcode ~= OPCODE_ADMIN_MINIMAP_TELEPORT then return true end if not canUseMinimapTeleport(player) then return true end local ok, data = pcall(json.decode, buffer) if not ok or type(data) ~= "table" or data.action ~= "teleport" or type(data.position) ~= "table" then return true end local x = tonumber(data.position.x) local y = tonumber(data.position.y) local z = tonumber(data.position.z) if not x or not y or not z then return true end local destination = Position(math.floor(x), math.floor(y), math.floor(z)) if not Tile(destination) then player:sendCancelMessage("There is no tile there.") return true end local ghost = player:isInGhostMode() if not ghost then player:getPosition():sendMagicEffect(CONST_ME_TELEPORT) end player:teleportTo(destination) if not ghost then destination:sendMagicEffect(CONST_ME_TELEPORT) end return true end opcodeEvent:register()