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

Solved Solved

tozikrulz

New Member
Joined
Jun 10, 2009
Messages
46
Reaction score
1
Hi, i quickly edited the change gold script in tfs 0.3.6 to add a new coin but when i reload actions this is the error that occurs

[28/05/2016 10:40:58] data/actions/scripts/other/changegold.lua:13: table index is nil

here is the script
Code:
local coins = {
    [ITEM_GOLD_COIN] = {
        to = ITEM_PLATINUM_COIN, effect = TEXTCOLOR_YELLOW
    },
    [ITEM_PLATINUM_COIN] = {
        from = ITEM_GOLD_COIN, to = ITEM_CRYSTAL_COIN, effect = TEXTCOLOR_LIGHTBLUE
    },
    [ITEM_CRYSTAL_COIN] = {
        from = ITEM_PLATINUM_COIN, to = ITEM_ANCIENT_COIN, effect = TEXTCOLOR_TEAL
    },
    [ITEM_ANCIENT_COIN] = {
        from = ITEM_CRYSTAL_COIN, effect = TEXTCOLOR_YELLOW
    }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(getPlayerFlagValue(cid, PLAYERFLAG_CANNOTPICKUPITEM)) then
        return false
    end

    local coin = coins[item.itemid]
    if(not coin) then
        return false
    end

    if(coin.to ~= nil and item.type == ITEMCOUNT_MAX) then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, coin.to, 1)
        doSendAnimatedText(fromPosition, "$$$", coins[coin.to].effect)
    elseif(coin.from ~= nil) then
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, coin.from, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPosition, "$$$", coins[coin.from].effect)
    end
    return true
end
 
and did you add it in actions.xml? aswell not only in the script file

like
Code:
    <action itemid="2148" script="other/changegold.lua" />
    <action itemid="2152" script="other/changegold.lua" />
    <action itemid="2160" script="other/changegold.lua" />
    <action itemid="ancient coin id here" script="other/changegold.lua" />
 

Similar threads

Back
Top