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

doSendMagicEffectInArea

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Reaction score
106
Location
Brazil
This is an simples function
wink.gif


UPDATED

Lua:
function doSendMagicEffectInArea(pos,effect,area,cid) -- Function by mock
	local centro = {}
	centro.y = math.floor(table.getn(area)/2)+1
	for y = 1, table.getn(area) do
		for x = 1, table.getn(area[y]) do
			if area[y][x] > 0 then
				centro.x = math.floor(table.getn(area[y])/2)+1
				if type(effect) == 'table' then
					doSendMagicEffect({x=pos.x+x-centro.x,y=pos.y+y-centro.y,z= pos.z},(effect[area[y][x]] or 0),cid)
				else
					doSendMagicEffect({x=pos.x+x-centro.x,y=pos.y+y-centro.y,z= pos.z},effect or 0,cid)
				end
			end
		end
	end
	return true
end
Add it on 050-function.lua and enjoy!

Example:
Lua:
local area = {
	{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
	{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
	{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
	{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
	{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
	{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
	{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
	{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
	{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
	{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
	{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}
}
function onUse(cid, item, frompos, item2, topos)
  doSendMagicEffectInArea(topos,36,area)
  return true
end
imagemaqr.png

OR with updated funcion
Lua:
local area = {
	{0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0},
	{0, 0, 0, 1, 3, 3, 3, 1, 0, 0, 0},
	{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
	{0, 1, 1, 1, 1, 1, 2, 1, 1, 1, 0},
	{0, 2, 1, 3, 1, 1, 1, 1, 1, 4, 0},
	{2, 2, 1, 1, 1, 4, 4, 1, 1, 4, 4},
	{0, 2, 1, 6, 1, 4, 4, 1, 1, 4, 0},
	{0, 1, 1, 6, 1, 5, 5, 1, 1, 1, 0},
	{0, 0, 1, 6, 1, 5, 5, 1, 1, 0, 0},
	{0, 0, 0, 1, 5, 5, 5, 1, 0, 0, 0},
	{0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
  doSendMagicEffectInArea(toPosition,{36,5,10,15,20,50},area)
  return true
end
imagem2nc.png

Enjoy
smile.gif



--------
 
Last edited:
Back
Top