Ü Pendragon
Member
- Joined
- Apr 10, 2017
- Messages
- 51
- Reaction score
- 6
Hi I've been looking for a way to lock mc using for example the Oberon lever. The only thing I managed to do was block it globally. In other words, if the player has an MC in trainers, he will not be able to do oberon. The correct way would be to just check if there is mc on the tiles
Code oberon
Part that I take from another code to try to do the mc lock
Can someone help me?
Code oberon
Lua:
bossConfig = {
[34000] = { -- ActionID
requiredLevel = 150,
minPlayersRequired = 1,
boss = "Grand Master Oberon",
bossGlobalStorage = 35000,
playerStorage = 36000,
teleportPosition = Position(33364, 31323, 9),
centerRoomPosition = Position(33364, 31318, 9),
northRange = 6, eastRange = 6, southRange = 9, westRange = 6,
exit = Position(33364, 31342, 9),
bossPosition = Position(33364, 31319, 9),
time = 5,
playerPositions = {
[1] = Position(33362, 31344, 9),
[2] = Position(33363, 31344, 9),
[3] = Position(33364, 31344, 9),
[4] = Position(33365, 31344, 9),
[5] = Position(33366, 31344, 9)
}
}
}
local function resetBoss(bossConfig, bossId)
local monster = Monster(bossId)
if monster then
monster:remove()
end
local spectators = Game.getSpectators(bossConfig.centerRoomPosition, false, true, bossConfig.westRange, bossConfig.eastRange, bossConfig.northRange, bossConfig.southRange)
for i = 1, #spectators do
spectators[i]:teleportTo(bossConfig.exit)
end
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item.itemid == 1946 then
local bossConfig = bossConfig[item:getActionId()]
if not bossConfig then
return false
end
if (getGlobalStorageValue(bossConfig.bossGlobalStorage) > 0) then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "There is already a team inside. Please wait 5 minutes.")
return true
end
local AccForIp = 1
local mc = 0
for _, check in ipairs(Game.getPlayers()) do
if player:getIp() == check:getIp() then
mc = mc + 1
if mc > AccForIp then
player:sendTextMessage(MESSAGE_STATUS_SMALL, ("Multiclient not allowed"))
return false
end
end
end
local errorMsg
local rPlayers = {}
for index, ipos in pairs(bossConfig.playerPositions) do
local playerTile = Tile(ipos):getTopCreature()
if playerTile then
if playerTile:isPlayer() then
if playerTile:getLevel() >= bossConfig.requiredLevel then
if playerTile:getStorageValue(bossConfig.playerStorage) <= os.time() then
table.insert(rPlayers, playerTile:getId())
else
errorMsg = 'One or more players have already entered in the last 12 hours.'
end
else
errorMsg = 'All the players need to be level '.. bossConfig.requiredLevel ..' or higher.'
end
end
end
end
if (#rPlayers >= bossConfig.minPlayersRequired) then
for _, pid in pairs(rPlayers) do
local rplayer = Player(pid)
if rplayer:isPlayer() then
rplayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, ('You have %o minutes before you get kicked out.'):format(bossConfig.time))
bossConfig.playerPositions[_]:sendMagicEffect(CONST_ME_POFF)
rplayer:teleportTo(bossConfig.teleportPosition)
rplayer:setStorageValue(bossConfig.playerStorage, os.time() + (12 * 60 * 60))
bossConfig.teleportPosition:sendMagicEffect(CONST_ME_ENERGYAREA)
rplayer:setDirection(DIRECTION_NORTH)
end
end
setGlobalStorageValue(bossConfig.bossGlobalStorage, 1)
addEvent(setGlobalStorageValue, bossConfig.time * 60 * 1000, bossConfig.bossGlobalStorage, 0)
local monster = Game.createMonster(bossConfig.boss, bossConfig.bossPosition)
addEvent(resetBoss, bossConfig.time * 60 * 1000, bossConfig, monster and monster.uid or 0)
else
if not errorMsg then
player:sendTextMessage(MESSAGE_STATUS_SMALL, ("You need %u players."):format(bossConfig.minPlayersRequired))
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, errorMsg)
end
return true
end
end
item:transform(item.itemid == 1946 and 1945 or 1946)
return true
end
Part that I take from another code to try to do the mc lock
Lua:
local AccForIp = 1
local mc = 0
for _, check in ipairs(Game.getPlayers()) do
if player:getIp() == check:getIp() then
mc = mc + 1
if mc > AccForIp then
player:sendTextMessage(MESSAGE_STATUS_SMALL, ("Multiclient not allowed"))
return false
end
end
end
Can someone help me?