• 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
818
Solutions
6
Reaction score
143
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

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
1,032
Solutions
102
Reaction score
1,083
Location
London
GitHub
MillhioreBT
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
 
OP
OP
kimokimo

kimokimo

Kimo
Joined
Jan 25, 2011
Messages
818
Solutions
6
Reaction score
143
GitHub
karimadnan
@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
 

oen432

Legendary OT User
Joined
Oct 3, 2014
Messages
1,451
Solutions
49
Reaction score
1,543
Location
Poland
GitHub
Oen44
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

oen432

Legendary OT User
Joined
Oct 3, 2014
Messages
1,451
Solutions
49
Reaction score
1,543
Location
Poland
GitHub
Oen44
yibeodFp
1.3, it's in the title.
 
Top