• 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

Pitufo™

InfinityOT.com
Joined
Feb 14, 2008
Messages
1,438
Reaction score
10
Location
Mexico, Cuernavaca
Tested and working on TFS 0.3 Beta 2
What this script does?
Well this script will send effects in an area of 3x3, if the player is in that area you will get 20 of Health, every X time, depending on how much interval u put in the creaturescripts.xml.

Script:

PHP:
--Script by Pitufo!
local pos =
{
    {{x = 98, y = 132, z = 7}, {x = 98, y = 132, z = 7, stackpos = 253}},
    {{x = 98, y = 133, z = 7}, {x = 98, y = 133, z = 7, stackpos = 253}},
    {{x = 98, y = 134, z = 7}, {x = 98, y = 134, z = 7, stackpos = 253}},
    {{x = 99, y = 132, z = 7}, {x = 99, y = 132, z = 7, stackpos = 253}},
    {{x = 99, y = 133, z = 7}, {x = 99, y = 133, z = 7, stackpos = 253}},
    {{x = 99, y = 134, z = 7}, {x = 99, y = 134, z = 7, stackpos = 253}},
    {{x = 100, y = 132, z = 7}, {x = 100, y = 132, z = 7, stackpos = 253}},
    {{x = 100, y = 133, z = 7}, {x = 100, y = 133, z = 7, stackpos = 253}},
    {{x = 100, y = 134, z = 7}, {x = 100, y = 134, z = 7, stackpos = 253}}
    }
function onThink(cid, interval, lastExecution)
    for _, positions in pairs(pos) do
        doSendMagicEffect(positions[1], 12)
		if getThingFromPos(positions[2]).itemid > 0 then
			for _, name in pairs(getOnlinePlayers()) do
				local player = getPlayerByName(name)
					doCreatureAddHealth(player, 20)
					doSendAnimatedText(positions[1], "+20", 18)
			end
		end
    end
return TRUE
end

Creaturescripts.xml:

PHP:
<globalevent name="areahealth" interval="2" script="areahealth.lua"/>

My interval is 2 seconds, so i will get 20health every 2 seconds if im in the area :D

Notice that you can change the area with just adding new positions!

2701200901219ux5.png

Haifurer/Pitufo <-Same person :D


Enjoy it
, any bug report it here!
Rep?
 
Last edited:
PHP:
--Script by Pitufo!
-- Easier config by Rizz
  
local centerpos = {x = 99, y = 133, z = 7}
local pos =
{
    {{x = centerpos.x-1, y = centerpos.y-1, z = centerpos.z, stackpos = 253}},
    {{x = centerpos.x-1, y = centerpos.y, z = centerpos.z, stackpos = 253}},
    {{x = centerpos.x-1, y = centerpos.y+1, z = centerpos.z, stackpos = 253}},
    {{x = centerpos.x, y = centerpos.y-1, z = centerpos.z, stackpos = 253}},
    {{x = centerpos.x, y = centerpos.y, z = centerpos.z, stackpos = 253}},
    {{x = centerpos.x, y = centerpos.y+1, z = centerpos.z, stackpos = 253}},
    {{x = centerpos.x+1, y = centerpos.y-1, z = centerpos.z, stackpos = 253}},
    {{x = centerpos.x+1, y = centerpos.y, z = centerpos.z, stackpos = 253}},
    {{x = centerpos.x+1, y = centerpos.y+1, z = centerpos.z, stackpos = 253}},
    }
function onThink(cid, interval, lastExecution)
    for _, positions in pairs(pos) do
        doSendMagicEffect(positions[1], 12)
        if getThingFromPos(positions[1]).itemid > 0 then
            for _, name in pairs(getOnlinePlayers()) do
                local player = getPlayerByName(name)
                doCreatureAddHealth(player, 20)
                doSendAnimatedText(positions[1], "+20", 18)
            end
        end
    end
return TRUE
end

Easier to config ;>

(Not Tested)
 
Add checking is player in area :f.

Code:
for areax = 1041, 1052 do
	for areay = 985, 991 do
		areatiles = {x=areax, y=areay, z=7, stackpos=253}
		areaplayers = getThingfromPos(areatiles)
	end
end

Just a sample.
 
Then you must know that it will not heal players in a stack ;>

Use doTargetAreaHealth function instead, it will work on stacks :)
 
nice, i made as spell for druid, but the problem is, if the player cast this spell 5x or so on, this will heal 5x, how i can do delay? i mean, the player must wait until it finish to cast again.

there's a way to fix it?
 
PHP:
--Script by Pitufo!
--Easier config by Rizz

local centerpos = {x = 99, y = 133, z = 7}

local pos =
{
    {{x = centerpos.x-1, y = centerpos.y-1, z = centerpos.z, stackpos = 253}},
    {{x = centerpos.x-1, y = centerpos.y, z = centerpos.z, stackpos = 253}},
    {{x = centerpos.x-1, y = centerpos.y+1, z = centerpos.z, stackpos = 253}},
    {{x = centerpos.x, y = centerpos.y-1, z = centerpos.z, stackpos = 253}},
    {{x = centerpos.x, y = centerpos.y, z = centerpos.z, stackpos = 253}},
    {{x = centerpos.x, y = centerpos.y+1, z = centerpos.z, stackpos = 253}},
    {{x = centerpos.x+1, y = centerpos.y-1, z = centerpos.z, stackpos = 253}},
    {{x = centerpos.x+1, y = centerpos.y, z = centerpos.z, stackpos = 253}},
    {{x = centerpos.x+1, y = centerpos.y+1, z = centerpos.z, stackpos = 253}},
    }
function onThink(cid, interval, lastExecution)
    for _, positions in pairs(pos) do
        doSendMagicEffect(positions[1], 12)
		local thing = getThingFromPos(positions[1])
        if thing.uid > 0 then
            if isPlayer(thing.uid) then
                doCreatureAddHealth(thing.uid, 20)
                doSendAnimatedText(positions[1], "+20", 18)
            end
        end
    end
	return TRUE
end

:> That one should work.
 
I already gave him the best solution, though through MSN...

Seems like he haven't updated yet, but it's much more efficient and will attack all players in stack :)
 
Colandus, can you make a script like this but for spell for druids, like world of warcraft summon a statue and this statue heal like this script for 2 min for example, and then the statue disappears.
 
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 :)
 
Better version :)

Wont Work.

PHP:
local config = 
{
    centerPos = {x = 1032, y = 1000, z = 4},
    xRadius = 3,
    yRadius = 2,
    healthValue = {min = 20, max = 25}
}

function CreateArea(center, xRad, yRad)
    local Area = {}
    for X = (center.x - xRad), (center.x + xRad) do
        for Y = (center.y - yRad), (center.y + yRad) do
            table.insert(Area, {x = X, y = Y, z = center.z})
        end
    end
    return Area
end

function onThink(cid, interval, lastExecution)
    local CreatedArea = CreateArea(config.centerPos, config.xRadius, config.yRadius)
    for i = 1, #CreatedArea do
        doAreaCombatHealth(0, COMBAT_HEALING, CreatedArea[i], 0, config.healthValue.min, config.healthValue.max, CONST_ME_MAGIC_BLUE)
    end
    return TRUE
end
my version o.o
 
do it local if you wish, personally i use it for others script ^.-
 
yes it is there, i copied/paste it from there ^.-


btw it does not change anything if you use local or not, because i dont think anyone will use it in other script.
 
Back
Top