• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

changegold.lua error

zxzxzx

New Member
Joined
Mar 12, 2011
Messages
334
Reaction score
3
Hello! I have error in my changegold.lua script (deprecated function , compat.lua 390 in function "doSentAnimatedText" Lines 1/34

code
Code:
function onUse(cid, item, fromPos, itemEx, toPos)
    if item.itemid == ITEM_GOLD_COIN and item.type == ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, ITEM_PLATINUM_COIN, 1)
        doSendAnimatedText(fromPos, "$$$", TEXTCOLOR_LIGHTBLUE)
    elseif item.itemid == ITEM_PLATINUM_COIN and item.type == ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, 1)
        doSendAnimatedText(fromPos, "$$$", TEXTCOLOR_TEAL)
    elseif item.itemid == ITEM_CRYSTAL_COIN and item.type == ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, ITEM_GOLD_NUGGET, 1)
        doSendAnimatedText(fromPos, "$$$", TEXTCOLOR_GREEN)
    elseif item.itemid == ITEM_GOLD_NUGGET and item.type == ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, ITEM_GOLD_INGOT, 1)
        doSendAnimatedText(fromPos, "$$$", TEXTCOLOR_GREEN)

    elseif item.itemid == ITEM_PLATINUM_COIN and item.type < ITEMCOUNT_MAX then
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, ITEM_GOLD_COIN, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPos, "$$$", TEXTCOLOR_YELLOW)
    elseif item.itemid == ITEM_CRYSTAL_COIN then
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, ITEM_PLATINUM_COIN, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPos, "$$$", TEXTCOLOR_LIGHTBLUE)
    elseif item.itemid == ITEM_GOLD_NUGGET then
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, ITEM_CRYSTAL_COIN, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPos, "$$$", TEXTCOLOR_GREEN)
    elseif item.itemid == ITEM_GOLD_INGOT then
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, ITEM_GOLD_NUGGET, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPos, "$$$", TEXTCOLOR_GREEN)
    else
        return FALSE
    end
    return TRUE
end

using tfs 1.2 (10.77)

HELP for rep++
 
Printer, yes I know but I want to use my script for gold ingots/nuggets becouse this standard script don't work with new value
 
like this: ?

Code:
local config = {
    [ITEM_GOLD_COIN] = {changeTo = ITEM_PLATINUM_COIN},
    [ITEM_PLATINUM_COIN] = {changeBack = ITEM_GOLD_COIN, changeTo = ITEM_CRYSTAL_COIN},
    [ITEM_CRYSTAL_COIN] = {changeBack = ITEM_PLATINUM_COIN, changeTo = ITEM_GOLD_NUGGET},
    [ITEM_GOLD_NUGGET] = {changeBack = ITEM_CRYSTAL_COIN, changeTo = ITEM_GOLD_INGOT},
    [ITEM_GOLD_INGOT] = {changeBack = ITEM_GOLD_NUGGET}
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local coin = config[item:getId()]
    if coin.changeTo and item.type == 100 then
        item:remove()
        player:addItem(coin.changeTo, 1)
    elseif coin.changeBack then
        item:remove(1)
        player:addItem(coin.changeBack, 100)
    else
        return false
    end
    return true
end


actions:

Code:
    <action itemid="2148" script="other/changegold.lua"/>
    <action itemid="2152" script="other/changegold.lua"/>
    <action itemid="2160" script="other/changegold.lua"/>
    <action itemid="2157" script="other/changegold.lua"/> <!-- Gold Nugget -->
    <action itemid="9971" script="other/changegold.lua"/> <!-- 1 Gold Ingot -->
 
ITEM_GOLD_NUGGET and ITEM_GOLD_INGOT are not defined enums in the source, change those in the table. To their respective itemId instead.
 
In my global.lua I added
Code:
ITEM_GOLD_COIN = 2148
ITEM_PLATINUM_COIN = 2152
ITEM_CRYSTAL_COIN = 2160
ITEM_GOLD_NUGGET = 2157
ITEM_GOLD_INGOT = 9971

I have to edit the source?
 
ITEM_GOLD_NUGGET and ITEM_GOLD_INGOT are not defined enums in the source, change those in the table. To their respective itemId instead.
Well since that, how could npc now that <gold nugget> is money? -- should be source edit..
 

Similar threads

Back
Top