- Joined
- Dec 26, 2013
- Messages
- 1,635
- Solutions
- 11
- Reaction score
- 879
Hello Otland! I have come to tell everyone about an awesome function I was attempting to make and @Ninja was so kind as to make it, and make it right for me... Full credits go to @Ninja
Ok so open up compat.lua and add this
Then all you have to do is use it like so
function onSay(cid, words, param)
print(Player(cid):getTotalArmor())
end
So now you can use player:getTotalArmor in formula's or w/e, NOTE THE FUNCTION ONLY RETURNS THE TOTAL ARMOR VALUE, YOU CAN'T USE IT TO SET THE VALUE... As it is, no way to do that through lua that I know of for tfs.1.0 maybe if someone made arm an attribute in the item class, but I wouldn't know how to do that...
Ok so open up compat.lua and add this
Code:
function Player.getTotalArmor(self)
local total = 0
local slots = { CONST_SLOT_HEAD, CONST_SLOT_NECKLACE, CONST_SLOT_ARMOR, CONST_SLOT_LEGS, CONST_SLOT_FEET, CONST_SLOT_RING }
local item
for i = 1, #slots do
item = self:getSlotItem(slots[i])
if item then
total = total + item:getType():getArmor()
end
end
return total
end
Then all you have to do is use it like so
function onSay(cid, words, param)
print(Player(cid):getTotalArmor())
end
So now you can use player:getTotalArmor in formula's or w/e, NOTE THE FUNCTION ONLY RETURNS THE TOTAL ARMOR VALUE, YOU CAN'T USE IT TO SET THE VALUE... As it is, no way to do that through lua that I know of for tfs.1.0 maybe if someone made arm an attribute in the item class, but I wouldn't know how to do that...