• 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 UPGRADE SCROLL [canary server]

Kyubinhok

New Member
Joined
Nov 15, 2021
Messages
1
Reaction score
0
GitHub
Kyubinhok
I need help with this script:
Click on some item an use with item to increase his tier
For example
If is thier 0 using scroll in item it change to tier 1
(And consume item)

If is tier 2 using scroll in item it change to tier 2..

And items can be increased to the maximum tier (10) for example...

I am using

Server Canary 13.21​


Please help me đź«Ł
 
Oh, no worries, thanks for trying and I'll be waiting, maybe the OP too :)
try:
Lua:
local UPGRADE_ITEM_ID = 44077
local MAX_TIER = 10  -- Maximum tier an item can be upgraded to

local function upgradeItemTier(target)
    local currentTier = target:getTier()

    if currentTier >= MAX_TIER then
        return false, "This item has reached the maximum upgrade tier."
    end

    target:setTier(currentTier + 1)
    return true, "Upgraded to tier " .. (currentTier + 1) .. " successfully!"
end

local function onUseUpgradeItem(player, item, target)
    if item:getId() == UPGRADE_ITEM_ID and target and target:isItem() then
        local success, message = upgradeItemTier(target)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, message)
        return success
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Use this item on an item to upgrade its tier.")
        return false
    end
end

local upgradeItem = Action()

function upgradeItem.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if onUseUpgradeItem(player, item, target) then
        item:remove(1)  -- Remove the upgrade item if upgrade was attempted
    end
    return true
end

upgradeItem:id(UPGRADE_ITEM_ID)
upgradeItem:register()
 
try:
Lua:
local UPGRADE_ITEM_ID = 44077
local MAX_TIER = 10  -- Maximum tier an item can be upgraded to

local function upgradeItemTier(target)
    local currentTier = target:getTier()

    if currentTier >= MAX_TIER then
        return false, "This item has reached the maximum upgrade tier."
    end

    target:setTier(currentTier + 1)
    return true, "Upgraded to tier " .. (currentTier + 1) .. " successfully!"
end

local function onUseUpgradeItem(player, item, target)
    if item:getId() == UPGRADE_ITEM_ID and target and target:isItem() then
        local success, message = upgradeItemTier(target)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, message)
        return success
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Use this item on an item to upgrade its tier.")
        return false
    end
end

local upgradeItem = Action()

function upgradeItem.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if onUseUpgradeItem(player, item, target) then
        item:remove(1)  -- Remove the upgrade item if upgrade was attempted
    end
    return true
end

upgradeItem:id(UPGRADE_ITEM_ID)
upgradeItem:register()
Hey, first of all- thank you very much for your time! :)

Since I am a total newbie before I try this script I'd like to ask you few questions- just so I make sure I get it right.

local UPGRADE_ITEM_ID = 44077
is that number just an example of an item ID that you chose? When creating different items using a GOD I use the command /i and I choose item id using this site: https://tibia.fandom.com/wiki/Item_IDs. Looking at the number that was in your script I found that it is
Cave Chair44182, 44077
I am not sure if I understand but... can I like, for example, duplicate an already existing item with some ID (for example some parchment like stuff), give it a new ID of my choice (I'd most likely just give it some weird number like 99199 or something like that), to make sure I do not break anything that is already working in game, then adjust your script by using my new item's ID instead? If yes- is editing/ duplicating already existing items through the data base or simply through itemx.xml in my OTS folder (\data\items)?

My other question would be- once the script is "ready", where should I put it?

That may look silly for you but I am, as I said, at the very beginning of OTS journey :)
 
try:
Lua:
local UPGRADE_ITEM_ID = 44077
local MAX_TIER = 10  -- Maximum tier an item can be upgraded to

local function upgradeItemTier(target)
    local currentTier = target:getTier()

    if currentTier >= MAX_TIER then
        return false, "This item has reached the maximum upgrade tier."
    end

    target:setTier(currentTier + 1)
    return true, "Upgraded to tier " .. (currentTier + 1) .. " successfully!"
end

local function onUseUpgradeItem(player, item, target)
    if item:getId() == UPGRADE_ITEM_ID and target and target:isItem() then
        local success, message = upgradeItemTier(target)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, message)
        return success
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Use this item on an item to upgrade its tier.")
        return false
    end
end

local upgradeItem = Action()

function upgradeItem.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if onUseUpgradeItem(player, item, target) then
        item:remove(1)  -- Remove the upgrade item if upgrade was attempted
    end
    return true
end

upgradeItem:id(UPGRADE_ITEM_ID)
upgradeItem:register()
now we need to add probability & tier removal, thx for the base, going to post script w this when i finish & make it work properly
 
Hey, first of all- thank you very much for your time! :)

Since I am a total newbie before I try this script I'd like to ask you few questions- just so I make sure I get it right.

local UPGRADE_ITEM_ID = 44077
is that number just an example of an item ID that you chose? When creating different items using a GOD I use the command /i and I choose item id using this site: https://tibia.fandom.com/wiki/Item_IDs. Looking at the number that was in your script I found that it is
Cave Chair44182, 44077
I am not sure if I understand but... can I like, for example, duplicate an already existing item with some ID (for example some parchment like stuff), give it a new ID of my choice (I'd most likely just give it some weird number like 99199 or something like that), to make sure I do not break anything that is already working in game, then adjust your script by using my new item's ID instead? If yes- is editing/ duplicating already existing items through the data base or simply through itemx.xml in my OTS folder (\data\items)?

My other question would be- once the script is "ready", where should I put it?

That may look silly for you but I am, as I said, at the very beginning of OTS journey :)

Hey, first of all- thank you very much for your time! :)

Since I am a total newbie before I try this script I'd like to ask you few questions- just so I make sure I get it right.

local UPGRADE_ITEM_ID = 44077
is that number just an example of an item ID that you chose? When creating different items using a GOD I use the command /i and I choose item id using this site: https://tibia.fandom.com/wiki/Item_IDs. Looking at the number that was in your script I found that it is
Cave Chair44182, 44077
I am not sure if I understand but... can I like, for example, duplicate an already existing item with some ID (for example some parchment like stuff), give it a new ID of my choice (I'd most likely just give it some weird number like 99199 or something like that), to make sure I do not break anything that is already working in game, then adjust your script by using my new item's ID instead? If yes- is editing/ duplicating already existing items through the data base or simply through itemx.xml in my OTS folder (\data\items)?

My other question would be- once the script is "ready", where should I put it?

That may look silly for you but I am, as I said, at the very beginning of OTS journey :)
Data/scripts and change id to item you want to use it. Must be useable like runes.
 
Back
Top