• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

OTClient Error map/script/otclient?

ImaG

Active Member
Joined
Aug 16, 2017
Messages
90
Solutions
1
Reaction score
40
Location
Poland
GitHub
ImaGus01v
Witam, mam problem i nie wiem dlaczego tak się dzieje. Mianowicie skrypt debuguje mapę, od tego zacząłem szukać i usunąłem dźwignię, po czym wszystko było w porządku. Dodam tylko, że wcześniej ten błąd nie występował. Nie wiem, skąd to się wzięło. Jakieś pomysły?
Cxcluyx.png


txKGFI6.png

mSwd9fb.png

LUA:
local config = {
    duration = 30, -- time till reset, in minutes
    level_req = 250, -- minimum level to do quest
    min_players = 4, -- minimum players to join quest
    lever_id = 1945, -- id of lever before pulled
    pulled_id = 1946 -- id of lever after pulled
}

local player_positions = {
    [1] = {fromPos = Position(1015, 1210, 11), toPos = Position(1042, 1217, 11)},
    [2] = {fromPos = Position(1015, 1211, 11), toPos = Position(1042, 1216, 11)},
    [3] = {fromPos = Position(1015, 1212, 11), toPos = Position(1042, 1215, 11)},
    [4] = {fromPos = Position(1015, 1213, 11), toPos = Position(1042, 1214, 11)}
}

local monsters = {
    [1] = {pos = Position(1042, 1218, 11), name = "Demon"},
    [2] = {pos = Position(1042, 1219, 11), name = "Demon"},
    [3] = {pos = Position(1042, 1220, 11), name = "Demon"},
    [4] = {pos = Position(1042, 1221, 11), name = "Vexclaw"},
    [5] = {pos = Position(1042, 1222, 11), name = "Grimeleech"},
    [6] = {pos = Position(1042, 1223, 11), name = "Hellflayer"},
    [7] = {pos = Position(1042, 1224, 11), name = "Death Dragon"},
    [8] = {pos = Position(1042, 1225, 11), name = "Ragiaz"},
    [9] = {pos = Position(1048, 1216, 11), name = "Demon"}
}

local quest_range = {fromPos = Position(1038, 1212, 11), toPos = Position(1048, 1228, 11)} -- see image in thread for explanation

local exit_position = Position(1020, 1215, 11) -- Position completely outside the quest area

function doResetAnnihilator(position, cid_array)
    local tile = Tile(position)
    local item = tile and tile:getItemById(config.pulled_id)
    if not item then
        return
    end

    local monster_names = {}
    for key, value in pairs(monsters) do
        if not isInArray(monster_names, value.name) then
            monster_names[#monster_names + 1] = value.name
        end
    end

    for i = 1, #monsters do
        local creatures = Tile(monsters[i].pos):getCreatures()
        for key, creature in pairs(creatures) do
            if isInArray(monster_names, creature:getName()) then
                creature:remove()
            end
        end
    end

    for i = 1, #player_positions do
        local creatures = Tile(player_positions[i].toPos):getCreatures()
        for key, creature in pairs(creatures) do
            if isInArray(monster_names, creature:getName()) then
                creature:remove()
            end
        end
    end

    for key, cid in pairs(cid_array) do
        local participant = Player(cid)
        if participant and isInRange(participant:getPosition(), quest_range.fromPos, quest_range.toPos) then
            participant:teleportTo(exit_position)
            exit_position:sendMagicEffect(CONST_ME_TELEPORT)
        end
    end

    item:transform(config.lever_id)
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid ~= config.lever_id then
        return player:sendCancelMessage("The quest is currently in use. Cooldown is " .. config.duration .. " minutes.")
    end

    local participants, pull_player = {}, false
    for i = 1, #player_positions do
        local fromPos = player_positions[i].fromPos
        local tile = Tile(fromPos)
        if not tile then
            print(">> ERROR: Annihilator tile does not exist for Position(" .. fromPos.x .. ", " .. fromPos.y .. ", " .. fromPos.z .. ").")
            return player:sendCancelMessage("There is an issue with this quest. Please contact an administrator.")
        end

        local creature = tile:getBottomCreature()
        if creature then
            local participant = creature:getPlayer()
            if not participant then
                return player:sendCancelMessage(participant:getName() .. " is not a valid participant.")
            end

            if participant:getLevel() < config.level_req then
                return player:sendCancelMessage(participant:getName() .. " is not the required level.")
            end

            if participant.uid == player.uid then
                pull_player = true
            end

            participants[#participants + 1] = {participant = participant, toPos = player_positions[i].toPos}
        end
    end

    if #participants < config.min_players then
        return player:sendCancelMessage("You do not have the required amount of participants.")
    end

    if not pull_player then
        return player:sendCancelMessage("You are in the wrong position.")
    end

    for i = 1, #monsters do
        local toPos = monsters[i].pos
        if not Tile(toPos) then
            print(">> ERROR: Annihilator tile does not exist for Position(" .. toPos.x .. ", " .. toPos.y .. ", " .. toPos.z .. ").")
            return player:sendCancelMessage("There is an issue with this quest. Please contact an administrator.")
        end
        Game.createMonster(monsters[i].name, monsters[i].pos, false, true)
    end

    local cid_array = {}
    for i = 1, #participants do
        participants[i].participant:teleportTo(participants[i].toPos)
        participants[i].toPos:sendMagicEffect(CONST_ME_TELEPORT)
        cid_array[#cid_array + 1] = participants[i].participant.uid
    end

    item:transform(config.pulled_id)
    addEvent(doResetAnnihilator, config.duration * 60 * 1000, toPosition, cid_array)
    return true
end
 
Problem solved
I used a different leverage ID and a different action ID.
It helped.
Why didn't this lever work?
In my opinion there are probably duplicate scripts with this lever ID although it is strange.
Regards! The thread can be closed.
 
Back
Top