• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

MoveEvent Healingtiles

Korrex

Intermediate OT User
Joined
Jan 19, 2008
Messages
2,748
Reaction score
109
Made this script like a month ago.
Realized now that it wouldn't work. Fixed it and now it's here to the public.
I will most certainly not give you the "movements.xml" part.
If you can't do that yourself then you're shit outta luck.
Lua:
---CONFIG---
local config = {
	hp = getCreatureHealth(cid),
	mp = getCreatureMana(cid),
	maxHp = getCreatureMaxHealth(cid),
	maxMp = getCreatureMaxMana(cid),
	healthheal = config.maxHp - config.hp,
	manaheal = config.maxMp - config.mp
}

function onStepIn(cid, item, position, fromPosition)
		if (isPlayer(cid)) then
			if (config.hp < config.maxHp) then
				doSendAnimatedText(getCreaturePosition(cid), "+" .. config.healthheal, CONST_ANI_RED)
				doPlayerAddHealth(cid, config.healthheal)
			end
			if (config.mp < config.maxMp) then
				doSendAnimatedText(getCreaturePosition(cid), "+" .. config.manaheal, CONST_ANI_BLUE)
				doPlayerAddMana(cid, config.manaheal)
			end
		end
	return true
end

AFTER MANY EDITS. It should work now.
 
Last edited:
Nice xd. Can you make that if is in area then heal every 1 second instead?
 
Nice xd. Can you make that if is in area then heal every 1 second instead?
I tried avoiding that with this script.
I could've just made it into an ongoing globalevent but this is better for the performance of the server.

I'll try and make an onThink or something later.
 
Last edited:
I just noticed, you have 2 problems:

the condition is wrong
You have it healing if playerHP == playerMaxHP and playerMana == playerMaxMana, which means it only heals if the player HP and mana are already full

shouldn't the condition be something like:
Code:
if config.hp < config.maxHp or config.mp < config.maxMp then

the other one is in your sendAnimatedText, you forgot .. between "+" and the var
you also need to show the animatedText before you actually heal, otherwise it'll always show +0 since the player would have already been healed
------------------------------------------------------
something like this should work to heal every 1 second, and since it's made thru addEvent, the server only checks it if a player is actually standing there, so it won't really interfere with the performance of the server :)
Code:
---CONFIG---
local config = {
    hp = getCreatureHealth(cid),
    mp = getCreatureMana(cid),
    maxHp = getCreatureMaxHealth(cid),
    maxMp = getCreatureMaxMana(cid),
    healthheal = 20,
    manaheal = 20,
    interval = 1000
}


local function heal(cid, pos)
    if doComparePositions(getCreaturePosition(cid), pos) then
        if config.hp < config.maxHp or config.mp < config.maxMp then
            doSendAnimatedText(getCreaturePosition(cid), "+" .. config.healthheal, 65)
            doSendAnimatedText(getCreaturePosition(cid), "+" .. config.manaheal, 65)
            doPlayerAddHealth(cid, config.healthheal)
            doPlayerAddMana(cid, config.manaheal)
            addEvent(heal, config.interval, cid, pos)
        end
    end
    return false
end


function onStepIn(cid, item, position, fromPosition)
    if isPlayer(cid) then
        heal(cid, position)
    end
    return true
end
 
Last edited:
not working nothing!!

HTML:
[03/09/2011 10:56:10] [Error - LuaScriptInterface::loadFile] data/movements/scripts/healthtile.lua:9: '}' expected (to close '{' at line 2) near '='
[03/09/2011 10:56:10] [Warning - Event::loadScript] Cannot load script (data/movements/scripts/healthtile.lua)
[03/09/2011 10:56:10] data/movements/scripts/healthtile.lua:9: '}' expected (to close '{' at line 2) near '='
 
Last edited:
@Up
try this one
Code:
---CONFIG---
local config = {
    hp = getCreatureHealth(cid),
    mp = getCreatureMana(cid),
    maxHp = getCreatureMaxHealth(cid),
    maxMp = getCreatureMaxMana(cid),
    healthheal = getCreatureMaxHealth(cid) - getCreatureHealth(cid),
    manaheal = getCreatureMaxMana(cid) - getCreatureMana(cid)
}
 
function onStepIn(cid, item, position, fromPosition)
        if (isPlayer(cid)) then
            if (config.hp < config.maxHp) then
                doSendAnimatedText(getCreaturePosition(cid), "+" .. config.healthheal, CONST_ANI_RED)
                doPlayerAddHealth(cid, config.healthheal)
            end
            if (config.mp < config.maxMp) then
                doSendAnimatedText(getCreaturePosition(cid), "+" .. config.manaheal, CONST_ANI_BLUE)
                doPlayerAddMana(cid, config.manaheal)
            end
        end
    return true
end
 
@Up
try this one
Code:
---CONFIG---
local config = {
    hp = getCreatureHealth(cid),
    mp = getCreatureMana(cid),
    maxHp = getCreatureMaxHealth(cid),
    maxMp = getCreatureMaxMana(cid),
    healthheal = getCreatureMaxHealth(cid) - getCreatureHealth(cid),
    manaheal = getCreatureMaxMana(cid) - getCreatureMana(cid)
}
 
function onStepIn(cid, item, position, fromPosition)
        if (isPlayer(cid)) then
            if (config.hp < config.maxHp) then
                doSendAnimatedText(getCreaturePosition(cid), "+" .. config.healthheal, CONST_ANI_RED)
                doPlayerAddHealth(cid, config.healthheal)
            end
            if (config.mp < config.maxMp) then
                doSendAnimatedText(getCreaturePosition(cid), "+" .. config.manaheal, CONST_ANI_BLUE)
                doPlayerAddMana(cid, config.manaheal)
            end
        end
    return true
end


PHP:
[03/09/2011 11:32:47] [Error - MoveEvents Interface] 
[03/09/2011 11:32:47] data/movements/scripts/healthtile.lua
[03/09/2011 11:32:47] Description: 
[03/09/2011 11:32:47] (luaGetCreatureHealth) Creature not found

[03/09/2011 11:32:48] [Error - MoveEvents Interface] 
[03/09/2011 11:32:48] data/movements/scripts/healthtile.lua
[03/09/2011 11:32:48] Description: 
[03/09/2011 11:32:48] data/movements/scripts/healthtile.lua:7: attempt to perform arithmetic on a boolean value
[03/09/2011 11:32:48] [Warning - Event::loadScript] Cannot load script (data/movements/scripts/healthtile.lua)
[03/09/2011 11:32:48] data/movements/scripts/healthtile.lua:4: '}' expected (to close '{' at line 2) near 'mp'
 
Lua:
function onStepIn(cid, item, position, fromPosition)
	--- CONFIG ---
	local config = {
		hp = getCreatureHealth(cid),
		mp = getCreatureMana(cid),
		maxHp = getCreatureMaxHealth(cid),
		maxMp = getCreatureMaxMana(cid),
		healthheal = getCreatureMaxHealth(cid) - getCreatureHealth(cid),
		manaheal = getCreatureMaxMana(cid) - getCreatureMana(cid)
	}
	-- END CONFIG --

	if isPlayer(cid) then
		if config.hp < config.maxHp then
			doSendAnimatedText(getCreaturePosition(cid), "+" .. config.healthheal, CONST_ANI_RED)
			doPlayerAddHealth(cid, config.healthheal)
		end
		if config.mp < config.maxMp then
			doSendAnimatedText(getCreaturePosition(cid), "+" .. config.manaheal, CONST_ANI_BLUE)
			doPlayerAddMana(cid, config.manaheal)
		end
	end
	return true
end
 
shorter ? :p
Code:
function onStepIn(cid, item, position, fromPosition)
	if isPlayer(cid) then
		if getCreatureMana(cid) < getCreatureMaxMana(cid) then
			doSendAnimatedText(getThingPos(cid), '+' .. getCreatureMaxMana(cid) - getCreatureMana(cid), 180)
			doPlayerAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
	elseif getCreatureHealth(cid) < getCreatureMaxHealth(cid) then
			doSendAnimatedText(getThingPos(cid), '+' .. getCreatureMaxHealth(cid) - getCreatureHealth(cid), 180)
			doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
			end
		end
	return true
end
 
shorter ? :p
Code:
function onStepIn(cid, item, position, fromPosition)
	if isPlayer(cid) then
		if getCreatureMana(cid) < getCreatureMaxMana(cid) then
			doSendAnimatedText(getThingPos(cid), '+' .. getCreatureMaxMana(cid) - getCreatureMana(cid), 180)
			doPlayerAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
	elseif getCreatureHealth(cid) < getCreatureMaxHealth(cid) then
			doSendAnimatedText(getThingPos(cid), '+' .. getCreatureMaxHealth(cid) - getCreatureHealth(cid), 180)
			doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
			end
		end
	return true
end
Well all you did was removing the vars. ^_^
 
Lua:
function onStepIn(cid, item, position, fromPosition)
	--- CONFIG ---
	local config = {
		hp = getCreatureHealth(cid),
		mp = getCreatureMana(cid),
		maxHp = getCreatureMaxHealth(cid),
		maxMp = getCreatureMaxMana(cid),
		healthheal = getCreatureMaxHealth(cid) - getCreatureHealth(cid),
		manaheal = getCreatureMaxMana(cid) - getCreatureMana(cid)
	}
	-- END CONFIG --

	if isPlayer(cid) then
		if config.hp < config.maxHp then
			doSendAnimatedText(getCreaturePosition(cid), "+" .. config.healthheal, CONST_ANI_RED)
			doPlayerAddHealth(cid, config.healthheal)
		end
		if config.mp < config.maxMp then
			doSendAnimatedText(getCreaturePosition(cid), "+" .. config.manaheal, CONST_ANI_BLUE)
			doPlayerAddMana(cid, config.manaheal)
		end
	end
	return true
end


VirrageS You Never FAIL!
THX ;)
 
Code:
function onStepIn(cid, item, position, fromPosition)
	--- CONFIG ---
	local config = {
		hp = getCreatureHealth(cid),
		mp = getCreatureMana(cid),
		maxHp = getCreatureMaxHealth(cid),
		maxMp = getCreatureMaxMana(cid),
		healthheal = getCreatureMaxHealth(cid) - getCreatureHealth(cid),
		manaheal = getCreatureMaxMana(cid) - getCreatureMana(cid)
	}
	-- END CONFIG --
 
	if isPlayer(cid) then
		if config.hp < config.maxHp then
			doSendAnimatedText(getCreaturePosition(cid), "+" .. config.healthheal, CONST_ANI_RED)
			[COLOR="#FF0000"][B]doPlayerAddHealth(cid, config.healthheal)[/B][/COLOR]
		end
		if config.mp < config.maxMp then
			doSendAnimatedText(getCreaturePosition(cid), "+" .. config.manaheal, CONST_ANI_BLUE)
			doPlayerAddMana(cid, config.manaheal)
		end
	end
	return true
end
VirrageS You Never FAIL!
THX ;)
just change this line to
Code:
doCreatureAddHealth(cid, config.healthheal)
jajaja
 
is possible that your script has an exhaust and say tile is exhausted or something?, and regenerate all the hp and the mana regen only 250?
 
Code:
local time = 10 -- exhuastion time (second)
local amount = 250 -- heal amount
function onStepIn(cid, item, position, fromPosition)
	if exhaustion.check(cid, 1234) then
		return doPlayerSendCancel(cid, "you are exhausted for "..exhaustion.get(cid, 1234).." second")
	end
	
	if isPlayer(cid) then
		if getCreatureMana(cid) < getCreatureMaxMana(cid) then
			doSendAnimatedText(getThingPos(cid), '+' .. amount, 180)
			doPlayerAddMana(cid, amount)
			exhaustion.set(cid, 1234,time)
	elseif getCreatureHealth(cid) < getCreatureMaxHealth(cid) then
			doSendAnimatedText(getThingPos(cid), '+' .. amount, 180)
			doCreatureAddHealth(cid, amount)
			exhaustion.set(cid, 1234,time)
			end
		end
	return true
end
btw it's not my script it's korrex's script :D
 
Back
Top