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

RevScripts [1.3][OTBr] Money Change

Scrollia

Banned User
Joined
Apr 26, 2021
Messages
100
Reaction score
15
Hi, i have custom coin working like 1pc - 5cc, but then it doesnt work with regular money change 1000gp-1k- 10l->1cc
How do i connect this 2 script in one?
Lua:
local config = {
    [ITEM_GOLD_COIN] = {changeTo = ITEM_PLATINUM_COIN},
    [ITEM_PLATINUM_COIN] = {changeBack = ITEM_GOLD_COIN}
}

local changeGold = Action()
function changeGold.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

changeGold:id(2148, 2152)
changeGold:register()

Code:
local config = {
    [40407] = {changeTo = 2160},
    [2160] = {changeBack = 40407}
}

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

    if coin.changeTo then
        item:remove(1)
        player:addItem(coin.changeTo, 5)
    elseif coin.changeBack and item:getCount() >= 5 then
        item:remove(5)
        player:addItem(coin.changeBack, 1)
    end

    return true
end

changegold:id(40407, 2160)
changegold:register()




100 gp -> 1 platinum cooin.
100 platinum coin -> 1cc
5cc -> 1 pirate coiny.
and revers ofc.​
 
Solution
Try with this
Lua:
local config = {
    [ITEM_GOLD_COIN] = {changeTo = ITEM_PLATINUM_COIN, changeToReq = 100},
    [ITEM_PLATINUM_COIN] = {changeBack = ITEM_GOLD_COIN, changeBackAmount = 100, changeTo = 2160, changeToReq = 100},
    [40407] = {changeBack = 2160, changeBackAmount = 5},
    [2160] = {changeTo = 40407, changeToReq = 5, changeBack = ITEM_PLATINUM_COIN, changeBackAmount = 100},
}

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

    if coin.changeTo and item:getCount() >= coin.changeToReq then
        item:remove(coin.changeToReq)
        player:addItem(coin.changeTo, 1)
    elseif coin.changeBack then...
Try with this
Lua:
local config = {
    [ITEM_GOLD_COIN] = {changeTo = ITEM_PLATINUM_COIN, changeToReq = 100},
    [ITEM_PLATINUM_COIN] = {changeBack = ITEM_GOLD_COIN, changeBackAmount = 100, changeTo = 2160, changeToReq = 100},
    [40407] = {changeBack = 2160, changeBackAmount = 5},
    [2160] = {changeTo = 40407, changeToReq = 5, changeBack = ITEM_PLATINUM_COIN, changeBackAmount = 100},
}

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

    if coin.changeTo and item:getCount() >= coin.changeToReq then
        item:remove(coin.changeToReq)
        player:addItem(coin.changeTo, 1)
    elseif coin.changeBack then
        item:remove(1)
        player:addItem(coin.changeBack, coin.changeBackAmount)
    end

    return true
end

changegold:id(40407, 2160, 2148, 2152)
changegold:register()
 
Solution
Try with this
Lua:
local config = {
    [ITEM_GOLD_COIN] = {changeTo = ITEM_PLATINUM_COIN, changeToReq = 100},
    [ITEM_PLATINUM_COIN] = {changeBack = ITEM_GOLD_COIN, changeBackAmount = 100, changeTo = 2160, changeToReq = 100},
    [40407] = {changeBack = 2160, changeBackAmount = 5},
    [2160] = {changeTo = 40407, changeToReq = 5, changeBack = ITEM_PLATINUM_COIN, changeBackAmount = 100},
}

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

    if coin.changeTo and item:getCount() >= coin.changeToReq then
        item:remove(coin.changeToReq)
        player:addItem(coin.changeTo, 1)
    elseif coin.changeBack then
        item:remove(1)
        player:addItem(coin.changeBack, coin.changeBackAmount)
    end

    return true
end

changegold:id(40407, 2160, 2148, 2152)
changegold:register()
excelenet working
 
Back
Top