• 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!

How can I add colors to the sqm of rare, epic, legendary items? OTclient

Just if anyone find this thread and wants colors for items with OEN upgrade system please look into:

 
You have to define in the XML item whether it is rare, epic or legendary
I think I got a good solution for the container module, I put this because most of my items have article "a" before the name:
LUA:
local function setFrames()
for _, container in pairs(g_game.getContainers()) do
local window = container.itemsPanel
for i, child in pairs(window:getChildren()) do
local id = child:getItemId()
local price = 0

local name = child:getTooltip()
child:setImageSource("/images/ui/item")
if (name) then
if (string.find(name, "legendary")) then
child:setImageSource('/images/ui/rarity_gold')
elseif (string.find(name, "epic")) then
child:setImageSource('/images/ui/rarity_purple')
elseif (string.find(name, "rare")) then
child:setImageSource('/images/ui/rarity_blue')
elseif (string.find(name, "a")) then
child:setImageSource('/images/ui/rarity_white') --checking if frames work at all
end
end

end
end
end
inventory:
local function setFrames(item, itemWidget)
local name = item:getTooltip()


if (name) then
if (string.find(name, "legendary")) then
itemWidget:setImageSource('/images/ui/rarity_gold')
elseif (string.find(name, "epic")) then
itemWidget:setImageSource('/images/ui/rarity_purple')
elseif (string.find(name, "rare")) then
itemWidget:setImageSource('/images/ui/rarity_blue')
elseif (string.find(name, "a")) then
itemWidget:setImageSource('/images/ui/rarity_white')
end
end
end


the rest I followed the step by step and also made the change in the source and it worked

hope they help
 
Last edited:
You have to define in the XML item whether it is rare, epic or legendary
I think I got a good solution for the container module, I put this because most of my items have article "a" before the name:
LUA:
local function setFrames()
for _, container in pairs(g_game.getContainers()) do
local window = container.itemsPanel
for i, child in pairs(window:getChildren()) do
local id = child:getItemId()
local price = 0

local name = child:getTooltip()
child:setImageSource("/images/ui/item")
if (name) then
if (string.find(name, "legendary")) then
child:setImageSource('/images/ui/rarity_gold')
elseif (string.find(name, "epic")) then
child:setImageSource('/images/ui/rarity_purple')
elseif (string.find(name, "rare")) then
child:setImageSource('/images/ui/rarity_blue')
elseif (string.find(name, "a")) then
child:setImageSource('/images/ui/rarity_white') --checking if frames work at all
end
end

end
end
end
inventory:
local function setFrames(item, itemWidget)
local name = item:getTooltip()


if (name) then
if (string.find(name, "legendary")) then
itemWidget:setImageSource('/images/ui/rarity_gold')
elseif (string.find(name, "epic")) then
itemWidget:setImageSource('/images/ui/rarity_purple')
elseif (string.find(name, "rare")) then
itemWidget:setImageSource('/images/ui/rarity_blue')
elseif (string.find(name, "a")) then
itemWidget:setImageSource('/images/ui/rarity_white')
end
end
end


the rest I followed the step by step and also made the change in the source and it worked

hope they help
Were you able to get it working? What OTX2 server engine are you using? Can you leave the full tutorial on how you were able to solve it?
 
Guys, what upgrade systems do you use? That's the most important question.

//edit
With OENs upgrade system I've posted how to make it work a few posts above.

I could help to find a solution but need to know what scripts do you have for the upgrades
 
Were you able to get it working? What OTX2 server engine are you using? Can you leave the full tutorial on how you were able to solve it?
I did it in tfs 1.4, but I believe that in otx it is the same thing. You will follow the tutorial and when you get to the parts where it puts the code in .lua, use mine that I left there in the comment. Note that every item has article="a" before the name, for normal items you leave "a" even if you want to use legendary, rare, epic you will have to replace the a in the article with epic for example and it will show the item with the rarity image, you make this change in items.xml
 
I did it in tfs 1.4, but I believe that in otx it is the same thing. You will follow the tutorial and when you get to the parts where it puts the code in .lua, use mine that I left there in the comment. Note that every item has article="a" before the name, for normal items you leave "a" even if you want to use legendary, rare, epic you will have to replace the a in the article with epic for example and it will show the item with the rarity image, you make this change in items.xml
Does what you're saying work if I don't have a rarity system installed on the server? For example, if I only want a few items that I generate myself with the names epic, legendary, and rare? I just want OtClient to recognize the color scheme when the items have the names
 
Does what you're saying work if I don't have a rarity system installed on the server? For example, if I only want a few items that I generate myself with the names epic, legendary, and rare? I just want OtClient to recognize the color scheme when the items have the names

exactly! you can put there just the part of the tutorial that talks about recognizing items in color and as I mentioned if you don't have the rarity system on the server you can define them manually through items.xml
 
exactly! you can put there just the part of the tutorial that talks about recognizing items in color and as I mentioned if you don't have the rarity system on the server you can define them manually through items.xml
I have sent you a message to the pv
 
Still doesn't work for me, tfs 1.4.2, otcv8

If i put:
LUA:
local function setFrames()
  for _, container in pairs(g_game.getContainers()) do
      local window = container.itemsPanel
      for i, child in pairs(window:getChildren()) do
          if child:getItemId() ~= 0 then
            local name = child:getItem():getName()

            child:setImageSource("/images/ui/item")
            if (name) then
              if (string.find(name, "legendary")) then
                child:setImageSource('/images/ui/rarity_gold')
              elseif (string.find(name, "epic")) then
                child:setImageSource('/images/ui/rarity_purple')
              elseif (string.find(name, "rare")) then
                child:setImageSource('/images/ui/rarity_blue')
              else
                child:setImageSource('/images/ui/rarity_white') --checking if frames work at all
              end
            end
          end
      end
  end
end

Then all items appear as 'white' but even if an item is 'epic', 'rare' or 'legendary' they won't change the frame to gold/purple etc.

Also, if you move the items out of backpack or out of corpse, the field remains with white frame. Even if this box in container is already empty, there's still rarity frame.

Tried to fix it but failed.
Any ideas?
i have same situation, i follow the stepts in this post and my itens are all "white border" you solved this?
obs: i have compiled with some changes by mateus roberto:

but now i have some errors, with protocol, extended opcode...

x.x


 
Back
Top