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

RevScripts god create item tfs 1.3 revscripts

Moody

New Member
Joined
Feb 8, 2020
Messages
46
Reaction score
3
iam have bug in /i but i dont know when bug produce
i see random error in tfs i dont know why and when

Lua Script Error: [Scripts Interface]
forgottenserver/data/scripts/talkactions/god/create item.lua:callback
data/scripts/talkactions/god/create item.lua:16: attempt to index local 'itemType' (a nil value)
stack traceback:
[C]: in function '__index'
...ottenserver/data/scripts/talkactions/god/create item.lua:16: in function <...ottenserver/data/scripts/talkactions/god/create item.lua:3>
script i use
Lua:
local talk = TalkAction("/i")

function talk.onSay(player, words, param)

local invalidIds = {
    1, 2, 3, 4, 5, 6, 7, 10, 11, 13, 14, 15, 19, 21, 26, 27, 28, 35, 43
}

    if not player:getGroup():getAccess() or player:getAccountType() < ACCOUNT_TYPE_GOD then
        return true
    end

    local split = param:split(",")

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

    if table.contains(invalidIds, itemType:getId()) then
        return false
    end

    local count = tonumber(split[2])
    if count 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 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

talk:separator(" ")
talk:register()
 
Solution
Lua:
local talk = TalkAction("/i")

function talk.onSay(player, words, param)

local invalidIds = {
    1, 2, 3, 4, 5, 6, 7, 10, 11, 13, 14, 15, 19, 21, 26, 27, 28, 35, 43
}

    if not player:getGroup():getAccess() or player:getAccountType() < ACCOUNT_TYPE_GOD then
        return true
    end

    local split = param:split(",")

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

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,094
Solutions
33
Reaction score
182
Lua:
local talk = TalkAction("/i")

function talk.onSay(player, words, param)

local invalidIds = {
    1, 2, 3, 4, 5, 6, 7, 10, 11, 13, 14, 15, 19, 21, 26, 27, 28, 35, 43
}

    if not player:getGroup():getAccess() or player:getAccountType() < ACCOUNT_TYPE_GOD then
        return true
    end

    local split = param:split(",")

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

    if table.contains(invalidIds, itemType:getId()) then
        return false
    end

    local count = tonumber(split[2])
    if count 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 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

talk:separator(" ")
talk:register()
 
Solution
OP
M

Moody

New Member
Joined
Feb 8, 2020
Messages
46
Reaction score
3
cant test or be sure script work or no work because i no know when and why error come on console. i go add this and see after 3 or 4 day if error come in console i back here
 

DoktorHolzbein

Banned User
Joined
Sep 29, 2020
Messages
24
Solutions
1
Reaction score
11
Location
Germany
cant test or be sure script work or no work because i no know when and why error come on console. i go add this and see after 3 or 4 day if error come in console i back here
english GIF
 
Top