• 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 Repait it please? Gold change script

walltimer

Active Member
Joined
Aug 5, 2020
Messages
170
Reaction score
26
local config = {
[40407] = {changeTo = ITEM_CRYSTAL_COIN},
[ITEM_CRYSTAL_COIN] = {changeBack = 40407}
}

local changegold = Action()

function changegold.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 == 1 then
item:remove()
player:addItem(coin.changeTo, 5)
elseif coin.changeBack then
item:transform(item.itemid, item.type - 5)
player:addItem(coin.changeBack, 1)
else
return false
end
return true
end
changegold:id(40407, 2160)
changegold:register()

5cc to 1 pirate coin and back, but when i have less than 5cc like 1-4 it makes 255c by click, why?
 
Solution
try ( tested & it works fine )
Lua:
local config = {
    [2159] = {changeTo = 2160},
    [2160] = {changeBack = 2159}
}

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(2159, 2160)
changegold:register()
Remember that if the crystal coin already has an Action() associated with it then it should not work, since only one Action() can be associated per id

Lua:
local config = {
[2159] = {changeTo = 2160},
[2160] = {changeBack = 2159}
}

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 then
        item:remove(5)
        player:addItem(coin.changeBack, 1)
    end
    return true
end
changegold:id(2159, 2160)
changegold:register()

If your coin already has an Action(), then handle this behavior from that script
 
Remember that if the crystal coin already has an Action() associated with it then it should not work, since only one Action() can be associated per id

Lua:
local config = {
[2159] = {changeTo = 2160},
[2160] = {changeBack = 2159}
}

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 then
        item:remove(5)
        player:addItem(coin.changeBack, 1)
    end
    return true
end
changegold:id(2159, 2160)
changegold:register()

If your coin already has an Action(), then handle this behavior from that script
Thank you! :)not it works good but, if i have 1-4cc it donest diseaper and keep giving me 1piratecoin, probably becouse of like u said, i have a scripted CC change,and find it, disabled and still the problem goes. Meybe u can make it for lever script ? press verver -get 5cc, give 1 pirate coin? :D Please.
 
Last edited:
try ( tested & it works fine )
Lua:
local config = {
    [2159] = {changeTo = 2160},
    [2160] = {changeBack = 2159}
}

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(2159, 2160)
changegold:register()
 
Solution
try ( tested & it works fine )
Lua:
local config = {
    [2159] = {changeTo = 2160},
    [2160] = {changeBack = 2159}
}

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(2159, 2160)
changegold:register()
WORKS!!!!!!!!!!!! GENIUS!!!!!!!!!!!!
 
Back
Top