• 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!

Lua Problems with onEquip

brunolopes

New Member
Joined
Nov 8, 2009
Messages
49
Reaction score
1
Hello!

I am having problems with the function onEquip, see this LUA script:

Code:
local r = {
	[2467] = {
		slot = CONST_SLOT_ARMOR,
	}
}

function onEquip(cid, item, slot)
	local k = r[item.itemid]
	if(k and slot == k.slot) then
		setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)+100)
	end
	return true
end

function onDeEquip(cid, item, slot)
	local k = r[item.itemid]
	if(k and slot == k.slot) then
		setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)-100)
	end
	return true
end

The function of the script is: When the player equips the item 2467 he got 100 maxHealth.

But in the game he got twice this value. For example: A player with 500 hp equip this item and the hp is now 700 instead of 600.

Another problem is when the player deEquip the item, instead of takes the twice too, he takes the normal -100 maxHealth.

How I can solve it?
Please Help!
 
I know this can be made by a condition.
But I want to make an attribute system (strenght, agility...) and this isn't a condition =)

The script is only a example.
 
I found that the onEquip execute all LUA code twice.
If I put in the code:

Code:
function onEquip(cid, item, slot)
   print("Equip")
   return true
end

The console shows:

Code:
Equip
Equip

Heh... Function Bug?
 
I already do this, heh...
But is another problem ;P
When the item is equipped and I logout and login the item give +50 a time ;\

So the item gives 50+50+...+50 =(
 
Back
Top