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

Eduardo170

Well-Known Member
Joined
Jan 7, 2014
Messages
422
Solutions
3
Reaction score
66
Location
Caracas, Venezuela
Hello community , I have these errors , please someone help me and excuse my English
TFS 0.3.6
Code:
The OTX Server Version: (2.X.S - 3) - Codename: (LORD ZEDD)



Code:
<?xml version="1.0" encoding="UTF-8"?>  
<mod name="Automatic Raids" version="1.0" author="Vodkart And xotservx" contact="xtibia.com" enabled="yes">  
<config name="raids_func"><![CDATA[
  days = {
    ["Tuesday"] = {
      ["19:49"] = {nome = "Countess Sorrow", pos = {fromPosition = {x=775, y=1194, z=9},toPosition = {x=777, y=1194, z=9}},m = {"1 Countess Sorrow"}, Time = 2},
      ["21:33"] = {nome = "The Imperor", pos = {fromPosition = {x=826, y=1229, z=10},toPosition = {x=828, y=1229, z=10}},m = {"1 The Imperor"}, Time = 20},
    },

    ["Wednesday"] = {
      ["18:45"] = {nome = "Mr. punish", pos = {fromPosition = {x=884, y=1215, z=10},toPosition = {x=886, y=1215, z=10}},m = {"1 Mr. Punish"}, Time = 2},
    },

    ["Sunday"] = {
      ["10:08"] = {nome = "Dracola", pos = {fromPosition = {x=882, y=1192, z=10},toPosition = {x=884, y=1192, z=10}}, m = {"1 Dracola"}, Time = 15},
      ["10:46"] = {nome = "Massacre", pos = {fromPosition = {x=919, y=1227, z=10},toPosition = {x=921, y=1227, z=10}}, m = {"1 Massacre"}, Time = 20},
      ["10:47"] = {nome = "Son of Verminor", pos = {fromPosition = {x=735, y=1243, z=10},toPosition = {x=737, y=1243, z=10}}, m = {"1 Son of Verminor"}, Time = 20},
    }                                      
  }
]]></config>    
<globalevent name="AutomaticRaids" interval="60000" event="script"><![CDATA[
domodlib('raids_func')
function onThink(interval, lastExecution)  
    if days[os.date("%A")] then
      local hours = tostring(os.date("%X")):sub(1, 5)      
      local tb = days[os.date("%A")][hours] 
        if tb then        
            function removeCreature(tb)
                for x = ((tb.pos.fromPosition.x)-10), ((tb.pos.toPosition.x)+10) do
                    for y = ((tb.pos.fromPosition.y)-10), ((tb.pos.toPosition.y)+10) do
                      local m = getTopCreature({x=x, y=y, z= tb.pos.fromPosition.z}).uid
                        if m ~= 0 and isMonster(m) then
                            doRemoveCreature(m)
                        end
                    end
                end
            end

            doBroadcastMessage("The invasion of " .. tb.nome .. " started")
            for _,x in pairs(tb.m) do
                for s = 1, tonumber(x:match("%d+")) do
                  local pos = {x = math.random(tb.pos.toPosition.x,tb.pos.fromPosition.x), y = math.random(tb.pos.toPosition.y, tb.pos.fromPosition.y) , z = tb.pos.fromPosition.z}
                    doCreateMonster(x:match("%s(.+)"), pos)
                end
            end

            addEvent(removeCreature, tb.Time*60*1000, tb)
        end
    end

    return true
end
]]></globalevent>
</mod>

Code:
[10/5/2016 20:29:53] [Error - GlobalEvent Interface]
[10/5/2016 20:29:53] domodlib('raids_func')
[10/5/2016 20:29:54] function onThink(interval, lastExecution)
[10/5/2016 20:29:54]     if days[os.date("%A")] then
[10/5/2016 20:29:54]       local hours = to string(os.date("%X")):sub(1, 5)    
[10/5/2016 20:29:54]       local tb = days[os.date("%A")][hours]
[10/5/2016 20:29:54]         if tb then      
[10/5/2016 20:29:54]             function removeCreature(tb)
[10/5/2016 20:29:54]                 for x = ((tb.pos.fromPosition.x)-10), ((tb.pos.toPosition.x)+10) do
[10/5/2016 20:29:54]                     for y = ((tb.pos.fromPosition.y)-10), ((tb.pos.toPosition.y)+10) do
[10/5/2016 20:29:54]                       local m = getTopCreature({x=x, y=y, z= tb.pos.fromPosition.z}).uid
[10/5/2016 20:29:54]                         if m ~= 0 and isMonster(m) then
[10/5/2016 20:29:54]                             doRemoveCreature(m)
[10/5/2016 20:29:54]                         end
[10/5/2016 20:29:54]                     end
[10/5/2016 20:29:55]                 end
[10/5/2016 20:29:55]             end

[10/5/2016 20:29:55]             doBroadcastMessage("The invasion of " .. tb.nome .. " started")
[10/5/2016 20:29:55]             for _,x in pairs(tb.m) do
[10/5/2016 20:29:55]                 for s = 1, tonumber(x:match("%d+")) do
[10/5/2016 20:29:55]                   local pos = {x = math.random(tb.pos.toPosition.x,tb.pos.fromPosition.x), y = math.random(tb.pos.toPosition.y, tb.pos.fromPosition.y) , z = tb.pos.fromPosition.z}
[10/5/2016 20:29:55]                     doCreateMonster(x:match("%s(.+)"), pos)
[10/5/2016 20:29:55]                 end
[10/5/2016 20:29:55]             end

[10/5/2016 20:29:55]             addEvent(removeCreature, tb.Time*60*1000, tb)
[10/5/2016 20:29:55]         end
[10/5/2016 20:29:55]     end

[10/5/2016 20:29:56]     return true
[10/5/2016 20:29:56] end
[10/5/2016 20:29:56] :onThink
[10/5/2016 20:29:56] Description:
[10/5/2016 20:29:56] [string "LuaInterface::loadBuffer"]:4: attempt to call global 'string' (a table value)
[10/5/2016 20:29:56] stack traceback:
[10/5/2016 20:29:56]     [string "LuaInterface::loadBuffer"]:4: in function <[string "LuaInterface::loadBuffer"]:2>
[10/5/2016 20:29:56] [Error - GlobalEvents::think] Couldn't execute event: AutomaticRaids
 
Last edited:
edited my post, you dont need tostring, os.date() already returns it as a string

edit: you could change
Code:
local hours = tostring(os.date("%X")):sub(1, 5)
local tb = days[os.date("%A")][hours]
if tb then
to
Code:
local tb = days[os.date("%A")][string.sub(os.date("%X"), 1, 5)]
if tb then
 
Last edited:
did you change what i said in my last post and it still is the same error?
edit: missed that tb was used elsewhere, changed it

also, why the fuck is there a function in the middle of that event? why isnt it just outside?

Code:
<?xml version="1.0" encoding="UTF-8"?>  
<mod name="Automatic Raids" version="1.0" author="Vodkart And xotservx" contact="xtibia.com" enabled="yes">  
<config name="raids_func"><![CDATA[
  days = {
    ["Tuesday"] = {
      ["19:49"] = {nome = "Countess Sorrow", pos = {fromPosition = {x=775, y=1194, z=9},toPosition = {x=777, y=1194, z=9}},m = {"1 Countess Sorrow"}, Time = 2},
      ["21:33"] = {nome = "The Imperor", pos = {fromPosition = {x=826, y=1229, z=10},toPosition = {x=828, y=1229, z=10}},m = {"1 The Imperor"}, Time = 20},
    },

    ["Wednesday"] = {
      ["18:45"] = {nome = "Mr. punish", pos = {fromPosition = {x=884, y=1215, z=10},toPosition = {x=886, y=1215, z=10}},m = {"1 Mr. Punish"}, Time = 2},
    },

    ["Sunday"] = {
      ["10:08"] = {nome = "Dracola", pos = {fromPosition = {x=882, y=1192, z=10},toPosition = {x=884, y=1192, z=10}}, m = {"1 Dracola"}, Time = 15},
      ["10:46"] = {nome = "Massacre", pos = {fromPosition = {x=919, y=1227, z=10},toPosition = {x=921, y=1227, z=10}}, m = {"1 Massacre"}, Time = 20},
      ["10:47"] = {nome = "Son of Verminor", pos = {fromPosition = {x=735, y=1243, z=10},toPosition = {x=737, y=1243, z=10}}, m = {"1 Son of Verminor"}, Time = 20},
    }                                      
  }
]]></config>    

function removeCreature(t)
    for x = ((t.pos.fromPosition.x)-10), ((t.pos.toPosition.x)+10) do
        for y = ((t.pos.fromPosition.y)-10), ((t.pos.toPosition.y)+10) do
         local m = getTopCreature({x=x, y=y, z= t.pos.fromPosition.z}).uid
            if m ~= 0 and isMonster(m) then
                doRemoveCreature(m)
            end
        end
    end
end

<globalevent name="AutomaticRaids" interval="60000" event="script"><![CDATA[
domodlib('raids_func')
function onThink(interval, lastExecution)  
    if days[os.date("%A")] then  
      local tb = days[os.date("%A")][string.sub(os.date("%X"), 1, 5)] 
        if tb then        
            removeCreature(tb)
            doBroadcastMessage("The invasion of " .. tb.nome .. " started")
            for _,x in pairs(tb.m) do
                for s = 1, tonumber(x:match("%d+")) do
                  local pos = {x = math.random(tb.pos.toPosition.x,tb.pos.fromPosition.x), y = math.random(tb.pos.toPosition.y, tb.pos.fromPosition.y) , z = tb.pos.fromPosition.z}
                    doCreateMonster(x:match("%s(.+)"), pos)
                end
            end
            addEvent(removeCreature, tb.Time*60*1000, tb)
        end
    end

    return true
end
]]></globalevent>
</mod>
if you try to use this code, what error do you get?
 
Last edited:
can you link a download to the server version you're using?
and link to where you got the raid script / how to install it

edit: i dont see why this script is in xml anyways, since you any TFS version you can just use globalevents.xml and set a timer in there, and then call the script..
 
Last edited:
can you upload the data folder somewhere? the entire site is in brazilian and you have to register you reach the link

edit: i can try to fix it on my 0.3.6 tfs server, but i have no idea how to add a script like this
 
Last edited:
if anyone knows how to fix this xml file feel free to do it, because i have no clue how to

but i got it to work on my 0.3.6 tfs by doing this:
in lib/100-compat.lua add
Code:
days = {
["Tuesday"] = {
  ["19:49"] = {nome = "Countess Sorrow", pos = {fromPosition = {x=775, y=1194, z=9},toPosition = {x=777, y=1194, z=9}},m = {"1 Countess Sorrow"}, Time = 2},
  ["21:33"] = {nome = "The Imperor", pos = {fromPosition = {x=826, y=1229, z=10},toPosition = {x=828, y=1229, z=10}},m = {"1 The Imperor"}, Time = 20},
},

["Wednesday"] = {
  ["04:08"] = {nome = "Mr. punish", pos = {fromPosition = {x=1000, y=990, z=7},toPosition = {x=1005, y=1000, z=7}},m = {"1 Mr. Punish"}, Time = 2},
},

["Sunday"] = {
  ["10:08"] = {nome = "Dracola", pos = {fromPosition = {x=882, y=1192, z=10},toPosition = {x=884, y=1192, z=10}}, m = {"1 Dracola"}, Time = 15},
  ["10:46"] = {nome = "Massacre", pos = {fromPosition = {x=919, y=1227, z=10},toPosition = {x=921, y=1227, z=10}}, m = {"1 Massacre"}, Time = 20},
  ["10:47"] = {nome = "Son of Verminor", pos = {fromPosition = {x=735, y=1243, z=10},toPosition = {x=737, y=1243, z=10}}, m = {"1 Son of Verminor"}, Time = 20},
}                                      
}
in globalevents.xml add
Code:
    <globalevent name="AutomaticRaids" interval="1" event="script" value="automatic_raids.lua"/>
and in /globalevents/scripts/automatic_raids.lua add
Code:
local function removeCreature(t)
    for x = ((t.pos.fromPosition.x)-10), ((t.pos.toPosition.x)+10) do
        for y = ((t.pos.fromPosition.y)-10), ((t.pos.toPosition.y)+10) do
         local m = getTopCreature({x=x, y=y, z= t.pos.fromPosition.z}).uid
            if m ~= 0 and isMonster(m) then
                doRemoveCreature(m)
            end
        end
    end
end

function onThink(interval, lastExecution, thinkInterval)  
    if days[os.date("%A")] then  
      local tb = days[os.date("%A")][string.sub(os.date("%X"), 1, 5)] 
        if tb then        
            removeCreature(tb)
            doBroadcastMessage("The invasion of " .. tb.nome .. " started")
            for _,x in pairs(tb.m) do
                for s = 1, tonumber(x:match("%d+")) do
                    print(tb.pos.toPosition.x, tb.pos.fromPosition.x)
                    print(tb.pos.toPosition.y, tb.pos.fromPosition.y)
                  local pos = {x = math.random(tb.pos.fromPosition.x, tb.pos.toPosition.x), y = math.random(tb.pos.fromPosition.y, tb.pos.toPosition.y) , z = tb.pos.fromPosition.z}
                    doCreateMonster(x:match("%s(.+)"), pos)
                end
            end
            addEvent(removeCreature, tb.Time*60*1000, tb)
        end
    end

    return true
end
and change things in the times etc and interval to whatever you want (1 = 1 second in interval)
 
Back
Top