elnelson
Lunaria World Dev
Hello, otlanders, im making a status-like feature that will show values from the equipped items
Player uses !statusand will be able to see (E.g.)
Total armor: 22 (showing the sum of all equipped armory)
Total defense: 29 (showing defense from weapon + shield)
Total attack: 22 (showing attack from weapon + trinket (ammo slot))
I've been trying to do it but i dont know how to get the summation of all values, all i could do for now is:
But, this shows me the value of the single equip, need to show the summation of values.
And i was trying with this script: but it says attempt to index a boolean value at line 6
Im using TFS 0.4
Player uses !statusand will be able to see (E.g.)
Total armor: 22 (showing the sum of all equipped armory)
Total defense: 29 (showing defense from weapon + shield)
Total attack: 22 (showing attack from weapon + trinket (ammo slot))
I've been trying to do it but i dont know how to get the summation of all values, all i could do for now is:
Lua:
local slotName = {"Head Slot", "Amulet Slot", "Backpack Slot", "Armor Slot", "Right Hand", "Left Hand", "Legs Slot", "Feet Slot", "Ring Slot", "Ammo Slot"}
local player = getPlayerByNameWildcard(param)
if isPlayer(cid) == TRUE then
local text = getPlayerName(cid).."'s Equipment: "
for i=1, 10 do
text = text.."\n"
local item = getPlayerSlotItem(cid, i)
if item.itemid > 0 then
-- if isContainer(item.uid) == TRUE then
-- text = text..slotName[i]..": "..getItemInfo(item.itemid).armor..getItemsInContainer(item, 1)
-- else
text = text..slotName[i]..": "..getItemInfo(item.itemid).armor
-- end
else
text = text..slotName[i]..": Empty"
end
end
doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE, "[Armor]: "..text)
But, this shows me the value of the single equip, need to show the summation of values.
And i was trying with this script: but it says attempt to index a boolean value at line 6
Lua:
function getTotalArmor(cid)
local total = 0
for i = 1, 10 do
local item = getPlayerSlotItem(cid, i)
if item then
total = total + getItemInfo(item.itemid).armor
end
end
return total
end
Im using TFS 0.4
Last edited: