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

TFS 1.X+ /i not creating items with charges over 100

Extrodus

|| Blazera.net ||
Premium User
Joined
Dec 22, 2008
Messages
2,737
Solutions
7
Reaction score
541
Location
Canada
Use this in your script:

Lua:
local fieryHeadchopper = player:addItem(18407, 1) -- id of fiery, amount of items to give
fieryHeadchopper:setAttribute('charges', 200) -- amount of charges
to give item with more than 100 charges.

You can also use new talkaction, edited /i by me:

talkactions.xml:
<talkaction words="/ich" separator=" " script="create_itemCharge.lua" />

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

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:splitTrimmed(",")

    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 charges = tonumber(split[2])
    if charges then
        if itemType:hasShowCharges() then
            charges = math.max(0, charges)
        else
            player:sendCancelMessage("Item must be: showcharges = 1 in items.xml")
            charges = 0
        end
    else
        charges = 0
    end

    local result = player:addItem(itemType:getId(), 1)
    if result then
        if charges > 0 then
        result:setAttribute('charges', charges)
        end
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    end
    return false
end

Example usage:
/ich itemID, chargesAmount

/ich 18407, 203 will give prismatic necklace with 203 charges.
In script I set condition that the item must have showcharges attribute in items.xml enabled (if it isnt, given item wont have charges). You can delete it if you want to.
 
Last edited:
Back
Top