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

Solved How to get total items weight from table.

Nothxbye

Banned User
Joined
Jan 22, 2012
Messages
1,124
Reaction score
173
Hello OTlanders,
Anyone know how to get total items weight from table.

For example i've got table with 3 item ids:
rewards = {2544, 2495, 2544}

And now i want total weight of these 3 items. How to do it?

I can do like that but its not flexible with rewards count:
Code:
getItemWeightById(rewards[1],1)+getItemWeightById(rewards[2],1)+getItemWeightById(rewards[3],1)
 
Code:
    local rewards = {{2544, 1}, {2495, 1}, {2544, 1}}
    local weight = 0
    for i = 1, #rewards do
        weight = weight + getItemWeightById(rewards[i], rewards[i][2])
    end
    print(weight)
 
ON TFS 1.0...
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local rewards = {2544, 2495, 2544}
  local weight = 0
  for _, v in pairs(rewards) do
    weight = weight + getItemWeight(v, 1)
  end
 
  return print(weight)
end

On TFS 3.7 use:
getItemWeightById
 
Back
Top