• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

I need to add a message for everyone

Petrus69

Creating Tibia Servers
Premium User
Joined
Nov 22, 2022
Messages
12
Reaction score
1
Location
Poland
Code:
local previous_key = previous_key or nil
local walls_array = {       
    [1] = {positions = {Position(5989, 6041, 7), Position(5989, 6041, 7)}, itemid = 1271},
    [2] = {positions = {Position(5989, 6041, 7)}, itemid = 1271},
    [3] = {positions = {Position(5989, 6041, 7)}, itemid = 1271},
}

function onThink(interval)
    local random_key
    repeat
        random_key = math.random(#walls_array)
    until random_key ~= previous_key

    local wall_array = walls_array[random_key]
    for _, position in pairs(wall_array.positions) do
        local tile = Tile(position)
        local wall = tile and tile:getItemById(wall_array.itemid)
        if wall then
            wall:remove()
         removeMessage = "You removed a wall!",
            addEvent(function(position, itemid)
                Game.createItem(itemid, 1, position)
            end, interval, position, wall_array.itemid)
        end
    end
    previous_key = random_key
    return true
end
 
Try this:

Lua:
local previous_key = previous_key or nil
local walls_array = {     
    [1] = {positions = {Position(5989, 6041, 7), Position(5989, 6041, 7)}, itemid = 1271},
    [2] = {positions = {Position(5989, 6041, 7)}, itemid = 1271},
    [3] = {positions = {Position(5989, 6041, 7)}, itemid = 1271},
}

function onThink(interval)
    local random_key
    repeat
        random_key = math.random(#walls_array)
    until random_key ~= previous_key

    local wall_array = walls_array[random_key]
    for _, position in pairs(wall_array.positions) do
        local tile = Tile(position)
        local wall = tile and tile:getItemById(wall_array.itemid)
        if wall then
            wall:remove()
            for _, targetPlayer in ipairs(Game.getPlayers()) do
            targetPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "INSERT MESSAGE HERE")
            end
            addEvent(function(position, itemid)
                Game.createItem(itemid, 1, position)
            end, interval, position, wall_array.itemid)
        end
    end
    previous_key = random_key
    return true
end
 
Back
Top