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

Show Tier onLook

Heroid

Active Member
Joined
Mar 7, 2011
Messages
332
Solutions
11
Reaction score
34
I'm looking for a function which I can put on the player's onLook script which shows the Tier of EQ the player currently has.

If a player has full Tier 1 Set, it would say "Tier: 1" on a player when I look at them.
If a player has full Tier 5, it would say "Tier: 5", simple.

There's 8 items in a Set, not counting Backpack & Ammo Slot.
So for each item in Tier 1 for example would give 1/8=0.125
Each item in Tier 5 would give 5/8=0.625

I also only want it to show one decimal if that's possible; 5.4 for example and not 5.42.

Thanks. :d

EDIT: TFS 1.2 btw
 
Last edited:
Solution
Forgot to mention it's for TFS 1.2 btw, but I'll see what I can do with that one tommorow, thanks.
We can still salvage @Xikini's code all we need to do is use his/her code as its own function inside of Player onLook in player.lua
So open up player.lua in data/events/scripts and find
Lua:
function Player:onLook(thing, position, distance)
    local description = "You see " .. thing:getDescription(distance)
Select those 2 lines and replace it with this.
Lua:
function Player:onLook(thing, position, distance)
   local description = "You see " .. thing:getDescription(distance) .. look(thing:getId())
Then right above Player onLook place this code.
Lua:
local items_checked = {1, 2, 4, 5, 6, 7, 8, 9} -- item slots 1-10 (1 Tier = 1...
I'm looking for a function which I can put on the player's onLook script which shows the Tier of EQ the player currently has.

If a player has full Tier 1 Set, it would say "Tier: 1" on a player when I look at them.
If a player has full Tier 5, it would say "Tier: 5", simple.

There's 8 items in a Set, not counting Backpack & Ammo Slot.
So for each item in Tier 1 for example would give 1/8=0.125
Each item in Tier 5 would give 5/8=0.625

I also only want it to show one decimal if that's possible; 5.4 for example and not 5.42.

Thanks. :d
Try this?

Lua:
local items_checked = {1, 2, 4, 5, 6, 7, 8, 9} -- item slots 1-10 (1 Tier = 1 of each item set in items_checked)
local item_table = {
   --[item_id] = Tier
   [1111] = 1,
   [2222] = 2,
   [3333] = 3
}

function onLook(cid, thing, position, lookDistance)
   local tier_tally = 0
   local quantity_per_tier = #items_checked
   for i = 1, #items_checked do
       if item_table[getPlayerSlotItem(cid, items_checked[i]).itemid] then
           tier_tally = tier_tally + (item_table[getPlayerSlotItem(cid, items_checked[i]).itemid] / quantity_per_tier)
       end
   end
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Tier: " .. string.format("%.1f", tier_tally))
   return true
end
 
Try this?

Lua:
local items_checked = {1, 2, 4, 5, 6, 7, 8, 9} -- item slots 1-10 (1 Tier = 1 of each item set in items_checked)
local item_table = {
   --[item_id] = Tier
   [1111] = 1,
   [2222] = 2,
   [3333] = 3
}

function onLook(cid, thing, position, lookDistance)
   local tier_tally = 0
   local quantity_per_tier = #items_checked
   for i = 1, #items_checked do
       if item_table[getPlayerSlotItem(cid, items_checked[i]).itemid] then
           tier_tally = tier_tally + (item_table[getPlayerSlotItem(cid, items_checked[i]).itemid] / quantity_per_tier)
       end
   end
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Tier: " .. string.format("%.1f", tier_tally))
   return true
end
Forgot to mention it's for TFS 1.2 btw, but I'll see what I can do with that one tommorow, thanks.
 
Forgot to mention it's for TFS 1.2 btw, but I'll see what I can do with that one tommorow, thanks.
We can still salvage @Xikini's code all we need to do is use his/her code as its own function inside of Player onLook in player.lua
So open up player.lua in data/events/scripts and find
Lua:
function Player:onLook(thing, position, distance)
    local description = "You see " .. thing:getDescription(distance)
Select those 2 lines and replace it with this.
Lua:
function Player:onLook(thing, position, distance)
   local description = "You see " .. thing:getDescription(distance) .. look(thing:getId())
Then right above Player onLook place this code.
Lua:
local items_checked = {1, 2, 4, 5, 6, 7, 8, 9} -- item slots 1-10 (1 Tier = 1 of each item set in items_checked)
local item_table = {
   --[item_id] = Tier
   [1111] = 1,
   [2222] = 2,
   [3333] = 3
}
function look(cid)
    local msg = ""
    if isPlayer(cid) then
        local tier_tally = 0
        local quantity_per_tier = #items_checked
        for i = 1, #items_checked do
            if item_table[getPlayerSlotItem(cid, items_checked[i]).itemid] then
                tier_tally = tier_tally + (item_table[getPlayerSlotItem(cid, items_checked[i]).itemid] / quantity_per_tier)
            end
        end
        msg = "Tier: " .. string.format("%.1f", tier_tally))
    end
    return msg
end
And for Player onLookInBattleList select the 1st 2 lines.
Lua:
function Player:onLookInBattleList(creature, distance)
    local description = "You see " .. creature:getDescription(distance)
And replace it with this.
Lua:
function Player:onLookInBattleList(creature, distance)
    local description = "You see " .. creature:getDescription(distance) .. look(creature:getId())
 
Solution
We can still salvage @Xikini's code all we need to do is use his/her code as its own function inside of Player onLook in player.lua
So open up player.lua in data/events/scripts and find
Lua:
function Player:onLook(thing, position, distance)
    local description = "You see " .. thing:getDescription(distance)
Select those 2 lines and replace it with this.
Lua:
function Player:onLook(thing, position, distance)
   local description = "You see " .. thing:getDescription(distance) .. look(thing:getId())
Then right above Player onLook place this code.
Lua:
local items_checked = {1, 2, 4, 5, 6, 7, 8, 9} -- item slots 1-10 (1 Tier = 1 of each item set in items_checked)
local item_table = {
   --[item_id] = Tier
   [1111] = 1,
   [2222] = 2,
   [3333] = 3
}
function look(cid)
    local msg = ""
    if isPlayer(cid) then
        local tier_tally = 0
        local quantity_per_tier = #items_checked
        for i = 1, #items_checked do
            if item_table[getPlayerSlotItem(cid, items_checked[i]).itemid] then
                tier_tally = tier_tally + (item_table[getPlayerSlotItem(cid, items_checked[i]).itemid] / quantity_per_tier)
            end
        end
        msg = "Tier: " .. string.format("%.1f", tier_tally))
    end
    return msg
end
And for Player onLookInBattleList select the 1st 2 lines.
Lua:
function Player:onLookInBattleList(creature, distance)
    local description = "You see " .. creature:getDescription(distance)
And replace it with this.
Lua:
function Player:onLookInBattleList(creature, distance)
    local description = "You see " .. creature:getDescription(distance) .. look(creature:getId())
Hey thanks alot! It's working just as I want now!
This is what I tried to do when I was playing around with it but I never managed to get it to work, seems like I missed some lines here and there, thanks.
 
Back
Top