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

tfs 1.3 onLogin check item attributes

kimokimo

Kimo
Joined
Jan 25, 2011
Messages
821
Solutions
6
Reaction score
156
GitHub
karimadnan
I was trying to check player equipped items on login to see if they carry a certain description but it seems like it returns a nil on login but it works in other scripts like movements, actions it returns the correct description.

Code:
    for i = 1, 9 do
    local items = getPlayerSlotItem(player, i)
        if items.uid ~= 0 then
            if items.actionid == 200 then
                local desc = getItemAttribute(items.uid, ITEM_ATTRIBUTE_DESCRIPTION)
                print(desc)
            end
        end
    end
 
Solution
Lua:
for slot = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
  local item = player:getSlotItem(slot)
  if item then
    if item.uid ~= 0 then
      if item.actionid == 200 then
        local desc = item:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
        print(desc)
      end
    end
  end
end
The function
Code:
getItemAttribute
does not exist and therefore you cannot call it, the best thing you can do is search the file "luascript.cpp" in its sources and find the correct function name
 
@Stellow

it's the full script i just added this to login.lua


The function
Code:
getItemAttribute
does not exist and therefore you cannot call it, the best thing you can do is search the file "luascript.cpp" in its sources and find the correct function name

Lua:
    for i = 1, 9 do
    local items = getPlayerSlotItem(player, i)
        if items.uid ~= 0 then
            if items.actionid == 200 then
                local desc = items:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
                print(desc)
            end
        end
    end

same error
 
Lua:
for slot = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
  local item = player:getSlotItem(slot)
  if item then
    if item.uid ~= 0 then
      if item.actionid == 200 then
        local desc = item:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
        print(desc)
      end
    end
  end
end
 
Solution
yibeodFp
1.3, it's in the title.
 
Back
Top