• 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 Help Change Gold

samuel157

/root
Joined
Mar 19, 2010
Messages
447
Solutions
3
Reaction score
49
Location
São Paulo, Brazil
GitHub
Samuel10M
I need 6 coins 1 gold coins turn to platinum coins then crystal coins then ignot coins then VIP coins then donate coin

Lua:
 local coins = {
[2148] = {to =
[2152] = {to =
[2160] = {to =
[2157] = {to =
[2159] = {to =
[9971] = {to =
}

function onUse(cid, item, fromPosition, itemEx, toPosition)

    if(getPlayerFlagValue(cid, PLAYERFLAG_CANNOTPICKUPITEM)) then
        return false
    end

    local coin = coins[item.itemid]
    if(not coin) then
        return false
    end

    if(coin.to ~= nil and item.type == ITEMCOUNT_MAX) then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, coin.to, 1)
    elseif(coin.from ~= nil) then
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, coin.from, ITEMCOUNT_MAX)
    end
    
    return true
end
 
Solution
Lua:
ITEM_GOLD_COIN = 2148
ITEM_PLATINUM_COIN = 2152
ITEM_CRYSTAL_COIN = 2160
ITEM_KK_COIN = 2157
ITEM_VIP_COIN = 9971
ITEM_DONATE_COIN = 2159

local coins = {
    [ITEM_GOLD_COIN] = {
        to = ITEM_PLATINUM_COIN, effect = COLOR_YELLOW
    },
    [ITEM_PLATINUM_COIN] = {
        from = ITEM_GOLD_COIN, to = ITEM_CRYSTAL_COIN, effect = COLOR_LIGHTBLUE
    },
    [ITEM_CRYSTAL_COIN] = {
        from = ITEM_PLATINUM_COIN, to = ITEM_KK_COIN, effect = COLOR_TEAL
    },
    [ITEM_KK_COIN] = {
        from = ITEM_CRYSTAL_COIN, to = ITEM_VIP_COIN, effect = COLOR_DARKORANGE
    },
    [ITEM_VIP_COIN] = {
        from = ITEM_KK_COIN, to = ITEM_DONATE_COIN, effect = COLOR_DARKORANGE
    },
    [ITEM_DONATE_COIN] = {
        from = ITEM_VIP_COIN, effect = COLOR_DARKORANGE
    }
}

function onUse(cid, item, fromPosition...
You can add new options to the change_gold.lua script. This is a default script in TFS.

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


Honestly your script is very similar you should just have to fill out the coins table. Don't set from for the first coin and don't set to for the last coin.

Code:
 local coins = {
[2148] = {to = 2152},
[2152] = {to = 2160, from = 2148},
[2160] = {to =
[2157] = {to =
[2159] = {to =
[9971] = {from 2159}
}
 

@soul4soul id of coin only 2148 2152 2160 2157 9971 2159 need change TFS 0.4 v8.60​

HELP ME PLEASE!

Lua:
 local coins = {
[2152] = {to = 2148},
[2148] = {to = 2157, from = 2152},
[2157] = {to = 9971, from = 2148},
[9971] = {to = 9970, from = 2157},
[9970] = {from = 9971},
}

function onUse(cid, item, fromPosition, itemEx, toPosition)

    if(getPlayerFlagValue(cid, PLAYERFLAG_CANNOTPICKUPITEM)) then
        return false
    end

    local coin = coins[item.itemid]
    if(not coin) then
        return false
    end

    if(coin.to ~= nil and item.type == ITEMCOUNT_MAX) then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, coin.to, 1)
    elseif(coin.from ~= nil) then
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, coin.from, ITEMCOUNT_MAX)
    end
   
    return true
end

XML:
    <action itemid="2148" event="script" value="other/changegold.lua"/>
    <action itemid="2152" event="script" value="other/changegold.lua"/>
    <action itemid="2160" event="script" value="other/changegold.lua"/>
    <action itemid="2157" event="script" value="other/changegold.lua"/>
    <action itemid="9971" event="script" value="other/changegold.lua"/>
    <action itemid="2148" event="script" value="other/changegold.lua"/>
    <action itemid="2159" event="script" value="other/changegold.lua"/>[
Post automatically merged:

#up
 
Last edited:

@soul4soul id of coin only 2148 2152 2160 2157 9971 2159 need change TFS 0.4 v8.60​

HELP ME PLEASE!

Lua:
 local coins = {
[2152] = {to = 2148},
[2148] = {to = 2157, from = 2152},
[2157] = {to = 9971, from = 2148},
[9971] = {to = 9970, from = 2157},
[9970] = {from = 9971},
}

function onUse(cid, item, fromPosition, itemEx, toPosition)

    if(getPlayerFlagValue(cid, PLAYERFLAG_CANNOTPICKUPITEM)) then
        return false
    end

    local coin = coins[item.itemid]
    if(not coin) then
        return false
    end

    if(coin.to ~= nil and item.type == ITEMCOUNT_MAX) then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, coin.to, 1)
    elseif(coin.from ~= nil) then
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, coin.from, ITEMCOUNT_MAX)
    end
 
    return true
end

XML:
    <action itemid="2148" event="script" value="other/changegold.lua"/>
    <action itemid="2152" event="script" value="other/changegold.lua"/>
    <action itemid="2160" event="script" value="other/changegold.lua"/>
    <action itemid="2157" event="script" value="other/changegold.lua"/>
    <action itemid="9971" event="script" value="other/changegold.lua"/>
    <action itemid="2148" event="script" value="other/changegold.lua"/>
    <action itemid="2159" event="script" value="other/changegold.lua"/>[
Post automatically merged:

#up
Lua:
local ITEM_SPECIAL_COIN = 12665

local coins = {
    [ITEM_GOLD_COIN] = {
        to = ITEM_PLATINUM_COIN, effect = TEXTCOLOR_YELLOW
    },
    [ITEM_PLATINUM_COIN] = {
        from = ITEM_GOLD_COIN, to = ITEM_CRYSTAL_COIN, effect = TEXTCOLOR_LIGHTBLUE
    },
    [ITEM_CRYSTAL_COIN] = {
        from = ITEM_PLATINUM_COIN, to = ITEM_SPECIAL_COIN, effect = TEXTCOLOR_TEAL
    },
    [ITEM_SPECIAL_COIN] = {
        from = ITEM_CRYSTAL_COIN, effect = 100
    }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(getPlayerFlagValue(cid, PLAYERFLAG_CANNOTPICKUPITEM)) then
        return false
    end

    local coin = coins[item.itemid]
    if(not coin) then
        return false
    end

    if(coin.to ~= nil and item.type == ITEMCOUNT_MAX and doPlayerAddItem(cid, coin.to, 1, false)) then
        doChangeTypeItem(item.uid, item.type - item.type)
        --doPlayerAddItem(cid, coin.to, 1)
        doSendAnimatedText(fromPosition, "$$$", coins[coin.to].effect)
    elseif(coin.from ~= nil and doPlayerAddItem(cid, coin.from, ITEMCOUNT_MAX, false)) then
        doChangeTypeItem(item.uid, item.type - 1)
        --doPlayerAddItem(cid, coin.from, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPosition, "$$$", coins[coin.from].effect)
    end

    return true
end
uses this code and adds the new currencies to the actions.xml and adds it to the script.
 
Lua:
--[[
copy and paste in constant.lua

ITEM_GOLD_COIN = 2148
ITEM_PLATINUM_COIN = 2152
ITEM_CRYSTAL_COIN = 2160
ITEM_GOLD_INGOT = 9971
ITEM_VIP_COIN = 0 -- change by coin id
ITEM_DONATE_COIN = 0 -- change by coin id

--]]

local coins = {
    [ITEM_GOLD_COIN] = {
        to = ITEM_PLATINUM_COIN, effect = COLOR_YELLOW
    },
    [ITEM_PLATINUM_COIN] = {
        from = ITEM_GOLD_COIN, to = ITEM_CRYSTAL_COIN, effect = COLOR_LIGHTBLUE
    },
    [ITEM_CRYSTAL_COIN] = {
        from = ITEM_PLATINUM_COIN, to = ITEM_GOLD_INGOT, effect = COLOR_TEAL
    },
    [ITEM_GOLD_INGOT] = {
        from = ITEM_CRYSTAL_COIN, to = ITEM_VIP_COIN, effect = COLOR_DARKORANGE
    },
    [ITEM_VIP_COIN] = {
        from = ITEM_GOLD_INGOT, to = ITEM_DONATE_COIN, effect = COLOR_DARKORANGE
    },
    [ITEM_DONATE_COIN] = {
        from = ITEM_VIP_COIN, effect = COLOR_DARKORANGE
    }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(getPlayerFlagValue(cid, PLAYERFLAG_CANNOTPICKUPITEM)) then
        return false
    end

    local coin = coins[item.itemid]
    if(not coin) then
        return false
    end

    if(coin.to ~= nil and item.type == ITEMCOUNT_MAX) then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, coin.to, 1)
        doSendAnimatedText(fromPosition, "$$$", coins[coin.to].effect)
    elseif(coin.from ~= nil) then
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, coin.from, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPosition, "$$$", coins[coin.from].effect)
    end

    return true
end
 
@Alberto Cabrera
Lua:
[31/08/2021 21:21:15] [Error - Action Interface]
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua
[31/08/2021 21:21:15] Description:
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua:25: table index is nil
[31/08/2021 21:21:15] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/changegold.lua)
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua:1: unexpected symbol near '='

[31/08/2021 21:21:15] [Error - Action Interface]
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua
[31/08/2021 21:21:15] Description:
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua:25: table index is nil
[31/08/2021 21:21:15] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/changegold.lua)
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua:1: unexpected symbol near '='

[31/08/2021 21:21:15] [Error - Action Interface]
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua
[31/08/2021 21:21:15] Description:
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua:25: table index is nil
[31/08/2021 21:21:15] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/changegold.lua)
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua:1: unexpected symbol near '='

[31/08/2021 21:21:15] [Error - Action Interface]
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua
[31/08/2021 21:21:15] Description:
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua:25: table index is nil
[31/08/2021 21:21:15] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/changegold.lua)
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua:1: unexpected symbol near '='

[31/08/2021 21:21:15] [Error - Action Interface]
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua
[31/08/2021 21:21:16] Description:
[31/08/2021 21:21:16] data/actions/scripts/other/changegold.lua:25: table index is nil
[31/08/2021 21:21:16] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/changegold.lua)
[31/08/2021 21:21:16] data/actions/scripts/other/changegold.lua:1: unexpected symbol near '='

[31/08/2021 21:21:16] [Error - Action Interface]
[31/08/2021 21:21:16] data/actions/scripts/other/changegold.lua
[31/08/2021 21:21:16] Description:
[31/08/2021 21:21:16] data/actions/scripts/other/changegold.lua:25: table index is nil
[31/08/2021 21:21:16] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/changegold.lua)
[31/08/2021 21:21:16] data/actions/scripts/other/changegold.lua:1: unexpected symbol near '='
[31/08/2021 21:21:16] Reloaded actions.
 
@Alberto Cabrera
Lua:
[31/08/2021 21:21:15] [Error - Action Interface]
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua
[31/08/2021 21:21:15] Description:
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua:25: table index is nil
[31/08/2021 21:21:15] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/changegold.lua)
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua:1: unexpected symbol near '='

[31/08/2021 21:21:15] [Error - Action Interface]
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua
[31/08/2021 21:21:15] Description:
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua:25: table index is nil
[31/08/2021 21:21:15] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/changegold.lua)
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua:1: unexpected symbol near '='

[31/08/2021 21:21:15] [Error - Action Interface]
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua
[31/08/2021 21:21:15] Description:
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua:25: table index is nil
[31/08/2021 21:21:15] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/changegold.lua)
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua:1: unexpected symbol near '='

[31/08/2021 21:21:15] [Error - Action Interface]
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua
[31/08/2021 21:21:15] Description:
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua:25: table index is nil
[31/08/2021 21:21:15] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/changegold.lua)
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua:1: unexpected symbol near '='

[31/08/2021 21:21:15] [Error - Action Interface]
[31/08/2021 21:21:15] data/actions/scripts/other/changegold.lua
[31/08/2021 21:21:16] Description:
[31/08/2021 21:21:16] data/actions/scripts/other/changegold.lua:25: table index is nil
[31/08/2021 21:21:16] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/changegold.lua)
[31/08/2021 21:21:16] data/actions/scripts/other/changegold.lua:1: unexpected symbol near '='

[31/08/2021 21:21:16] [Error - Action Interface]
[31/08/2021 21:21:16] data/actions/scripts/other/changegold.lua
[31/08/2021 21:21:16] Description:
[31/08/2021 21:21:16] data/actions/scripts/other/changegold.lua:25: table index is nil
[31/08/2021 21:21:16] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/changegold.lua)
[31/08/2021 21:21:16] data/actions/scripts/other/changegold.lua:1: unexpected symbol near '='
[31/08/2021 21:21:16] Reloaded actions.

ITEM_VIP_COIN = 0 -- change by coin id
ITEM_DONATE_COIN = 0 -- change by coin id
 
@Alberto Cabrera
Crystal Coin = 2160 Transform = KK Coin = 2157 Transform [VIP] Coin = 9971 Transform [DONATE] Coin = 2159


Lua:
ITEM_GOLD_COIN = 2148
ITEM_PLATINUM_COIN = 2152
ITEM_CRYSTAL_COIN = 2160
ITEM_GOLD_INGOT = 9971
ITEM_VIP_COIN = 2157
ITEM_DONATE_COIN = 2159

--]]

local coins = {
    [ITEM_GOLD_COIN] = {
        to = ITEM_PLATINUM_COIN, effect = COLOR_YELLOW
    },
    [ITEM_PLATINUM_COIN] = {
        from = ITEM_GOLD_COIN, to = ITEM_CRYSTAL_COIN, effect = COLOR_LIGHTBLUE
    },
    [ITEM_CRYSTAL_COIN] = {
        from = ITEM_PLATINUM_COIN, to = ITEM_GOLD_INGOT, effect = COLOR_TEAL
    },
    [ITEM_VIP_COIN] = {
        from = ITEM_CRYSTAL_COIN, to = ITEM_VIP_COIN, effect = COLOR_DARKORANGE
    },
    [ITEM_KK_COIN] = {
        from = ITEM_VIP_COIN, to = ITEM_DONATE_COIN, effect = COLOR_DARKORANGE
    },
    [ITEM_DONATE_COIN] = {
        from = ITEM_VIP_COIN, effect = COLOR_DARKORANGE
    }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(getPlayerFlagValue(cid, PLAYERFLAG_CANNOTPICKUPITEM)) then
        return false
    end

    local coin = coins[item.itemid]
    if(not coin) then
        return false
    end

    if(coin.to ~= nil and item.type == ITEMCOUNT_MAX) then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, coin.to, 1)
        doSendAnimatedText(fromPosition, "$$$", coins[coin.to].effect)
    elseif(coin.from ~= nil) then
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, coin.from, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPosition, "$$$", coins[coin.from].effect)
    end

    return true
end
--[[
copy and paste in constant.lua

ITEM_GOLD_COIN = 2148
ITEM_PLATINUM_COIN = 2152
ITEM_CRYSTAL_COIN = 2160
ITEM_GOLD_INGOT = 9971
ITEM_VIP_COIN = 0 -- change by coin id
ITEM_DONATE_COIN = 0 -- change by coin id

--]]

local coins = {
    [ITEM_GOLD_COIN] = {
        to = ITEM_PLATINUM_COIN, effect = COLOR_YELLOW
    },
    [ITEM_PLATINUM_COIN] = {
        from = ITEM_GOLD_COIN, to = ITEM_CRYSTAL_COIN, effect = COLOR_LIGHTBLUE
    },
    [ITEM_CRYSTAL_COIN] = {
        from = ITEM_PLATINUM_COIN, to = ITEM_GOLD_INGOT, effect = COLOR_TEAL
    },
    [ITEM_GOLD_INGOT] = {
        from = ITEM_CRYSTAL_COIN, to = ITEM_VIP_COIN, effect = COLOR_DARKORANGE
    },
    [ITEM_VIP_COIN] = {
        from = ITEM_GOLD_INGOT, to = ITEM_DONATE_COIN, effect = COLOR_DARKORANGE
    },
    [ITEM_DONATE_COIN] = {
        from = ITEM_VIP_COIN, effect = COLOR_DARKORANGE
    }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(getPlayerFlagValue(cid, PLAYERFLAG_CANNOTPICKUPITEM)) then
        return false
    end

    local coin = coins[item.itemid]
    if(not coin) then
        return false
    end

    if(coin.to ~= nil and item.type == ITEMCOUNT_MAX) then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, coin.to, 1)
        doSendAnimatedText(fromPosition, "$$$", coins[coin.to].effect)
    elseif(coin.from ~= nil) then
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, coin.from, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPosition, "$$$", coins[coin.from].effect)
    end

    return true
end

hbgfcv.png

Lua:
[31/08/2021 21:37:46] [Error - Action Interface]
[31/08/2021 21:37:46] data/actions/scripts/other/changegold.lua
[31/08/2021 21:37:46] Description:
[31/08/2021 21:37:46] data/actions/scripts/other/changegold.lua:25: table index is nil
[31/08/2021 21:37:46] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/changegold.lua)
[31/08/2021 21:37:46] data/actions/scripts/other/changegold.lua:1: unexpected symbol near '='

[31/08/2021 21:37:46] [Error - Action Interface]
[31/08/2021 21:37:46] data/actions/scripts/other/changegold.lua
[31/08/2021 21:37:46] Description:
[31/08/2021 21:37:46] data/actions/scripts/other/changegold.lua:25: table index is nil
[31/08/2021 21:37:46] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/changegold.lua)
[31/08/2021 21:37:46] data/actions/scripts/other/changegold.lua:1: unexpected symbol near '='

[31/08/2021 21:37:46] [Error - Action Interface]
[31/08/2021 21:37:46] data/actions/scripts/other/changegold.lua
[31/08/2021 21:37:46] Description:
[31/08/2021 21:37:46] data/actions/scripts/other/changegold.lua:25: table index is nil
[31/08/2021 21:37:46] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/changegold.lua)
[31/08/2021 21:37:46] data/actions/scripts/other/changegold.lua:1: unexpected symbol near '='

[31/08/2021 21:37:46] [Error - Action Interface]
[31/08/2021 21:37:46] data/actions/scripts/other/changegold.lua
[31/08/2021 21:37:46] Description:
[31/08/2021 21:37:46] data/actions/scripts/other/changegold.lua:25: table index is nil
[31/08/2021 21:37:46] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/changegold.lua)
[31/08/2021 21:37:46] data/actions/scripts/other/changegold.lua:1: unexpected symbol near '='

[31/08/2021 21:37:46] [Error - Action Interface]
[31/08/2021 21:37:46] data/actions/scripts/other/changegold.lua
[31/08/2021 21:37:46] Description:
[31/08/2021 21:37:46] data/actions/scripts/other/changegold.lua:25: table index is nil
[31/08/2021 21:37:46] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/changegold.lua)
[31/08/2021 21:37:46] data/actions/scripts/other/changegold.lua:1: unexpected symbol near '='

[31/08/2021 21:37:46] [Error - Action Interface]
[31/08/2021 21:37:46] data/actions/scripts/other/changegold.lua
[31/08/2021 21:37:46] Description:
[31/08/2021 21:37:46] data/actions/scripts/other/changegold.lua:25: table index is nil
[31/08/2021 21:37:46] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/changegold.lua)
[31/08/2021 21:37:46] data/actions/scripts/other/changegold.lua:1: unexpected symbol near '='
[31/08/2021 21:37:46] Reloaded actions.
[31/08/2021 21:38:35] > CLEAN: Removed 6 items from 5 tiles (5 were marked) in 0 seconds.
[31/08/2021 21:38:36] > Broadcasted message: "Mapa [DexSoft] Vai Ser Limpo Olha Clean Recolha Seus Items Pra Nao Perdelos.".
[31/08/2021 21:39:17] [Warning - Actions::registerEvent] Duplicate registered item uid: 7509
[31/08/2021 21:39:17] [Warning - Actions::registerEvent] Duplicate registered item id: 2553

[31/08/2021 21:39:17] [Error - Action Interface]
[31/08/2021 21:39:17] data/actions/scripts/other/changegold.lua
[31/08/2021 21:39:17] Description:
[31/08/2021 21:39:17] data/actions/scripts/other/changegold.lua:25: table index is nil
[31/08/2021 21:39:17] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/changegold.lua)
[31/08/2021 21:39:17] data/actions/scripts/other/changegold.lua:1: unexpected symbol near '='

[31/08/2021 21:39:17] [Error - Action Interface]
[31/08/2021 21:39:17] data/actions/scripts/other/changegold.lua
[31/08/2021 21:39:17] Description:
[31/08/2021 21:39:17] data/actions/scripts/other/changegold.lua:25: table index is nil
[31/08/2021 21:39:17] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/changegold.lua)
[31/08/2021 21:39:17] data/actions/scripts/other/changegold.lua:1: unexpected symbol near '='

[31/08/2021 21:39:17] [Error - Action Interface]
[31/08/2021 21:39:17] data/actions/scripts/other/changegold.lua
[31/08/2021 21:39:17] Description:
[31/08/2021 21:39:17] data/actions/scripts/other/changegold.lua:25: table index is nil
[31/08/2021 21:39:17] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/changegold.lua)
[31/08/2021 21:39:17] data/actions/scripts/other/changegold.lua:1: unexpected symbol near '='

[31/08/2021 21:39:17] [Error - Action Interface]
[31/08/2021 21:39:17] data/actions/scripts/other/changegold.lua
[31/08/2021 21:39:17] Description:
[31/08/2021 21:39:17] data/actions/scripts/other/changegold.lua:25: table index is nil
[31/08/2021 21:39:17] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/changegold.lua)
[31/08/2021 21:39:17] data/actions/scripts/other/changegold.lua:1: unexpected symbol near '='

[31/08/2021 21:39:17] [Error - Action Interface]
[31/08/2021 21:39:17] data/actions/scripts/other/changegold.lua
[31/08/2021 21:39:17] Description:
[31/08/2021 21:39:17] data/actions/scripts/other/changegold.lua:25: table index is nil
[31/08/2021 21:39:17] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/changegold.lua)
[31/08/2021 21:39:17] data/actions/scripts/other/changegold.lua:1: unexpected symbol near '='

assemble the script complete for me please!hbgfcv.png
 
Last edited:
Lua:
ITEM_GOLD_COIN = 2148
ITEM_PLATINUM_COIN = 2152
ITEM_CRYSTAL_COIN = 2160
ITEM_KK_COIN = 2157
ITEM_VIP_COIN = 9971
ITEM_DONATE_COIN = 2159

local coins = {
    [ITEM_GOLD_COIN] = {
        to = ITEM_PLATINUM_COIN, effect = COLOR_YELLOW
    },
    [ITEM_PLATINUM_COIN] = {
        from = ITEM_GOLD_COIN, to = ITEM_CRYSTAL_COIN, effect = COLOR_LIGHTBLUE
    },
    [ITEM_CRYSTAL_COIN] = {
        from = ITEM_PLATINUM_COIN, to = ITEM_KK_COIN, effect = COLOR_TEAL
    },
    [ITEM_KK_COIN] = {
        from = ITEM_CRYSTAL_COIN, to = ITEM_VIP_COIN, effect = COLOR_DARKORANGE
    },
    [ITEM_VIP_COIN] = {
        from = ITEM_KK_COIN, to = ITEM_DONATE_COIN, effect = COLOR_DARKORANGE
    },
    [ITEM_DONATE_COIN] = {
        from = ITEM_VIP_COIN, effect = COLOR_DARKORANGE
    }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(getPlayerFlagValue(cid, PLAYERFLAG_CANNOTPICKUPITEM)) then
        return false
    end

    local coin = coins[item.itemid]
    if(not coin) then
        return false
    end

    if(coin.to ~= nil and item.type == ITEMCOUNT_MAX) then
        doChangeTypeItem(item.uid, item.type - item.type)
        doPlayerAddItem(cid, coin.to, 1)
        doSendAnimatedText(fromPosition, "$$$", coins[coin.to].effect)
    elseif(coin.from ~= nil) then
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, coin.from, ITEMCOUNT_MAX)
        doSendAnimatedText(fromPosition, "$$$", coins[coin.from].effect)
    end

    return true
end
 
Solution
Back
Top