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

Lua Woe strange error

ex eclipse

New Member
Joined
Jul 15, 2007
Messages
282
Reaction score
1
Location
Brazil
hi all, i had WOE working in another server with another map
so i changed the map but im still using rev3777 forgotten server
so i just changed positions and such but when I walk over actionid 3131 (that checks player guild)
i get this error
Code:
[3:52:24.774] [Error - MoveEvents Interface]
[3:52:24.774] data/movements/scripts/woe_tiles.lua:eek:nStepIn
[3:52:24.774] Description:
[3:52:24.774] ./_woe.lua:76: attempt to concatenate local 'id' (a nil value)
[3:52:24.774] stack traceback:
[3:52:24.774]   ./_woe.lua:76: in function 'getGuildName'
[3:52:24.774]   ./_woe.lua:91: in function 'guildName'
[3:52:24.774]   data/movements/scripts/woe_tiles.lua:24: in function <data/movements/scripts/woe_tiles.lua:3>

what the hell is wrong ?
 
Please follow the Support Board rules when you are creating threads in the Support Board.

We are not capable of reading your mind, so bare in mind that it's necessary to state the TFS version you are using, and post the script you are having trouble with.
 
sorry, its the default WOE posted in a lot of topics... I did not think it needed.. cuz its a popular script
whatever, here its

woe_tiles.lua (movements folder)
Code:
dofile("./_woe.lua")

function onStepIn(cid, item, position, fromPosition)
    if item.actionid == Castle.tiles then
        Woe.getInfo()
        if isPlayer(cid) then
            if Woe.isTime() then
                if getPlayerGuildId(cid) ~= 0 then
                    if Woe.isRegistered(cid) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Boa Sorte ".. getCreatureName(cid) .."!.")
                    else
                        Woe.moveBack(cid, fromPosition, "Você não está registrado digite !guild")
                    end          
                else
                    Woe.moveBack(cid, fromPosition, "Somente jogadores com guilda podem entrar.")
                end
            elseif getPlayerGuildId(cid) == infoLua[2] then
                if Woe.isRegistered(cid) then
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Bem vindo ".. getCreatureName(cid) ..".")
                else
                    Woe.moveBack(cid, fromPosition, "Você não está registrado digite !guild")
                end          
            else
                Woe.moveBack(cid, fromPosition, "Não é hora do castelo e você não é da guilda ".. Woe.guildName() ..".")
            end
        end
    elseif item.actionid == Castle.portals then
        doTeleportThing(cid, Castle.PreToPos[math.random(1, 2)], false)
    elseif item.actionid == Castle.bases then
        if isPlayer(cid) then
            Woe.moveBack(cid, fromPosition, "Você não pode pisar ai.")
        end
    end
    return true
end

function onAddItem(moveitem, tileitem, position)
    doRemoveItem(moveitem.uid, moveitem.type > 0 and moveitem.type or 1)
    return true
end

_woe.lua (ot folder.. together with config and such)
Code:
dofile("./var.woe")

local config = woe_config

fileStore = true

infoFile = 'tmp.woe'
infoLua = {}

Woe = {}
Woe.__index = Woe

function Woe.setup()
    db.executeQuery("DROP TABLE IF EXISTS `woe`;")
    db.executeQuery("CREATE TABLE `woe` (`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,`started` INT( 11 ) NOT NULL ,`guild` INT( 11 ) NOT NULL ,`breaker` INT( 11 ) NOT NULL ,`time` INT( 11 ) NOT NULL ,PRIMARY KEY ( `id` ) ,UNIQUE (`id`)) ENGINE = MYISAM")
    doBroadcastMessage("DB Added [...]", config.bcType)
    if fileStore then
        local newFile = io.open(infoFile, "w")
        for _, i in ipairs({'started', 'guild', 'breaker', 'time'}) do
            newFile:write(i .. ' = 0 ;end;\n')
        end
        newFile:close()
    else
        db.executeQuery("DROP TABLE IF EXISTS `tmpwoe`;")
        db.executeQuery("CREATE TABLE `tmpwoe` (`started` INT( 11 ) NOT NULL ,`guild` INT( 11 ) NOT NULL ,`breaker` INT( 111 ) NOT NULL ,`time` INT( 1 ) NOT NULL) ENGINE = MYISAM ;")
        db.executeQuery("ALTER TABLE `tmpwoe` ADD `indexer` INT NOT NULL ")
        db.executeQuery("INSERT INTO `tmpwoe` (`started` ,`guild` ,`breaker` ,`time`, `indexer`)VALUES ('0', '0', '0', '0', '1');")
    end
end

function Woe.getInfo()
    if fileStore then
        local open = io.open(infoFile, "r")
        if open then
            for i in io.lines(infoFile) do
                for v, k in ipairs({'started', 'guild', 'breaker', 'time'}) do
                    if (i:find(k)) then
                        n = i:match(k .. '.*')
                        infoLua[v] = tonumber(n:sub(n:find('=') + 2, n:find(';end;') - 2))
                    end
                end
            end
            open:close()
        end
    else
        for v, k in ipairs({'started', 'guild', 'breaker', 'time'}) do
            local tmp = db.getResult("SELECT " .. k .. " FROM `tmpwoe` WHERE `indexer` = '1';")
            infoLua[v] = tmp:getDataInt(k)
            tmp:free()
        end
    end
end

function Woe.updateInfo(tab)
    if fileStore then
        local open = io.open(infoFile, "w")
        if open then
            for k, i in ipairs({'started', 'guild', 'breaker', 'time'}) do
                open:write(i .. ' = ' .. tab[k] .. ' ;end;\n')
            end
            open:close()
        end
    else
        for v, k in ipairs({'started', 'guild', 'breaker', 'time'}) do
            db.executeQuery("UPDATE `tmpwoe` SET " .. k .. " =  " .. tab[v] .. " WHERE `indexer` = 1;")
        end
    end
end

function Woe.save()
    Woe.getInfo()
    db.executeQuery("INSERT INTO `woe` (`started`, `guild`, `breaker`, `time`) VALUES (" .. infoLua[1] .. ", " .. infoLua[2] .. ", " .. infoLua[3] .. ", " .. infoLua[4] .. ");")
end

function Woe.getGuildName(id)
    local res = db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. id .. ";")
    if (res:getID() ~= -1) then
        ret = res:getDataString('name')
        res:free()
    end
    return ret
end

function Woe.breakerName()
    Woe.getInfo()
    return infoLua[3] ~= 0 and getPlayerNameByGUID(infoLua[3]) or 'None'
end

function Woe.guildName()
    Woe.getInfo()
    return infoLua[2] ~= 0 and Woe.getGuildName(infoLua[2]) or 'Nones'
end

function Woe.startTime()
    Woe.getInfo()
    return os.date("%d %B %Y %X ", infoLua[1])
end

function Woe.breakTime()
    Woe.getInfo()
    return os.date("%d %B %Y %X ", infoLua[4])
end

function Woe.timeToEnd()
    Woe.getInfo()
    local myTable = {}
    for k, i in ipairs({"%M", "%S"}) do
        myTable[k] = os.date(i, os.difftime(os.time(), infoLua[1]))
    end
    return {mins = ((config.timeToEnd - 1) - myTable[1]), secs = (60 - myTable[2])}
end

function Woe.moveBack(cid, fromPosition, text)
    doTeleportThing(cid, fromPosition, TRUE)
    doPlayerSendCancel(cid, text)
end

function Woe.getGuildMembers(id)
    local members = {}
    for _, i in ipairs(getPlayersOnline()) do
        if id == getPlayerGuildId(i) then
            table.insert(members, i)
        end
    end
    return members
end

function Woe.deco(text)
    for _, i in ipairs(Castle.decoraciones) do
        doItemSetAttribute(i, "description", text)
    end
end

function Woe.removePortals()
    for _, i in ipairs(Castle.PrePortalsPos) do
        if (getThingFromPos(i).itemid > 0) then
            doRemoveItem(getThingFromPos(i).uid)
        end
    end
end

function Woe.removePre()
    for _, i in ipairs(Castle.PreEmpes) do
        if (isCreature(getThingFromPos(i).uid) == true) then
            doRemoveCreature(getThingFromPos(i).uid)
        end
    end
end

function Woe.checkPre()
    local Count = 0
    for _, i in ipairs(Castle.PreEmpes) do
        if (isCreature(getThingFromPos(i).uid) == false) then
            Count = Count + 1
        end
    end
    return (Count == #Castle.PreEmpes)
end

function Woe.isTime()
    return (getGlobalStorageValue(stor.WoeTime) == 1)
end

function Woe.isStarted()
    return (getGlobalStorageValue(stor.Started) == 1)
end

function Woe.isRegistered(cid)
    return (getPlayerStorageValue(cid, stor.register) == 1)
end

function Woe.isInCastle(cid)
    local myPos = getCreaturePosition(cid)
    if (myPos.x >= Castle.salas.a.fromx and myPos.x <= Castle.salas.a.tox) then
        if (myPos.y >= Castle.salas.a.fromy and myPos.y <= Castle.salas.a.toy) then
            if isInArray({Castle.salas.a.z, Castle.salas.b.z, Castle.salas.c.z, Castle.salas.d.z, Castle.salas.e.z}, myPos.z) then
                return true
            end
        end
    end
    return false
end

function Woe.expulsar(guild, fromx, tox, fromy, toy, z, outpos)
    for _x = fromx, tox do
        for _y = fromy, toy do
            local player = getThingFromPos({x = _x, y = _y, z = z, stackpos = 253}).uid
            if (isPlayer(player) == true) then
                if (getPlayerGuildId(player) ~= guild) then
                    doTeleportThing(player, outpos, false)
                end
            end
        end
    end
end

-- extras

function doSetItemActionId(uid, action)
    doItemSetAttribute(uid, "aid", action)
end

function exhaust(cid, storevalue, exhausttime)
-- Exhaustion function by Alreth, v1.1 2006-06-24 01:31
-- Returns 1 if not exhausted and 0 if exhausted
    newExhaust = os.time()
    oldExhaust = getPlayerStorageValue(cid, storevalue)
    if (oldExhaust == nil or oldExhaust < 0) then
        oldExhaust = 0
    end
    if (exhausttime == nil or exhausttime < 0) then
        exhausttime = 1
    end
    diffTime = os.difftime(newExhaust, oldExhaust)
    if (diffTime >= exhausttime or diffTime < 0) then
        setPlayerStorageValue(cid, storevalue, newExhaust)
        return 1
    else
        return 0
    end
end

--new
guard_pos =
    {
        {x = 1237, y = 1025, z = 6},
        {x = 1238, y = 1025, z = 6},
        {x = 1239, y = 1025, z = 6},
        {x = 1240, y = 1025, z = 6},
        {x = 1241, y = 1025, z = 6},
        {x = 1236, y = 1025, z = 6},
        {x = 1235, y = 1025, z = 6}
    }
  
function Woe.check()
    for storage = 24504, 24511 do
        local pid = getGlobalStorageValue(storage)
        if isCreature(pid) then
            return false
        end
    end
    return true
end

function Woe.summon()
    for k, i in ipairs(guard_pos) do
        local pid = doSummonCreature("guard", i)
        setGlobalStorageValue(24503 + k, pid)
    end
end

function Woe.remove()
    for storage = 24504, 24511 do
        local pid = getGlobalStorageValue(storage)
        if isCreature(pid) then
            doRemoveCreature(pid)
        end
    end
end
 
sorry, its the default WOE posted in a lot of topics... I did not think it needed.. cuz its a popular script
whatever, here its

woe_tiles.lua (movements folder)
Code:
dofile("./_woe.lua")

function onStepIn(cid, item, position, fromPosition)
    if item.actionid == Castle.tiles then
        Woe.getInfo()
        if isPlayer(cid) then
            if Woe.isTime() then
                if getPlayerGuildId(cid) ~= 0 then
                    if Woe.isRegistered(cid) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Boa Sorte ".. getCreatureName(cid) .."!.")
                    else
                        Woe.moveBack(cid, fromPosition, "Você não está registrado digite !guild")
                    end         
                else
                    Woe.moveBack(cid, fromPosition, "Somente jogadores com guilda podem entrar.")
                end
            elseif getPlayerGuildId(cid) == infoLua[2] then
                if Woe.isRegistered(cid) then
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Bem vindo ".. getCreatureName(cid) ..".")
                else
                    Woe.moveBack(cid, fromPosition, "Você não está registrado digite !guild")
                end         
            else
                Woe.moveBack(cid, fromPosition, "Não é hora do castelo e você não é da guilda ".. Woe.guildName() ..".")
            end
        end
    elseif item.actionid == Castle.portals then
        doTeleportThing(cid, Castle.PreToPos[math.random(1, 2)], false)
    elseif item.actionid == Castle.bases then
        if isPlayer(cid) then
            Woe.moveBack(cid, fromPosition, "Você não pode pisar ai.")
        end
    end
    return true
end

function onAddItem(moveitem, tileitem, position)
    doRemoveItem(moveitem.uid, moveitem.type > 0 and moveitem.type or 1)
    return true
end

_woe.lua (ot folder.. together with config and such)
Code:
dofile("./var.woe")

local config = woe_config

fileStore = true

infoFile = 'tmp.woe'
infoLua = {}

Woe = {}
Woe.__index = Woe

function Woe.setup()
    db.executeQuery("DROP TABLE IF EXISTS `woe`;")
    db.executeQuery("CREATE TABLE `woe` (`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,`started` INT( 11 ) NOT NULL ,`guild` INT( 11 ) NOT NULL ,`breaker` INT( 11 ) NOT NULL ,`time` INT( 11 ) NOT NULL ,PRIMARY KEY ( `id` ) ,UNIQUE (`id`)) ENGINE = MYISAM")
    doBroadcastMessage("DB Added [...]", config.bcType)
    if fileStore then
        local newFile = io.open(infoFile, "w")
        for _, i in ipairs({'started', 'guild', 'breaker', 'time'}) do
            newFile:write(i .. ' = 0 ;end;\n')
        end
        newFile:close()
    else
        db.executeQuery("DROP TABLE IF EXISTS `tmpwoe`;")
        db.executeQuery("CREATE TABLE `tmpwoe` (`started` INT( 11 ) NOT NULL ,`guild` INT( 11 ) NOT NULL ,`breaker` INT( 111 ) NOT NULL ,`time` INT( 1 ) NOT NULL) ENGINE = MYISAM ;")
        db.executeQuery("ALTER TABLE `tmpwoe` ADD `indexer` INT NOT NULL ")
        db.executeQuery("INSERT INTO `tmpwoe` (`started` ,`guild` ,`breaker` ,`time`, `indexer`)VALUES ('0', '0', '0', '0', '1');")
    end
end

function Woe.getInfo()
    if fileStore then
        local open = io.open(infoFile, "r")
        if open then
            for i in io.lines(infoFile) do
                for v, k in ipairs({'started', 'guild', 'breaker', 'time'}) do
                    if (i:find(k)) then
                        n = i:match(k .. '.*')
                        infoLua[v] = tonumber(n:sub(n:find('=') + 2, n:find(';end;') - 2))
                    end
                end
            end
            open:close()
        end
    else
        for v, k in ipairs({'started', 'guild', 'breaker', 'time'}) do
            local tmp = db.getResult("SELECT " .. k .. " FROM `tmpwoe` WHERE `indexer` = '1';")
            infoLua[v] = tmp:getDataInt(k)
            tmp:free()
        end
    end
end

function Woe.updateInfo(tab)
    if fileStore then
        local open = io.open(infoFile, "w")
        if open then
            for k, i in ipairs({'started', 'guild', 'breaker', 'time'}) do
                open:write(i .. ' = ' .. tab[k] .. ' ;end;\n')
            end
            open:close()
        end
    else
        for v, k in ipairs({'started', 'guild', 'breaker', 'time'}) do
            db.executeQuery("UPDATE `tmpwoe` SET " .. k .. " =  " .. tab[v] .. " WHERE `indexer` = 1;")
        end
    end
end

function Woe.save()
    Woe.getInfo()
    db.executeQuery("INSERT INTO `woe` (`started`, `guild`, `breaker`, `time`) VALUES (" .. infoLua[1] .. ", " .. infoLua[2] .. ", " .. infoLua[3] .. ", " .. infoLua[4] .. ");")
end

function Woe.getGuildName(id)
    local res = db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. id .. ";")
    if (res:getID() ~= -1) then
        ret = res:getDataString('name')
        res:free()
    end
    return ret
end

function Woe.breakerName()
    Woe.getInfo()
    return infoLua[3] ~= 0 and getPlayerNameByGUID(infoLua[3]) or 'None'
end

function Woe.guildName()
    Woe.getInfo()
    return infoLua[2] ~= 0 and Woe.getGuildName(infoLua[2]) or 'Nones'
end

function Woe.startTime()
    Woe.getInfo()
    return os.date("%d %B %Y %X ", infoLua[1])
end

function Woe.breakTime()
    Woe.getInfo()
    return os.date("%d %B %Y %X ", infoLua[4])
end

function Woe.timeToEnd()
    Woe.getInfo()
    local myTable = {}
    for k, i in ipairs({"%M", "%S"}) do
        myTable[k] = os.date(i, os.difftime(os.time(), infoLua[1]))
    end
    return {mins = ((config.timeToEnd - 1) - myTable[1]), secs = (60 - myTable[2])}
end

function Woe.moveBack(cid, fromPosition, text)
    doTeleportThing(cid, fromPosition, TRUE)
    doPlayerSendCancel(cid, text)
end

function Woe.getGuildMembers(id)
    local members = {}
    for _, i in ipairs(getPlayersOnline()) do
        if id == getPlayerGuildId(i) then
            table.insert(members, i)
        end
    end
    return members
end

function Woe.deco(text)
    for _, i in ipairs(Castle.decoraciones) do
        doItemSetAttribute(i, "description", text)
    end
end

function Woe.removePortals()
    for _, i in ipairs(Castle.PrePortalsPos) do
        if (getThingFromPos(i).itemid > 0) then
            doRemoveItem(getThingFromPos(i).uid)
        end
    end
end

function Woe.removePre()
    for _, i in ipairs(Castle.PreEmpes) do
        if (isCreature(getThingFromPos(i).uid) == true) then
            doRemoveCreature(getThingFromPos(i).uid)
        end
    end
end

function Woe.checkPre()
    local Count = 0
    for _, i in ipairs(Castle.PreEmpes) do
        if (isCreature(getThingFromPos(i).uid) == false) then
            Count = Count + 1
        end
    end
    return (Count == #Castle.PreEmpes)
end

function Woe.isTime()
    return (getGlobalStorageValue(stor.WoeTime) == 1)
end

function Woe.isStarted()
    return (getGlobalStorageValue(stor.Started) == 1)
end

function Woe.isRegistered(cid)
    return (getPlayerStorageValue(cid, stor.register) == 1)
end

function Woe.isInCastle(cid)
    local myPos = getCreaturePosition(cid)
    if (myPos.x >= Castle.salas.a.fromx and myPos.x <= Castle.salas.a.tox) then
        if (myPos.y >= Castle.salas.a.fromy and myPos.y <= Castle.salas.a.toy) then
            if isInArray({Castle.salas.a.z, Castle.salas.b.z, Castle.salas.c.z, Castle.salas.d.z, Castle.salas.e.z}, myPos.z) then
                return true
            end
        end
    end
    return false
end

function Woe.expulsar(guild, fromx, tox, fromy, toy, z, outpos)
    for _x = fromx, tox do
        for _y = fromy, toy do
            local player = getThingFromPos({x = _x, y = _y, z = z, stackpos = 253}).uid
            if (isPlayer(player) == true) then
                if (getPlayerGuildId(player) ~= guild) then
                    doTeleportThing(player, outpos, false)
                end
            end
        end
    end
end

-- extras

function doSetItemActionId(uid, action)
    doItemSetAttribute(uid, "aid", action)
end

function exhaust(cid, storevalue, exhausttime)
-- Exhaustion function by Alreth, v1.1 2006-06-24 01:31
-- Returns 1 if not exhausted and 0 if exhausted
    newExhaust = os.time()
    oldExhaust = getPlayerStorageValue(cid, storevalue)
    if (oldExhaust == nil or oldExhaust < 0) then
        oldExhaust = 0
    end
    if (exhausttime == nil or exhausttime < 0) then
        exhausttime = 1
    end
    diffTime = os.difftime(newExhaust, oldExhaust)
    if (diffTime >= exhausttime or diffTime < 0) then
        setPlayerStorageValue(cid, storevalue, newExhaust)
        return 1
    else
        return 0
    end
end

--new
guard_pos =
    {
        {x = 1237, y = 1025, z = 6},
        {x = 1238, y = 1025, z = 6},
        {x = 1239, y = 1025, z = 6},
        {x = 1240, y = 1025, z = 6},
        {x = 1241, y = 1025, z = 6},
        {x = 1236, y = 1025, z = 6},
        {x = 1235, y = 1025, z = 6}
    }
 
function Woe.check()
    for storage = 24504, 24511 do
        local pid = getGlobalStorageValue(storage)
        if isCreature(pid) then
            return false
        end
    end
    return true
end

function Woe.summon()
    for k, i in ipairs(guard_pos) do
        local pid = doSummonCreature("guard", i)
        setGlobalStorageValue(24503 + k, pid)
    end
end

function Woe.remove()
    for storage = 24504, 24511 do
        local pid = getGlobalStorageValue(storage)
        if isCreature(pid) then
            doRemoveCreature(pid)
        end
    end
end

Try changing:
Code:
return infoLua[2] ~= 0 and Woe.getGuildName(infoLua[2]) or 'Nones'

To:

Code:
return tonumber(infoLua[2]) and (infoLua[2] ~= 0 and Woe.getGuildName(infoLua[2])) or 'Nones'
 
holy shit another error
Code:
 [Error - TalkAction Interface]
data/talkactions/scripts/woe.lua:onSay
[Description:
 (luaGetPlayerNameByGUID) Player not found
[15:39:15.815] [Error - GlobalEvent Interface]
[15:39:15.815] data/globalevents/scripts/woe.lua:onThink
[15:39:15.815] Description:
[15:39:15.816] ./_woe.lua:59: attempt to concatenate field '?' (a nil value)
[15:39:15.816] stack traceback:
[15:39:15.816]  ./_woe.lua:59: in function 'updateInfo'
[15:39:15.816]  data/globalevents/scripts/woe.lua:55: in function <data/globalevents/scripts/woe.lua:46>
[15:39:15.816] [Error - GlobalEvents::think] Couldn't execute event: WoE


the _woe.lua is above
the globalevents/woe.lua below

Code:
dofile("./_woe.lua")

local config = woe_config

local reward = 1000000 -- 1kk
local itemid2 = 10127
local function EndWoe()
    Woe.getInfo()
      
    setGlobalStorageValue(stor.Started, 0)
    setGlobalStorageValue(stor.WoeTime, 0)
  
    Woe.expulsar(infoLua[2], Castle.salas.a.fromx, Castle.salas.a.tox, Castle.salas.a.fromy, Castle.salas.a.toy, Castle.salas.a.z, Castle._exit)
    Woe.expulsar(infoLua[2], Castle.salas.b.fromx, Castle.salas.b.tox, Castle.salas.b.fromy, Castle.salas.b.toy, Castle.salas.b.z, Castle._exit)
    Woe.expulsar(infoLua[2], Castle.salas.c.fromx, Castle.salas.c.tox, Castle.salas.c.fromy, Castle.salas.c.toy, Castle.salas.c.z, Castle._exit)
       Woe.expulsar(infoLua[2], Castle.salas.d.fromx, Castle.salas.d.tox, Castle.salas.d.fromy, Castle.salas.d.toy, Castle.salas.d.z, Castle._exit)
       Woe.expulsar(infoLua[2], Castle.salas.e.fromx, Castle.salas.e.tox, Castle.salas.e.fromy, Castle.salas.e.toy, Castle.salas.e.z, Castle._exit)
  
  
    doBroadcastMessage("Castle finalizado", config.bcType)
    doBroadcastMessage("O " .. Castle.name .. " foi dominado por ".. Woe.guildName() ..".", config.bcType)
  
    if isCreature(getThingFromPos(Castle.empePos).uid) then
        doRemoveCreature(getThingFromPos(Castle.empePos).uid)
    end
  
    Woe.removePre()
    Woe.removePortals()
  
    doRemoveItem(getThingFromPos(Castle.desde).uid)
  
    Woe.save()
  
    for _, cid in ipairs(getPlayersOnline()) do
        if infoLua[2] == getPlayerGuildId(cid) then
            doPlayerAddMoney(cid, reward)
                     doPlayerAddItem(cid, itemid2)
        end
    end
  
    Woe.remove()
    setGlobalStorageValue(24503, -1)
  
end

function onThink(interval, lastExecution)
    Woe.getInfo()
    if Woe.isTime() then
        if not Woe.isStarted() then
            doSummonCreature("empe", Castle.empePos)
            doSummonCreature("pre1", Castle.PreEmpes[1])
            doSummonCreature("pre2", Castle.PreEmpes[2])
            doBroadcastMessage("Castle iniciado...", config.bcType)
            setGlobalStorageValue(stor.Started, 1)
            Woe.updateInfo({os.time(), infoLua[2], infoLua[3], infoLua[4]})
            doCreateTeleport(1387, Castle.pos, Castle.desde)
            addEvent(EndWoe, config.timeToEnd * 60 * 1000)
        end
    end
    return true
end
 
Last edited:
holy shit another error
Code:
[Error - TalkAction Interface]
data/talkactions/scripts/woe.lua:onSay
[Description:
(luaGetPlayerNameByGUID) Player not found
[15:39:15.815] [Error - GlobalEvent Interface]
[15:39:15.815] data/globalevents/scripts/woe.lua:onThink
[15:39:15.815] Description:
[15:39:15.816] ./_woe.lua:59: attempt to concatenate field '?' (a nil value)
[15:39:15.816] stack traceback:
[15:39:15.816]  ./_woe.lua:59: in function 'updateInfo'
[15:39:15.816]  data/globalevents/scripts/woe.lua:55: in function <data/globalevents/scripts/woe.lua:46>
[15:39:15.816] [Error - GlobalEvents::think] Couldn't execute event: WoE


the _woe.lua is above
the globalevents/woe.lua below

Code:
dofile("./_woe.lua")

local config = woe_config

local reward = 1000000 -- 1kk
local itemid2 = 10127
local function EndWoe()
    Woe.getInfo()
     
    setGlobalStorageValue(stor.Started, 0)
    setGlobalStorageValue(stor.WoeTime, 0)
 
    Woe.expulsar(infoLua[2], Castle.salas.a.fromx, Castle.salas.a.tox, Castle.salas.a.fromy, Castle.salas.a.toy, Castle.salas.a.z, Castle._exit)
    Woe.expulsar(infoLua[2], Castle.salas.b.fromx, Castle.salas.b.tox, Castle.salas.b.fromy, Castle.salas.b.toy, Castle.salas.b.z, Castle._exit)
    Woe.expulsar(infoLua[2], Castle.salas.c.fromx, Castle.salas.c.tox, Castle.salas.c.fromy, Castle.salas.c.toy, Castle.salas.c.z, Castle._exit)
       Woe.expulsar(infoLua[2], Castle.salas.d.fromx, Castle.salas.d.tox, Castle.salas.d.fromy, Castle.salas.d.toy, Castle.salas.d.z, Castle._exit)
       Woe.expulsar(infoLua[2], Castle.salas.e.fromx, Castle.salas.e.tox, Castle.salas.e.fromy, Castle.salas.e.toy, Castle.salas.e.z, Castle._exit)
 
 
    doBroadcastMessage("Castle finalizado", config.bcType)
    doBroadcastMessage("O " .. Castle.name .. " foi dominado por ".. Woe.guildName() ..".", config.bcType)
 
    if isCreature(getThingFromPos(Castle.empePos).uid) then
        doRemoveCreature(getThingFromPos(Castle.empePos).uid)
    end
 
    Woe.removePre()
    Woe.removePortals()
 
    doRemoveItem(getThingFromPos(Castle.desde).uid)
 
    Woe.save()
 
    for _, cid in ipairs(getPlayersOnline()) do
        if infoLua[2] == getPlayerGuildId(cid) then
            doPlayerAddMoney(cid, reward)
                     doPlayerAddItem(cid, itemid2)
        end
    end
 
    Woe.remove()
    setGlobalStorageValue(24503, -1)
 
end

function onThink(interval, lastExecution)
    Woe.getInfo()
    if Woe.isTime() then
        if not Woe.isStarted() then
            doSummonCreature("empe", Castle.empePos)
            doSummonCreature("pre1", Castle.PreEmpes[1])
            doSummonCreature("pre2", Castle.PreEmpes[2])
            doBroadcastMessage("Castle iniciado...", config.bcType)
            setGlobalStorageValue(stor.Started, 1)
            Woe.updateInfo({os.time(), infoLua[2], infoLua[3], infoLua[4]})
            doCreateTeleport(1387, Castle.pos, Castle.desde)
            addEvent(EndWoe, config.timeToEnd * 60 * 1000)
        end
    end
    return true
end

You didn't post "data/talkactions/scripts/woe.lua:eek:nSay"
 
You didn't post "data/talkactions/scripts/woe.lua:eek:nSay"

Code:
dofile("./_woe.lua")

local config = woe_config

function onSay(cid, words, param)

    if words == "/castle" and param == "/!/SETUPX2" then
        Woe.setup()
        return true
    end
  
    Woe.getInfo()
  
    local myTable = {}
  
    for _, i in ipairs({"%d", "%B", "%Y", "%X"}) do
        table.insert(myTable, os.date(i, infoLua[4]))
    end
  
    if Woe.isStarted() then
        text = "time left = " ..  Woe.timeToEnd().mins .. ":" .. Woe.timeToEnd().secs .. "\nActually the castle " .. Castle.name .. " is owned by " .. Woe.guildName() .. ".\n" .. Woe.breakerName() .. " broke the empe at "..myTable[1].." / "..myTable[2].." / "..myTable[3].." at time "..myTable[4].."."
    else
        text = "the last Bless Castle was won by " .. Woe.guildName() .. ".\n" .. Woe.breakerName() .. " broke the empe at "..myTable[1].." / "..myTable[2].." / "..myTable[3].." at time "..myTable[4].."."
    end

    if words == "/castle" then
        if getPlayerAccess(cid) >= config.accessToStar then
            if param == "on" then
                if Woe.isTime() ~= true then
                    doBroadcastMessage("Castle vai começar agora! Para Informações do evento acesse o site.", config.bcType)
                    doBroadcastMessage("terá uma duração de " .. config.timeToEnd .. " minutos.", config.bcType)
                    setGlobalStorageValue(stor.WoeTime, 1)
                else
                    doPlayerSendCancel(cid, "Castle is already running.")
                end
            elseif param == "off" then
                if Woe.isTime() == true then
                    doBroadcastMessage("Castle was canceled...", config.bcType)
                    setGlobalStorageValue(stor.WoeTime, 0)
                    setGlobalStorageValue(stor.Started, 0)
                    if isCreature(getThingFromPos(Castle.empePos).uid) == TRUE then
                        doRemoveCreature(getThingFromPos(Castle.empePos).uid)
                    end
                    if getThingFromPos(Castle.desde).itemid > 0 then
                        doRemoveItem(getThingFromPos(Castle.desde).uid)
                    end
                    Woe.removePre()
                    Woe.removePortals()
                else
                    doPlayerSendCancel(cid, "Castle is not running.")
                end
            elseif param == "empe" then
                doSummonCreature("empe", Castle.empePos)
            elseif param == "go" then
                local newPos = Castle.empePos
                newPos.y = newPos.y + 1
                doTeleportThing(cid, newPos, FALSE)
            elseif param == "info" then
                doPlayerPopupFYI(cid, text)
            else
                doPlayerSendCancel(cid, "not valid param.")
            end
        elseif getPlayerAccess(cid) < config.accessToStar then
            if param == "info" then
                doPlayerPopupFYI(cid, text)
            end
        else
            doPlayerSendCancel(cid, "not possible.")
        end  
    elseif words == "!recall" then
        if Woe.isStarted() == true then
            if getPlayerGuildLevel(cid) == GUILDLEVEL_LEADER then
                if Woe.isInCastle(cid) == true then
                    local members = Woe.getGuildMembers(getPlayerGuildId(cid))
                    if #members > 1 then
                        if(exhaust(cid, stor.recall, config.recallTime) == 1) then
                            for _, i in ipairs(members) do
                                if getPlayerGuildLevel(i) ~= GUILDLEVEL_LEADER then
                                    local pos = getClosestFreeTile(cid, getCreaturePosition(cid), FALSE, TRUE)
                                    doTeleportThing(i, pos, FALSE)
                                end
                            end
                            doCreatureSay(cid, "Emergency Recall", TALKTYPE_SAY)
                        else
                            doPlayerSendCancel(cid, "you can only use this every " .. config.recallTime / 60 .. " minutes.")
                        end      
                    else
                        doPlayerSendCancel(cid, "no members online.")
                    end
                else
                    doPlayerSendCancel(cid, "only can be used in the castle.")
                end
            else
                doPlayerSendCancel(cid, "you are not the leader.")
            end
        else
            doPlayerSendCancel(cid, "Castle is not running.")
        end
    end
    return true
end
 
i didnt posted before cuz i thought error was on _woe.lua again and I still think it lol
its posted first msg but i'll repost

_WOE.LUA
Code:
dofile("./var.woe")

local config = woe_config

fileStore = true

infoFile = 'tmp.woe'
infoLua = {}

Woe = {}
Woe.__index = Woe

function Woe.setup()
    db.executeQuery("DROP TABLE IF EXISTS `woe`;")
    db.executeQuery("CREATE TABLE `woe` (`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,`started` INT( 11 ) NOT NULL ,`guild` INT( 11 ) NOT NULL ,`breaker` INT( 11 ) NOT NULL ,`time` INT( 11 ) NOT NULL ,PRIMARY KEY ( `id` ) ,UNIQUE (`id`)) ENGINE = MYISAM")
    doBroadcastMessage("DB Added [...]", config.bcType)
    if fileStore then
        local newFile = io.open(infoFile, "w")
        for _, i in ipairs({'started', 'guild', 'breaker', 'time'}) do
            newFile:write(i .. ' = 0 ;end;\n')
        end
        newFile:close()
    else
        db.executeQuery("DROP TABLE IF EXISTS `tmpwoe`;")
        db.executeQuery("CREATE TABLE `tmpwoe` (`started` INT( 11 ) NOT NULL ,`guild` INT( 11 ) NOT NULL ,`breaker` INT( 111 ) NOT NULL ,`time` INT( 1 ) NOT NULL) ENGINE = MYISAM ;")
        db.executeQuery("ALTER TABLE `tmpwoe` ADD `indexer` INT NOT NULL ")
        db.executeQuery("INSERT INTO `tmpwoe` (`started` ,`guild` ,`breaker` ,`time`, `indexer`)VALUES ('0', '0', '0', '0', '1');")
    end
end

function Woe.getInfo()
    if fileStore then
        local open = io.open(infoFile, "r")
        if open then
            for i in io.lines(infoFile) do 
                for v, k in ipairs({'started', 'guild', 'breaker', 'time'}) do
                    if (i:find(k)) then
                        n = i:match(k .. '.*')
                        infoLua[v] = tonumber(n:sub(n:find('=') + 2, n:find(';end;') - 2))
                    end
                end
            end
            open:close()
        end
    else
        for v, k in ipairs({'started', 'guild', 'breaker', 'time'}) do
            local tmp = db.getResult("SELECT " .. k .. " FROM `tmpwoe` WHERE `indexer` = '1';")
            infoLua[v] = tmp:getDataInt(k)
            tmp:free()
        end
    end
end

function Woe.updateInfo(tab)
    if fileStore then
        local open = io.open(infoFile, "w")
        if open then
            for k, i in ipairs({'started', 'guild', 'breaker', 'time'}) do
                open:write(i .. ' = ' .. tab[k] .. ' ;end;\n')
            end
            open:close()
        end
    else
        for v, k in ipairs({'started', 'guild', 'breaker', 'time'}) do
            db.executeQuery("UPDATE `tmpwoe` SET " .. k .. " =  " .. tab[v] .. " WHERE `indexer` = 1;")
        end
    end
end

function Woe.save()
    Woe.getInfo()
    db.executeQuery("INSERT INTO `woe` (`started`, `guild`, `breaker`, `time`) VALUES (" .. infoLua[1] .. ", " .. infoLua[2] .. ", " .. infoLua[3] .. ", " .. infoLua[4] .. ");")
end

function Woe.getGuildName(id)
    local res = db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. id .. ";")
    if (res:getID() ~= -1) then
        ret = res:getDataString('name')
        res:free()
    end
    return ret
end

function Woe.breakerName()
    Woe.getInfo()
    return infoLua[3] ~= 0 and getPlayerNameByGUID(infoLua[3]) or 'None'
end

function Woe.guildName()
    Woe.getInfo()
    return tonumber(infoLua[2]) and (infoLua[2] ~= 0 and Woe.getGuildName(infoLua[2])) or 'Nones'
end

function Woe.startTime()
    Woe.getInfo()
    return os.date("%d %B %Y %X ", infoLua[1])
end

function Woe.breakTime()
    Woe.getInfo()
    return os.date("%d %B %Y %X ", infoLua[4])
end

function Woe.timeToEnd()
    Woe.getInfo()
    local myTable = {}
    for k, i in ipairs({"%M", "%S"}) do
        myTable[k] = os.date(i, os.difftime(os.time(), infoLua[1]))
    end
    return {mins = ((config.timeToEnd - 1) - myTable[1]), secs = (60 - myTable[2])}
end

function Woe.moveBack(cid, fromPosition, text)
    doTeleportThing(cid, fromPosition, TRUE)
    doPlayerSendCancel(cid, text)
end

function Woe.getGuildMembers(id)
    local members = {}
    for _, i in ipairs(getPlayersOnline()) do
        if id == getPlayerGuildId(i) then
            table.insert(members, i)
        end
    end
    return members
end

function Woe.deco(text)
    for _, i in ipairs(Castle.decoraciones) do
        doItemSetAttribute(i, "description", text)
    end
end

function Woe.removePortals()
    for _, i in ipairs(Castle.PrePortalsPos) do
        if (getThingFromPos(i).itemid > 0) then
            doRemoveItem(getThingFromPos(i).uid)
        end
    end
end

function Woe.removePre()
    for _, i in ipairs(Castle.PreEmpes) do
        if (isCreature(getThingFromPos(i).uid) == true) then
            doRemoveCreature(getThingFromPos(i).uid)
        end
    end
end

function Woe.checkPre()
    local Count = 0
    for _, i in ipairs(Castle.PreEmpes) do
        if (isCreature(getThingFromPos(i).uid) == false) then
            Count = Count + 1
        end
    end
    return (Count == #Castle.PreEmpes)
end

function Woe.isTime()
    return (getGlobalStorageValue(stor.WoeTime) == 1)
end

function Woe.isStarted()
    return (getGlobalStorageValue(stor.Started) == 1)
end

function Woe.isRegistered(cid)
    return (getPlayerStorageValue(cid, stor.register) == 1)
end

function Woe.isInCastle(cid)
    local myPos = getCreaturePosition(cid)
    if (myPos.x >= Castle.salas.a.fromx and myPos.x <= Castle.salas.a.tox) then
        if (myPos.y >= Castle.salas.a.fromy and myPos.y <= Castle.salas.a.toy) then
            if isInArray({Castle.salas.a.z, Castle.salas.b.z, Castle.salas.c.z, Castle.salas.d.z, Castle.salas.e.z}, myPos.z) then
                return true
            end
        end
    end
    return false
end

function Woe.expulsar(guild, fromx, tox, fromy, toy, z, outpos)
    for _x = fromx, tox do
        for _y = fromy, toy do
            local player = getThingFromPos({x = _x, y = _y, z = z, stackpos = 253}).uid
            if (isPlayer(player) == true) then
                if (getPlayerGuildId(player) ~= guild) then
                    doTeleportThing(player, outpos, false)
                end
            end
        end
    end
end

-- extras

function doSetItemActionId(uid, action)
    doItemSetAttribute(uid, "aid", action)
end

function exhaust(cid, storevalue, exhausttime)
-- Exhaustion function by Alreth, v1.1 2006-06-24 01:31
-- Returns 1 if not exhausted and 0 if exhausted
    newExhaust = os.time()
    oldExhaust = getPlayerStorageValue(cid, storevalue)
    if (oldExhaust == nil or oldExhaust < 0) then
        oldExhaust = 0
    end
    if (exhausttime == nil or exhausttime < 0) then
        exhausttime = 1
    end
    diffTime = os.difftime(newExhaust, oldExhaust)
    if (diffTime >= exhausttime or diffTime < 0) then
        setPlayerStorageValue(cid, storevalue, newExhaust) 
        return 1
    else
        return 0
    end
end

--new
guard_pos = 
    {
        {x = 1237, y = 1025, z = 6},
        {x = 1238, y = 1025, z = 6},
        {x = 1239, y = 1025, z = 6},
        {x = 1240, y = 1025, z = 6},
        {x = 1241, y = 1025, z = 6},
        {x = 1236, y = 1025, z = 6},
        {x = 1235, y = 1025, z = 6}
    }
   
function Woe.check()
    for storage = 24504, 24511 do
        local pid = getGlobalStorageValue(storage)
        if isCreature(pid) then
            return false
        end
    end
    return true
end

function Woe.summon()
    for k, i in ipairs(guard_pos) do
        local pid = doSummonCreature("guard", i)
        setGlobalStorageValue(24503 + k, pid)
    end
end

function Woe.remove()
    for storage = 24504, 24511 do
        local pid = getGlobalStorageValue(storage)
        if isCreature(pid) then
            doRemoveCreature(pid)
        end
    end
end
 
well i changed
fileStore = true to false
and added sql table to database, so it seems that sttoped to use the tmp.woe file and its using sql table
seems working now
 
Back
Top