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

[MOVEEVENTS] Someone help me to fix to???

f@bio

Fudera Otserver
Joined
Jul 10, 2007
Messages
213
Reaction score
0
Location
Brasil
-- Hello friends, i'm have a problem whit this, i dont good to make scripts, and need help:

Code:
function onEquip(cid, item, slot)

local health = getCreatureMaxHealth(cid)
local mana = getCreatureMaxMana(cid)
	
	if getPlayerSlotItem(cid, 4) == TRUE then
		doPlayerSendTextMessage(cid, 25, "Health changed...")
		setCreatureMaxHealth(cid, health+500)
		setCreatureMaxMana(cid, mana+300)
	end
end


function onDeEquip(cid, item, slot)

local health = getCreatureMaxHealth(cid)
local mana = getCreatureMaxMana(cid)
	
		doPlayerSendTextMessage(cid, 25, "Health changed...")
		setCreatureMaxHealth(cid, health-500)
		setCreatureMaxMana(cid, mana-300)
end

-- In this script i'm want to equip a ARMOR, and ADD 500+ health, but when DEEQUIP this remove +500 health... but for me don't work, can someone help to fix...

-- Many thx for all...
 
Not Tested

Lua:
local config = {
        item1 = 2472 -- ID of armor
}

function onEquip(cid, item, slot)
local health = getCreatureMaxHealth(cid)
local mana = getCreatureMaxMana(cid)
	if getPlayerSlotItem(cid, config.item1, 4) == TRUE then
		doPlayerSendTextMessage(cid, 25, "Health changed...")
		setCreatureMaxHealth(cid, health, +500)
		setCreatureMaxMana(cid, mana, +300)
	end
end

function onDeEquip(cid, item, slot)
local health = getCreatureMaxHealth(cid)
local mana = getCreatureMaxMana(cid)
	if getPlayerSlotItem(cid, config.item1, 4) ~= TRUE then
		doPlayerSendTextMessage(cid, 25, "Health changed...")
		setCreatureMaxHealth(cid, health, -500)
		setCreatureMaxMana(cid, mana, -300)
        end
end
 
Last edited:
-- Now have other ERROR when i'm go to EQUIPT THE ITEM:

-- Message on GAME:
Code:
you cannot dress this objecte there
-- Message on CONSOLE:
Code:
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/kina_arm.lua:onEquip

luaGetPlayerSlotItem(). Player not found

-- Can you help me???
 
Last edited:
Try this
Lua:
  local config = {
        item = 2472 -- ID of armor
}

function onEquip(cid, item, slot)
        if getPlayerSlotItem(cid, CONST_SLOT_ARMOR).itemid == config.item then
                doPlayerSendTextMessage(cid, 25, "Health changed...")
                setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + 500)
                setCreatureMaxMana(cid, getCreatureMaxMana(cid) + 300)
        end
end

function onDeEquip(cid, item, slot)
        if getPlayerSlotItem(cid, CONST_SLOT_ARMOR).itemid == config.item then
                doPlayerSendTextMessage(cid, 25, "Health changed...")
                setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) - 500)
                setCreatureMaxMana(cid, getCreatureMaxMana(cid) - 300)
        end
end
 
@darkhaos

-- Now dont send error on console, but send error on GAME, see this message:
-- Message on GAME:
Code:
you cannot dress this objecte there

-- See the MOVEMENTS:
Lua:
<movevent type="Equip" itemid="2508" slot="armor" event="script" value="kina_arm.lua" /> --elven armor
<movevent type="DeEquip" itemid="2508" slot="armor" event="script" value="kina_arm.lua" /> --elven armor

-- This your script:
Lua:
local config = {
        item1 = 2508 -- ID of armor
}

function onEquip(cid, item, slot)
        if getPlayerSlotItem(cid, CONST_SLOT_ARMOR).itemid == config.item then
                doPlayerSendTextMessage(cid, 25, "Health changed...")
                setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + 500)
                setCreatureMaxMana(cid, getCreatureMaxMana(cid) + 300)
        end
end

function onDeEquip(cid, item, slot)
        if getPlayerSlotItem(cid, CONST_SLOT_ARMOR).itemid == config.item then
                doPlayerSendTextMessage(cid, 25, "Health changed...")
                setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) - 500)
                setCreatureMaxMana(cid, getCreatureMaxMana(cid) - 300)
        end
end

-- Have a ideia to fix this... many thx for all to help me, i'm greatfull...
 
Last edited:
do you have this line in items.xml? (elven armor)
Lua:
		<attribute key="slotType" value="body"/>

Lua:
<item id="2508" article="a" name="native armor">
		<attribute key="weight" value="5000"/>
		<attribute key="armor" value="1"/>
		<attribute key="slotType" value="body"/>
</item>

-- I'm changed NATIVE ARMOR to ELVEN ARMOR
 
Lua:
  local config = {
        item1 = 2508 -- ID of armor
}

function onEquip(cid, item, slot)
        if getPlayerSlotItem(cid, CONST_SLOT_ARMOR).itemid == config.item then
                doPlayerSendTextMessage(cid, 25, "Health changed...")
                setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + 500)
                setCreatureMaxMana(cid, getCreatureMaxMana(cid) + 300)
				return TRUE
        end
end

function onDeEquip(cid, item, slot)
        if getPlayerSlotItem(cid, CONST_SLOT_ARMOR).itemid == config.item then
                doPlayerSendTextMessage(cid, 25, "Health changed...")
                setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) - 500)
                setCreatureMaxMana(cid, getCreatureMaxMana(cid) - 300)
				return TRUE
        end
end

Edited darkhaos script, may work.
 
Use what I wrote in this post:

http://otland.net/f132/old-greg-chris77s-scripting-services-37296/index8.html#post378101

But changing the respective stuff, like the item and the attributes.

Which means, if you're using item 2472, in step 1 look for itemID 2472 (or whatever item you wish to use).

In step 2, instead of using:

PHP:
<attribute key="maxmanapercent" value="125"/>

Use:

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

And also add:

PHP:
<attribute key="maxmanapoints" value="300"/>

So if you used 2472, it looks like this in the end:

PHP:
	<item id="2472" article="a" name="magic plate armor">
		<attribute key="description" value="An enchanted gem glows on the plate armor."/>
		<attribute key="weight" value="8500"/>
		<attribute key="armor" value="17"/>
		<attribute key="slotType" value="body"/>
		
		<attribute key="maxhealthpoints" value="500"/>
		<attribute key="maxmanapoints" value="300"/>
	</item>

In step 3 instead of using:

PHP:
<movevent type="Equip" itemid="2179" slot="ring" event="function" value="onEquipItem"/>
    <movevent type="DeEquip" itemid="2179" slot="ring" event="function" value="onDeEquipItem"/>

You use:


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

And thats all. If you do it correctly it will work.
 
Back
Top