Grehy
Killroy
I just want to know if I can make an item add 500 health when you wear it, thanks!
<movevent event="Equip" itemid="ItemID" slot="necklace" script=”sample.lua” />
<movevent event="DeEquip" itemid="ItemID" slot="necklace" script=”sample.lua” />
function onEquip(cid, itemID, slot)
local HPbefore = getCreatureMaxHealth(cid) -- taking player's max hp
local HPafter = 500 -- how much hp give
if slot == 2 then -- slot 2 is necklace
setCreatureMaxHealth(cid, HPbefore + HPafter)
end
return 1
end
function onDeEquip(cid, itemID, slot)
local HPbefore = getCreatureMaxHealth(cid) -- taking player's max hp
local HPafter = 500 -- how much hp give
if(item.itemid == ItemID) and (slot == 8) then
setCreatureMaxHealth(cid, HPbefore - HPafter)
end
return 1
end
In movements.xml add:
LUA:<movevent event="Equip" itemid="ItemID" slot="necklace" script=”sample.lua” /> <movevent event="DeEquip" itemid="ItemID" slot="necklace" script=”sample.lua” />
Then create some lua file:
And:LUA:function onEquip(cid, itemID, slot) local HPbefore = getCreatureMaxHealth(cid) -- taking player's max hp local HPafter = 500 -- how much hp give if slot == 2 then -- slot 2 is necklace setCreatureMaxHealth(cid, HPbefore + HPafter) end return 1 end
You have to change ItemID to ID of your item ;pLUA:function onDeEquip(cid, itemID, slot) local HPbefore = getCreatureMaxHealth(cid) -- taking player's max hp local HPafter = 500 -- how much hp give if(item.itemid == ItemID) and (slot == 8) then setCreatureMaxHealth(cid, HPbefore - HPafter) end return 1 end
Slots:
It may work, I just started with lua
- head
- necklace
- backpack
- armor
- right-hand
- left-hand
- legs
- feet
- ring
@EDIT
Do you want to give 500 hp or set bigger max hp?
<item id="2463" article="a" name="plate armor">
<attribute key="weight" value="12000"/>
<attribute key="armor" value="10"/>
<attribute key="slotType" value="body"/>
</item>
<attribute key="maxhealthpoints" value="500"/>
<item id="2463" article="a" name="plate armor">
<attribute key="weight" value="12000"/>
<attribute key="armor" value="10"/>
<attribute key="slotType" value="body"/>
<attribute key="maxhealthpoints" value="500"/>
</item>
<movevent type="Equip" itemid="2463" slot="armor" level="1" event="function" value="onEquipItem"/>
<movevent type="DeEquip" itemid="2463" slot="armor" event="function" value="onDeEquipItem"/>
[16/05/2009 18:40:01] [Warning - Items::loadFromXml] Unknown key value maxhealthpoints