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

GlobalEvent Health Area

PHP:
local config = 
{
	centerPos = {x = 99, y = 133, z = 7},
	xRadius = 7,
	yRadius 5,
	healthValue = 20,
	textColor = 18 -- green
}

function onThink(cid, interval, lastExecution)
	for _, v in pairs(getSpectators(config.centerPos, config.xRadius, config.yRadius)) do
		doSendMagicEffect(v, CONST_ME_MAGIC_BLUE)
		local thing = getThingFromPos(v)
		if (isPlayer(thing.uid) == TRUE) then
			doCreatureAddHealth(thing.uid, config.healthValue)
			doSendAnimatedText(positions[1], "+" .. config.healthValue, config.textColor)
		end
	end
	return TRUE
end

Better version :)

I doubt getSpectators returns a position :p

Though, my version of this code was using doAreaCombatHealth and imo most efficient...

I gave it to Pitufo but never saved it, thought he'd update his post here o.o
 
The fact of using a combat doesn't turns into more effient. Did you benchmarked it?

Well, about my code, i've forgot that getSpectators won't returns a position (i use a different server that returns uids as keys and position as values).
 
The fact of using a combat doesn't turns into more effient. Did you benchmarked it?

Well, about my code, i've forgot that getSpectators won't returns a position (i use a different server that returns uids as keys and position as values).

I mean, it's more proper to use it... It was made for such things, then use it for it ;>

It's like you'd write your own getTopCreature function or w/e instead of using the already existing one o.o
 
can anyone make this add hp & mana ?

Code:
local config = 
{
    centerPos = {x = 99, y = 133, z = 7},
    xRadius = 7,
    yRadius 5,
    healthValue = 20,
    manaValue = 20,
    textColor = 18 -- green
}

function onThink(cid, interval, lastExecution)
    for _, v in pairs(getSpectators(config.centerPos, config.xRadius, config.yRadius)) do
        doSendMagicEffect(v, CONST_ME_MAGIC_BLUE)
        local thing = getThingFromPos(v)
        if (isPlayer(thing.uid) == TRUE) then
            doCreatureAddHealth(thing.uid, config.healthValue)
            doCreatureAddMana(thing.uid, config.manaValue)
            doSendAnimatedText(positions[1], "+" .. config.healthValue, config.textColor)
        end
    end
    return TRUE
end

manaValue = 20, -- add xxxx mana if u want
 
This might work as well.

Lua:
local t = {
	p = {x = 100, y = 100, z = 7},
	x_ = 5,
	y_ = 5,
	min = 20,
	max = 50
}

function onThink(cid, interval)
	for _, i in pairs(getSpectators(t.p, t.x_, t.y_, false)) then
		doSendMagicEffect(i, CONST_ME_MAGIC_BLUE)
		local creature = getTopCreature(i)
		if creature.type == 1 then
			doCreatureAddHealth(creature.uid, math.random(t.min, t.max))
		end
	end
	
	return true
end
 
This might work as well.

Lua:
local t = {
	p = {x = 100, y = 100, z = 7},
	x_ = 5,
	y_ = 5,
	min = 20,
	max = 50
}

function onThink(cid, interval)
	for _, i in pairs(getSpectators(t.p, t.x_, t.y_, false)) then
		doSendMagicEffect(i, CONST_ME_MAGIC_BLUE)
		local creature = getTopCreature(i)
		if creature.type == 1 then
			doCreatureAddHealth(creature.uid, math.random(t.min, t.max))
		end
	end
	
	return true
end


yeap work as well.
thx!
 
got it working on 0.3.6pl1?
heals hp and mana?

3x3?!
 
Nicee! Ive found alot but ive always wanted to edit the magic effect that pops up it was always names and would never work. Thankkkks! Repp!
 
Back
Top