• 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+ Gold Converter

Kownikuzyt

Member
Joined
Feb 11, 2020
Messages
170
Solutions
1
Reaction score
8
Hello, I would like this script to detect and change money. It is possible?

I am using the TFS 1.1 engine.



XML:
<action itemid="11773" script="goldconverter.lua" />



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

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local coin = config[target.itemid]
 
    if not coin then
        return false
    end
 
    local charges = item:getCharges()
        if coin.changeTo and target.type == 100 then
        target:remove()
        player:addItem(coin.changeTo, 1)
        item:transform(item:getId(), charges -1)
    elseif coin.changeBack then
        target:transform(target.itemid, target.type - 1)
        player:addItem(coin.changeBack, 100)
        item:transform(item:getId(), charges -1)
        else
        return false
    end
    if charges == 0 then
    item:remove()
    end
    return true
end
 
Solution
@Xikini

[...]
Player: Lee triggered !shop talkaction.
Processing type 1: itemids
Player: Lee triggered !shop talkaction.
Processing type 1: itemids
Saving server...

Lee has logged out.
Gold Converter - target.itemid = 0
Gold Converter - target.itemid = 0
So that tells me that you aren't using the gold converter on a stack of coins.

Use with -> click on coins
@Xikini

If you remove this parameter, can you convert 100 gold coins into 1 platinum coin and 100 platinum coin into 1 Crystal coins? If so, I will ask you to remove the redundant code.
There is no redundant code.. wtf
You literally just don't understand what I'm saying.

whatever. I'm not helping further. since you can't understand.

Here's perm gold converter.
Enjoy.

Lua:
local goldCoin = 2148
local platCoin = 2152
local crysCoin = 2160

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local goldCount, goldRemoved = player:getItemCount(goldCoin), 0
    local platCount, platRemoved = player:getItemCount(platCoin), 0
    
    goldCount = math.floor(goldCount/100)
    while goldCount > 0 do
        goldCount = goldCount - 1
        goldRemoved = goldRemoved + 1
        platCount = platCount + 1
    end
    
    platCount = math.floor(platCount/100)
    while platCount > 0 do
        platCount = platCount - 1
        platRemoved = platRemoved + 1
    end
    
    if goldRemoved > 0 then
        player:removeItem(goldCoin, goldRemoved * 100)
        player:addItem(platCoin, goldRemoved)
    end
    
    if platRemoved > 0 then
        player:removeItem(platCoin, platRemoved * 100)
        player:addItem(crysCoin, platRemoved)
    end
    
    local text = "No stacks of coins needed to be converted."
    if goldRemoved > 0 or platRemoved > 0 then
        text = text .. (goldRemoved == 0 and "" or " Converted " .. goldRemoved .. " stack" .. (goldRemoved > 0 and "s" or "") .. " of gold coins.")
        text = text .. (platRemoved == 0 and "" or " Converted " .. platRemoved .. " stack" .. (platRemoved > 0 and "s" or "") .. " of platinum coins.")
        fromPosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
    end
    player:sendTextMessage(MESSAGE_DAMAGE_RECEIVED, text)
    return true
end
 
There is no redundant code.. wtf
You literally just don't understand what I'm saying.

whatever. I'm not helping further. since you can't understand.

Here's perm gold converter.
Enjoy.

Lua:
local goldCoin = 2148
local platCoin = 2152
local crysCoin = 2160

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local goldCount, goldRemoved = player:getItemCount(goldCoin), 0
    local platCount, platRemoved = player:getItemCount(platCoin), 0
   
    goldCount = math.floor(goldCount/100)
    while goldCount > 0 do
        goldCount = goldCount - 1
        goldRemoved = goldRemoved + 1
        platCount = platCount + 1
    end
   
    platCount = math.floor(platCount/100)
    while platCount > 0 do
        platCount = platCount - 1
        platRemoved = platRemoved + 1
    end
   
    if goldRemoved > 0 then
        player:removeItem(goldCoin, goldRemoved * 100)
        player:addItem(platCoin, goldRemoved)
    end
   
    if platRemoved > 0 then
        player:removeItem(platCoin, platRemoved * 100)
        player:addItem(crysCoin, platRemoved)
    end
   
    local text = "No stacks of coins needed to be converted."
    if goldRemoved > 0 or platRemoved > 0 then
        text = text .. (goldRemoved == 0 and "" or " Converted " .. goldRemoved .. " stack" .. (goldRemoved > 0 and "s" or "") .. " of gold coins.")
        text = text .. (platRemoved == 0 and "" or " Converted " .. platRemoved .. " stack" .. (platRemoved > 0 and "s" or "") .. " of platinum coins.")
        fromPosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
    end
    player:sendTextMessage(MESSAGE_DAMAGE_RECEIVED, text)
    return true
end

@Xikini

Thank you very much :)
 
Back
Top