beenii
Well-Known Member
- Joined
- Jul 26, 2010
- Messages
- 586
- Solutions
- 1
- Reaction score
- 58
Code:
function onStatsChange(cid, attacker, type, combat, value)
if isPlayer(cid) and type == STATSCHANGE_HEALTHLOSS then
if isPlayer(attacker) or isMonster(attacker) then
itemHEAD = getPlayerSlotItem(cid, CONST_SLOT_HEAD)
itemARMOR = getPlayerSlotItem(cid, CONST_SLOT_ARMOR)
itemLEGS = getPlayerSlotItem(cid, CONST_SLOT_LEGS)
itemFEET = getPlayerSlotItem(cid, CONST_SLOT_FEET)
itemLEFT = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
itemRIGHT = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
if combat == COMBAT_ICEDAMAGE then
absorb = math.floor(getItemAttribute(itemHEAD.uid, "IceProtec") + getItemAttribute(itemARMOR.uid, "IceProtec") + getItemAttribute(itemLEGS.uid, "IceProtec") + getItemAttribute(itemFEET.uid, "IceProtec")+ getItemAttribute(itemLEFT.uid, "IceProtec") + getItemAttribute(itemRIGHT.uid, "IceProtec"))
doSendMagicEffect(getThingPosition(attacker), CONST_ME_ICEATTACK)
doCreatureAddHealth(attacker, -absorb)
doSendAnimatedText(getThingPosition(attacker), absorb, COLOR_TEAL)
end
if combat == COMBAT_EARTHDAMAGE then
absorb = math.floor(value / 2)
doSendMagicEffect(getThingPosition(attacker), CONST_ME_GREEN_RINGS)
doCreatureAddHealth(attacker, -absorb)
doSendAnimatedText(getThingPosition(attacker), absorb, COLOR_LIGHTGREEN)
end
end
return true
end
end
my script have error because, dont have all items on slots and have valors null on atttributes
need function check all slots have or not items. and if null attrribute return to 0
I found something like, but need modify. need check attributes "EnergyProtec, FireProtec, IceProtec, PhysicalProtec, DeathProtec, EarthProtec, HolyProtec" in next slots:
( CONST_SLOT_HEAD
CONST_SLOT_ARMOR
CONST_SLOT_LEGS
CONST_SLOT_FEET
CONST_SLOT_LEFT
CONST_SLOT_RIGHT )
and give me the sum of an attribute.
--------------------------------------------------------- script base started -----------------------------------
items = {
[2647] = {CONST_SLOT_LEGS, 30},
[2463] = {CONST_SLOT_ARMOR, 30},
[2645] = {CONST_SLOT_FEET, 30},
[2493] = {CONST_SLOT_HEAD, 30},
}
local reflection = 0
for x,i in pairs(items) do
if getPlayerSlotItem(cid, i[1]).itemid == x then
reflection = reflection + i[2]
end
end