• 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!

RAID removing item

carlinhous1996

New Member
Joined
Apr 14, 2022
Messages
54
Reaction score
3
guys, can someone help me with a raid system that happens once a week on a set day, but the time is random that removes 6 items that are on the ground and creates a creature.

ex: items 3122, 3123, 3124, 3125, 3126, 3127 they will be in an x coordinate the body will disappear and will create a y creature.

a123.png

if it helps i have a similar one

Lua:
local shit = {
    {boss = "Darkness Dragon unprisioned", pos = {x=9545, y=13666, z=8}}
}

function onThink(cid, interval)
    local nomonster = {}
    for _, v in pairs(shit) do
        if not getCreatureByName(v.boss) then
            table.insert(nomonster, _)
        end
    end
    if #nomonster == 0 then return true end
    local r = nomonster[math.random(1, #nomonster)]
    doSummonCreature(shit[r].boss, shit[r].pos)
    return true
end
 
Startup Globalevent:
Lua:
local weekDay = "Friday"

local monster = {
    name = "Darkness Dragon unprisioned",
    position = { x = 100, y = 100, z = 7 },
}

local stack_pos = 255

local removeList = {
    [1] = { itemId = 3122, itemPosition = { x = 100, y = 100, z = 7, stackPos = stack_pos } },
    [2] = { itemId = 3123, itemPosition = { x = 100, y = 100, z = 7, stackPos = stack_pos } },
    [3] = { itemId = 3124, itemPosition = { x = 100, y = 100, z = 7, stackPos = stack_pos } },
    [4] = { itemId = 3125, itemPosition = { x = 100, y = 100, z = 7, stackPos = stack_pos } },
    [5] = { itemId = 3126, itemPosition = { x = 100, y = 100, z = 7, stackPos = stack_pos } },
    [6] = { itemId = 3127, itemPosition = { x = 100, y = 100, z = 7, stackPos = stack_pos } },
}

function onStartup()
    if os.date("%A") == weekDay then
        doSummonCreature(monster.name, monster.position)
        for i = 1, #removeList do
            item = getTileThingByPos(removeList[i].itemPosition)
            if item.itemid == removeList[i].itemId then
                doRemoveItem(item.uid)
            end
        end
    end

    return true
end
Post automatically merged:

I made a second version. In this case it's like an raid system:
Lua:
--[[
    Whenever it's Friday, the server will try to run this raid with a 30% chance every hour.
    During the raid, bones will be removed from a predetermined position and a creature will also be summoned.
    The raid will happen only once per Friday.
]]

local weekDay = "Friday"
local chanceToRaid = 30

local monster = {
    name = "Darkness Dragon unprisioned",
    position = { x = 100, y = 100, z = 7 },
}

local stack_pos = 255
local removeList = {
    [1] = { itemId = 3122, itemPosition = { x = 100, y = 100, z = 7, stackPos = stack_pos } },
    [2] = { itemId = 3123, itemPosition = { x = 100, y = 100, z = 7, stackPos = stack_pos } },
    [3] = { itemId = 3124, itemPosition = { x = 100, y = 100, z = 7, stackPos = stack_pos } },
    [4] = { itemId = 3125, itemPosition = { x = 100, y = 100, z = 7, stackPos = stack_pos } },
    [5] = { itemId = 3126, itemPosition = { x = 100, y = 100, z = 7, stackPos = stack_pos } },
    [6] = { itemId = 3127, itemPosition = { x = 100, y = 100, z = 7, stackPos = stack_pos } },
}

local storage = 95566557
function raid()
    if getGlobalStorageValue(storage) <= 0 then
        if math.random(1, 100) <= chanceToRaid then
            for i = 1, #removeList do
                item = getTileThingByPos(removeList[i].itemPosition)
                if item.itemid == removeList[i].itemId then
                    doRemoveItem(item.uid)
                end
            end
            doSummonCreature(monster.name, monster.position)
            setGlobalStorageValue(storage, 1)
        end
        addEvent(raid, 3600000)
    end

    return true
end

function onStartup()
    if os.date("%A") == weekDay then
        raid()
    else
        setGlobalStorageValue(storage, 0)
    end

    return true
end
The first version I made will happen whenever the server starts on Friday.
 
Last edited:
Startup Globalevent:
Lua:
local weekDay = "Friday"

local monster = {
    name = "Darkness Dragon unprisioned",
    position = { x = 100, y = 100, z = 7 },
}

local stack_pos = 255

local removeList = {
    [1] = { itemId = 3122, itemPosition = { x = 100, y = 100, z = 7, stackPos = stack_pos } },
    [2] = { itemId = 3123, itemPosition = { x = 100, y = 100, z = 7, stackPos = stack_pos } },
    [3] = { itemId = 3124, itemPosition = { x = 100, y = 100, z = 7, stackPos = stack_pos } },
    [4] = { itemId = 3125, itemPosition = { x = 100, y = 100, z = 7, stackPos = stack_pos } },
    [5] = { itemId = 3126, itemPosition = { x = 100, y = 100, z = 7, stackPos = stack_pos } },
    [6] = { itemId = 3127, itemPosition = { x = 100, y = 100, z = 7, stackPos = stack_pos } },
}

function onStartup()
    if os.date("%A") == weekDay then
        doSummonCreature(monster.name, monster.position)
        for i = 1, #removeList do
            item = getTileThingByPos(removeList[i].itemPosition)
            if item.itemid == removeList[i].itemId then
                doRemoveItem(item.uid)
            end
        end
    end

    return true
end
Post automatically merged:

I made a second version. In this case it's like an raid system:
Lua:
--[[
    Whenever it's Friday, the server will try to run this raid with a 30% chance every hour.
    During the raid, bones will be removed from a predetermined position and a creature will also be summoned.
    The raid will happen only once per Friday.
]]

local weekDay = "Friday"
local chanceToRaid = 30

local monster = {
    name = "Darkness Dragon unprisioned",
    position = { x = 100, y = 100, z = 7 },
}

local stack_pos = 255
local removeList = {
    [1] = { itemId = 3122, itemPosition = { x = 100, y = 100, z = 7, stackPos = stack_pos } },
    [2] = { itemId = 3123, itemPosition = { x = 100, y = 100, z = 7, stackPos = stack_pos } },
    [3] = { itemId = 3124, itemPosition = { x = 100, y = 100, z = 7, stackPos = stack_pos } },
    [4] = { itemId = 3125, itemPosition = { x = 100, y = 100, z = 7, stackPos = stack_pos } },
    [5] = { itemId = 3126, itemPosition = { x = 100, y = 100, z = 7, stackPos = stack_pos } },
    [6] = { itemId = 3127, itemPosition = { x = 100, y = 100, z = 7, stackPos = stack_pos } },
}

local storage = 95566557
function raid()
    if getGlobalStorageValue(storage) <= 0 then
        if math.random(1, 100) <= chanceToRaid then
            for i = 1, #removeList do
                item = getTileThingByPos(removeList[i].itemPosition)
                if item.itemid == removeList[i].itemId then
                    doRemoveItem(item.uid)
                end
            end
            doSummonCreature(monster.name, monster.position)
            setGlobalStorageValue(storage, 1)
        end
        addEvent(raid, 3600000)
    end

    return true
end

function onStartup()
    if os.date("%A") == weekDay then
        raid()
    else
        setGlobalStorageValue(storage, 0)
    end

    return true
end
The first version I made will happen whenever the server starts on Friday.
the second happens 1 time on Fridays and 30% chance every hour is that it?
 
Whenever it's Friday, the server will try to execute the raid.
Every hour, the server will have a 30% chance to execute the raid.
The raid can only be performed once per Friday.
 
Whenever it's Friday, the server will try to execute the raid.
Every hour, the server will have a 30% chance to execute the raid.
The raid can only be performed once per Friday.

change the function onStartUp with this one (enter interval for 1 hour in globalevents.xml)
Lua:
function onThink(interval)
    local random = math.random(1,100)
    if os.date("%A") == weekDay and random > chanceToRaid then
        raid()
    else
        setGlobalStorageValue(storage, 0)
    end

    return true
end
 
Last edited by a moderator:
the second happens 1 time on Fridays and 30% chance every hour is that it?
here gave this error.
[Warning - Event::loadScript] Event onThink not found (data/globalevents/scripts/raiddarkness.lua)
Post automatically merged:

change the function onStartUp with this one (enter interval for 1 hour in globalevents.xml)
Lua:
function onThink(interval)
    local random = math.random(1,100)
    if os.date("%A") == weekDay and random > then
        raid()
    else
        setGlobalStorageValue(storage, 0)
    end

    return true
end
replaces the onStartUp and gave this error

[Error - LuaScriptInterface::loadFile] data/globalevents/scripts/raiddarkness.lua:46: unexpected symbol near 'then'
[Warning - Event::loadScript] Cannot load script (data/globalevents/scripts/raiddarkness.lua)
data/globalevents/scripts/raiddarkness.lua:46: unexpected symbol near 'then'
 
ahh sorry for that! editted the old post
here gave this error.
[Warning - Event::loadScript] Event onThink not found (data/globalevents/scripts/raiddarkness.lua)
Post automatically merged:


replaces the onStartUp and gave this error

[Error - LuaScriptInterface::loadFile] data/globalevents/scripts/raiddarkness.lua:46: unexpected symbol near 'then'
[Warning - Event::loadScript] Cannot load script (data/globalevents/scripts/raiddarkness.lua)
data/globalevents/scripts/raiddarkness.lua:46: unexpected symbol near 'then'
 
globalevents.xml
Lua:
    <globalevent name="Raid" interval="3600000" script="YOURFILENAME.lua" />
change YOURFILENAME with the filename
I made changes in time to test and did not remove the items or create the creature

<globalevent name="Raid" interval="30" script="raiddarkness.lua"/>

Lua:
--[[

    Whenever it's Friday, the server will try to run this raid with a 30% chance every hour.

    During the raid, bones will be removed from a predetermined position and a creature will also be summoned.

    The raid will happen only once per Friday.

]]



local weekDay = "Sunday"

local chanceToRaid = 99



local monster = {

    name = "Darkness Dragon imprisioned",

    position = { x = 9546, y = 13668, z = 8 },

}



local stack_pos = 255

local removeList = {

    [1] = { itemId = 3122, itemPosition = { x = 9543, y = 13667, z = 8, stackPos = stack_pos } },

    [2] = { itemId = 3123, itemPosition = { x = 9544, y = 13667, z = 8, stackPos = stack_pos } },

    [3] = { itemId = 3124, itemPosition = { x = 9545, y = 13667, z = 8, stackPos = stack_pos } },

    [4] = { itemId = 3125, itemPosition = { x = 9543, y = 13668, z = 8, stackPos = stack_pos } },

    [5] = { itemId = 3126, itemPosition = { x = 9544, y = 13668, z = 8, stackPos = stack_pos } },

    [6] = { itemId = 3127, itemPosition = { x = 9545, y = 13668, z = 8, stackPos = stack_pos } },

}



local storage = 95566557

function raid()

    if getGlobalStorageValue(storage) <= 0 then

        if math.random(1, 100) <= chanceToRaid then

            for i = 1, #removeList do

                item = getTileThingByPos(removeList.itemPosition)

                if item.itemid == removeList.itemId then

                    doRemoveItem(item.uid)

                end

            end

            doSummonCreature(monster.name, monster.position)

            setGlobalStorageValue(storage, 1)

        end

        addEvent(raid, 30)

    end



    return true

end



function onThink(interval)

    local random = math.random(1,100)

    if os.date("%A") == weekDay and random > chanceToRaid then

        raid()

    else

        setGlobalStorageValue(storage, 0)

    end



    return true

end
 
Last edited:
I made changes in time to test and did not remove the items or create the creature

<globalevent name="Raid" interval="30" script="raiddarkness.lua"/>

Lua:
--[[

    Whenever it's Friday, the server will try to run this raid with a 30% chance every hour.

    During the raid, bones will be removed from a predetermined position and a creature will also be summoned.

    The raid will happen only once per Friday.

]]



local weekDay = "Sunday"

local chanceToRaid = 99



local monster = {

    name = "Darkness Dragon imprisioned",

    position = { x = 9546, y = 13668, z = 8 },

}



local stack_pos = 255

local removeList = {

    [1] = { itemId = 3122, itemPosition = { x = 9543, y = 13667, z = 8, stackPos = stack_pos } },

    [2] = { itemId = 3123, itemPosition = { x = 9544, y = 13667, z = 8, stackPos = stack_pos } },

    [3] = { itemId = 3124, itemPosition = { x = 9545, y = 13667, z = 8, stackPos = stack_pos } },

    [4] = { itemId = 3125, itemPosition = { x = 9543, y = 13668, z = 8, stackPos = stack_pos } },

    [5] = { itemId = 3126, itemPosition = { x = 9544, y = 13668, z = 8, stackPos = stack_pos } },

    [6] = { itemId = 3127, itemPosition = { x = 9545, y = 13668, z = 8, stackPos = stack_pos } },

}



local storage = 95566557

function raid()

    if getGlobalStorageValue(storage) <= 0 then

        if math.random(1, 100) <= chanceToRaid then

            for i = 1, #removeList do

                item = getTileThingByPos(removeList.itemPosition)

                if item.itemid == removeList.itemId then

                    doRemoveItem(item.uid)

                end

            end

            doSummonCreature(monster.name, monster.position)

            setGlobalStorageValue(storage, 1)

        end

        addEvent(raid, 30)

    end



    return true

end



function onThink(interval)

    local random = math.random(1,100)

    if os.date("%A") == weekDay and random > chanceToRaid then

        raid()

    else

        setGlobalStorageValue(storage, 0)

    end



    return true

end
What version is it ?
Tfs 1.3 is working the raid method but not removing items before create
 
Back
Top