• 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 [TFS 1.2] !commands full list of commands from talkactions.xml

Shadow Dan

Sh4dowDan
Joined
Jun 5, 2010
Messages
344
Reaction score
88
Location
Poland
Very useful command that shows you list of possible commands.
I didn't found a single script working with new TFS versions.
This type of coding is too hard for me for now. Could be nice if anyone have any ideas how to upgrade this script.


Old code from TFS with tibia version 8.6
Code:
local config = {
    ingameGuilds = getBooleanFromString(getConfigValue('ingameGuildManagement'))
}

function onSay(cid, words, param, channel)
if(not checkExhausted(cid, 555, 5)) then
    return true
end
    local playerAccess, t = getPlayerAccess(cid), {}
    for i, talk in ipairs(getTalkActionList()) do
        if(not talk.hidden and playerAccess >= talk.access) then
            if(config.ingameGuilds or (talk.functionName ~= "guildjoin" and talk.functionName ~= "guildcreate")) then
                table.insert(t, talk)
            end
        end
    end

    table.sort(t, function(a, b) return a.access > b.access end)
    local lastAccess, str = -1, ""
    for i, talk in ipairs(t) do
        local line = ""
        if(lastAccess ~= talk.access) then
            if(i ~= 1) then
                line = "\n"
            end
            lastAccess = talk.access
        end
        str = str .. line .. talk.words .. "\n"
    end

    doShowTextDialog(cid, 2160, str)
    return true
end
 
Solution
Xeraphus how to use this function?
I give it a try and there was an empty result.
put this function in your lib
https://otland.net/threads/getfilekeywords-file-keywords-requireall.247695/
Code:
function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end
    local list = getFileKeywords([[data\talkations\talkactions.xml]], {{keyword= 'words', index = 'words'}})
    local t = {}
    for i = 1, #list do
        table.insert(t, list[i].words)
    end
    doShowTextDialog(player:getId(), 1950, table.concat(t, '\n'))
    return true
end
Code:
function getTalkactionList()
    local list = {}
    local i = 0
    for line in io.lines([[data\talkactions\talkactions.xml]]) do
        local words, script = line:find('words="(.-)"'), line:find('script="(.-)"')
        if words and script then
            i = i + 1
            list[i] = {
                words     = line:match('words="(.-)"'),
                separator = line:match('separator="(.-)"'),
                script    = line:match('script="(.-)"')
            }
        end
    end
    return list
end
 
Code:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/testScript.lua:onSay
data/talkactions/scripts/testScript.lua:105: attempt to concatenate a table value
stack traceback:
        [C]: in function '__concat'
        data/talkactions/scripts/testScript.lua:105: in function <data/talkactions/scripts/testScript.lua:27>
 
Code:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/testScript.lua:onSay
data/talkactions/scripts/testScript.lua:105: attempt to concatenate a table value
stack traceback:
        [C]: in function '__concat'
        data/talkactions/scripts/testScript.lua:105: in function <data/talkactions/scripts/testScript.lua:27>
wat
whats 105
 
I also had this problem on my server but there's a few working and some not. I can use /a (as in teleport) and /b (as in broadcast) but not /i (spawn items), /m (summoning monsters) for example. I have no clue why this doesn't work. Is it the tfs version?
 
I also had this problem on my server but there's a few working and some not. I can use /a (as in teleport) and /b (as in broadcast) but not /i (spawn items), /m (summoning monsters) for example. I have no clue why this doesn't work. Is it the tfs version?
you have to change your account type to 5/3
 
That's not the issue. I am a god on the account. I can use certain commands but not near all of them.
god on the account or the player lol
you have to have ACCOUNT_TYPE_GOD to execute those other commands
you have to edit types to 5 on your account in mysql
8LVH2dz.png
 
Xeraphus how to use this function?
I give it a try and there was an empty result.
put this function in your lib
https://otland.net/threads/getfilekeywords-file-keywords-requireall.247695/
Code:
function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end
    local list = getFileKeywords([[data\talkations\talkactions.xml]], {{keyword= 'words', index = 'words'}})
    local t = {}
    for i = 1, #list do
        table.insert(t, list[i].words)
    end
    doShowTextDialog(player:getId(), 1950, table.concat(t, '\n'))
    return true
end
 
Solution
Code:
function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end
    local list = getFileKeywords([[data\talkations\talkactions.xml]], {{keyword= 'words', index = 'words'}})
    local t = {}
    for i = 1, #list do
        table.insert(t, list[i].words)
    end
    doShowTextDialog(player:getId(), 1950, table.concat(t, '\n'))
    return true
end

Code:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/1.lua:onSay
data/talkactions/scripts/1.lua:5: attempt to call global 'getFileKeywords' (a nil value)
stack traceback:
        [C]: in function 'getFileKeywords'
        data/talkactions/scripts/1.lua:5: in function <data/talkactions/scripts/1.lua:1>
 
Code:
function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end
    local list = getFileKeywords([[data\talkations\talkactions.xml]], {{keyword= 'words', index = 'words'}})
    local t = {}
    for i = 1, #list do
        table.insert(t, list[i].words)
    end
    doShowTextDialog(player:getId(), 1950, table.concat(t, '\n'))
    return true
end

Code:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/1.lua:onSay
data/talkactions/scripts/1.lua:5: attempt to call global 'getFileKeywords' (a nil value)
stack traceback:
        [C]: in function 'getFileKeywords'
        data/talkactions/scripts/1.lua:5: in function <data/talkactions/scripts/1.lua:1>
put this function in your lib
https://otland.net/threads/getfilekeywords-file-keywords-requireall.247695/
 
Code:
function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end
    local list = getFileKeywords([[data\talkations\talkactions.xml]], {{keyword= 'words', index = 'words'}})
    local t = {}
    for i = 1, #list do
        table.insert(t, list[i].words)
    end
    doShowTextDialog(player:getId(), 1950, table.concat(t, '\n'))
    return true
end
This is poorly written because you don't want to parse or give the impression of parsing a document everytime you call a function. What you do want to do is the cache and intelligently clear the results.
 
Back
Top