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?
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.