beenii
Well-Known Member
- Joined
- Jul 26, 2010
- Messages
- 586
- Solutions
- 1
- Reaction score
- 58
HI This code works perfectly
returned good values.
but....
Only have this error in console:
This error happens when the character has not any article in its slot.
Here the code:
//
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Ice: "..total..".")
AND I try creating this function, but only returns me the value of a slot:
for use:
getPlayerProtection(cid, 'IceProtec')
and same error in console anil value xD!
returned good values.
but....
Only have this error in console:

This error happens when the character has not any article in its slot.
Here the code:
Code:
local slots = {
['head'] = CONST_SLOT_HEAD,
['armor'] = CONST_SLOT_ARMOR,
['legs'] = CONST_SLOT_LEGS,
['feet'] = CONST_SLOT_FEET,
['left'] = CONST_SLOT_LEFT,
['right'] = CONST_SLOT_RIGHT
}
local itemSlots, total = {}, 0
for slot, const in pairs(slots) do
local hasItemOn = getPlayerSlotItem(cid, const).uid
if hasItemOn then
itemSlots[slot] = hasItemOn
end
end
for slot, slottedItem in pairs(itemSlots) do
local temp = getItemAttribute(slottedItem, 'IceProtec')
total = total + (temp ~= nil and temp or 0 )
end
//
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Ice: "..total..".")
AND I try creating this function, but only returns me the value of a slot:
Code:
function getPlayerProtection(cid, attribute)
local slots = {
['head'] = CONST_SLOT_HEAD,
['armor'] = CONST_SLOT_ARMOR,
['legs'] = CONST_SLOT_LEGS,
['feet'] = CONST_SLOT_FEET,
['left'] = CONST_SLOT_LEFT,
['right'] = CONST_SLOT_RIGHT
}
local itemSlots, total = {}, 0
for slot, const in pairs(slots) do
local hasItemOn = getPlayerSlotItem(cid, const).uid
if hasItemOn then
itemSlots[slot] = hasItemOn
end
end
for slot, slottedItem in pairs(itemSlots) do
local temp = getItemAttribute(slottedItem, attribute)
return total + (temp ~= nil and temp or 0 )
end
end
for use:
getPlayerProtection(cid, 'IceProtec')
and same error in console anil value xD!