• 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 Tfs1.1 New currency problem

FLE

Member
Joined
Oct 5, 2008
Messages
422
Reaction score
24
Location
Vancouver Canada
Hello Otland,

I am having trouble getting my new currency too work here....
Before in 0.3.6 you had too add the [item_gold_nugget] into your constant.lua

I cant find a constant.lua, or anything like this in tfs 1.1

can someone explain too me what they changed constant.lua too...
because i looked everywhere for where the id's of the default coins are..
but they just aren't there..

I hope its not in the sources that would just be a pain

Thanks

<action itemid="2157" script="other/changegold.lua" />

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},

}

function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    local coin = config[item.itemid]
    if not coin then
        return false
    end

    if coin.changeTo and item.type == 100 then
        item:remove()
        player:addItem(coin.changeTo, 1)
    elseif coin.changeBack then
        item:transform(item.itemid, item.type - 1)
        player:addItem(coin.changeBack, 100)
    else
        return false
    end
    return true
end
 
Last edited by a moderator:
use this
Code:
local ITEM_GOLD_COIN = 2148
local ITEM_PLATINUM_COIN = 2152
local ITEM_CRYSTAL_COIN = 2160



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}
 
}

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
 
Code:
local ITEM_GOLD_COIN = 2148
local ITEM_PLATINUM_COIN = 2152
local ITEM_CRYSTAL_COIN = 2160
local ITEM_GOLD_NUGGET = 2157
local ITEM_GOLD_INGOT = 9971



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
 
Back
Top