• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved change exp item from 100vs to 1vc

tuduras

Well-Known Member
Joined
Jun 4, 2017
Messages
340
Solutions
2
Reaction score
58
Hello Otlanders,
I have item 100violet skins, which is changing to 1 violet collections. 100 violet skin.webp to -->violet collection.webp . And I have got a script:
LUA:
local coins = {
    [ITEM_VIOLET_SKIN] = {
        to = ITEM_VIOLET_COLLECTION, effect = TEXTCOLOR_TEAL
    },
    [ITEM_VIOLET_COLLECTION] = {
        from = ITEM_VIOLET_SKIN, effect = TEXTCOLOR_TEAL
    }
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, 46002) < os.time() - 2 then
        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, "~Skins~", coins[coin.to].effect)
        elseif(coin.from ~= nil) then
            doChangeTypeItem(item.uid, item.type - 1)
            doPlayerAddItem(cid, coin.from, ITEMCOUNT_MAX)
            doSendAnimatedText(fromPosition, "~Skins~", coins[coin.from].effect)
        end
        return true
    end
end

after which occurs ERROR in console. console error.webp
Can You help me ?
I'm using otx 2.16 based on 0.3.7
 
You can define item consts in the const.h file found in your sources folder. Once you rebuild, the const will be available in both sources and Lua environments.

Below is where they are located for current TFS, It should be similar for otx 2.16
forgottenserver/src/const.h at master · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/master/src/const.h#L520)

and you register the enum here:
forgottenserver/src/luascript.cpp at master · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/master/src/luascript.cpp#L1794)
 
Basically, look at ITEM_GOLD_COIN, this variable can be used in Lua scripts because it is defined in the sources. You can make your own by following what i said to do.
(You can also define it globally in a global lua lib file, which skips the need for compilation)

Otherwise, using fixed ID's will do. You're welcome!
 
Last edited:
Back
Top