• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

[REQUEST] Item that adds health

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:
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
And:
LUA:
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
You have to change ItemID to ID of your item ;p
Slots:
  1. head
  2. necklace
  3. backpack
  4. armor
  5. right-hand
  6. left-hand
  7. legs
  8. feet
  9. ring
It may work, I just started with lua :D

@EDIT
Do you want to give 500 hp or set bigger max hp?
 
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:
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
And:
LUA:
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
You have to change ItemID to ID of your item ;p
Slots:
  1. head
  2. necklace
  3. backpack
  4. armor
  5. right-hand
  6. left-hand
  7. legs
  8. feet
  9. ring
It may work, I just started with lua :D

@EDIT
Do you want to give 500 hp or set bigger max hp?

Just add 500hp, and when you take it off it goes back down
 
You dont need to do all that stuff mate. The script Vanitas made probably works, but there's an easier way that doesnt require scripting.

Just go to items.xml, find the item you want, lets say you want plate armor to add 500hp when worn, then find plate armor in items.xml:

PHP:
	<item id="2463" article="a" name="plate armor">
		<attribute key="weight" value="12000"/>
		<attribute key="armor" value="10"/>
		<attribute key="slotType" value="body"/>
	</item>

And add the item's attribute you desire, in this case it would be:

PHP:
		<attribute key="maxhealthpoints" value="500"/>

So at the end plate armor would look like this:

PHP:
	<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>

And add in movements.xml:

PHP:
	<movevent type="Equip" itemid="2463" slot="armor" level="1" event="function" value="onEquipItem"/>	
	<movevent type="DeEquip" itemid="2463" slot="armor" event="function" value="onDeEquipItem"/>

That's all, now you just need to restart the server and it should work.

Notice the attributes I use are for TFS 0.3.2, if you have a different version and you test this attribute and it doesnt work, you could check my tutorial about item attributes to know how to find correct ones for your version or any version. Link in my sig.

If you get an error in console similar to this:

Code:
[16/05/2009 18:40:01] [Warning - Items::loadFromXml] Unknown key value maxhealthpoints

That means that attribute is not working for your version and you must find the one for it.

I tested it so its working on TFS 0.3.2, and considering its not scripting but only adding attributes it should work correctly for you too.

Cheers.
 
Back
Top