• 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 Problem with GOD Commands

rikaardo25

New Member
Joined
May 22, 2017
Messages
10
Reaction score
0
Hello,

Its my first time posting on this forum, also new, hope you can help me here.
Im making a thread regarding about commands, and tried several thing such as changing the account type to 5 and group id 3, and still got nothing... Just getting erros


Everytime i try to execute the /i command, in game i dont get any message such as this command is invalid or this item doesnt exist.. Just getting this kind of error..

I have attached the Create_item.lua, i have change anything on it\

Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/create_item.lua:eek:nSay
data/global.lua:37: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
[C]: at 0x7ff773162e20
[C]: in function 'pairs'
data/global.lua:37: in function 'contains'
data/talkactions/scripts/create_item.lua:21: in function <data/talkactions/scripts/create_item.lua:1>

Thanks in advance,
You reply will be appreciated
 

Attachments

Solution
Your lua file is slightly different to the one provided on the official github website for TFS 1.2, replace create_item.lua with this one:

Lua:
function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

    if player:getAccountType() < ACCOUNT_TYPE_GOD then
        return false
    end

    local split = param:split(",")

    local itemType = ItemType(split[1])
    if itemType:getId() == 0 then
        itemType = ItemType(tonumber(split[1]))
        if itemType:getId() == 0 then
            player:sendCancelMessage("There is no item with that id or name.")
            return false
        end
    end

    local count = tonumber(split[2])
    if count ~= nil then
        if...
Your lua file is slightly different to the one provided on the official github website for TFS 1.2, replace create_item.lua with this one:

Lua:
function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

    if player:getAccountType() < ACCOUNT_TYPE_GOD then
        return false
    end

    local split = param:split(",")

    local itemType = ItemType(split[1])
    if itemType:getId() == 0 then
        itemType = ItemType(tonumber(split[1]))
        if itemType:getId() == 0 then
            player:sendCancelMessage("There is no item with that id or name.")
            return false
        end
    end

    local count = tonumber(split[2])
    if count ~= nil then
        if itemType:isStackable() then
            count = math.min(10000, math.max(1, count))
        elseif not itemType:isFluidContainer() then
            count = math.min(100, math.max(1, count))
        else
            count = math.max(0, count)
        end
    else
        if not itemType:isFluidContainer() then
            count = 1
        else
            count = 0
        end
    end

    local result = player:addItem(itemType:getId(), count)
    if result ~= nil then
        if not itemType:isStackable() then
            if type(result) == "table" then
                for _, item in ipairs(result) do
                    item:decay()
                end
            else
                result:decay()
            end
        end
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    end
    return false
end
 
Solution
Your lua file is slightly different to the one provided on the official github website for TFS 1.2, replace create_item.lua with this one:

Lua:
function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

    if player:getAccountType() < ACCOUNT_TYPE_GOD then
        return false
    end

    local split = param:split(",")

    local itemType = ItemType(split[1])
    if itemType:getId() == 0 then
        itemType = ItemType(tonumber(split[1]))
        if itemType:getId() == 0 then
            player:sendCancelMessage("There is no item with that id or name.")
            return false
        end
    end

    local count = tonumber(split[2])
    if count ~= nil then
        if itemType:isStackable() then
            count = math.min(10000, math.max(1, count))
        elseif not itemType:isFluidContainer() then
            count = math.min(100, math.max(1, count))
        else
            count = math.max(0, count)
        end
    else
        if not itemType:isFluidContainer() then
            count = 1
        else
            count = 0
        end
    end

    local result = player:addItem(itemType:getId(), count)
    if result ~= nil then
        if not itemType:isStackable() then
            if type(result) == "table" then
                for _, item in ipairs(result) do
                    item:decay()
                end
            else
                result:decay()
            end
        end
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    end
    return false
end


I replaced with this one, It works, it sparkle now...

Thanks bud!!
 
Back
Top