Ir para conteúdo

Featured Replies

Postado

Testado no TFS 0.3.6

A função faz pega tal coisa dentre de uma posição


function getCreatureInRange(type, fromPos, toPos, toGet, itemid)


local types =

{

	["player"] = isPlayer,

	["monster"] = isMonster,

	["npc"] = isNpc,

	["creature"] = isCreature

}

local tmp = {}


	local type = types[type]

	if(not type) then

		print('[getCreatureInRange]>> Unknow type')

		return 0

	end


	local thing = nil

	for x = fromPos.x, toPos.x do

		for y = fromPos.y, toPos.y do

			for z = fromPos.z, toPos.z do

				for s = 1, 253 do

					local position = {x = x, y = y, z = z, stackpos = s}

					thing = getTileThingByPos(position)

					if(type(thing.uid) == true) then

						table.insert(tmp, thing.uid)

					end

				end

			end

		end

	end

	if(toGet == "count") then

		return table.maxn(tmp)

	elseif(toGet == "name") then

		return tmp

	else

		print('[getCreatureInRange]>> Unknow creature to get')

		return 0

	end

	return true

end

Como Usar:

local fromPos = {x = 100, y = 100, z = 7, stackpos = 1}

local toPos = {x = 150, y = 150, z = 7, stackpos = 1}


local t = getCreatureInRange("monster", fromPos, toPos, "count")


print('>> There are ' .. t .. ' monsters)

Exemplo como vai retornar:
  Citar
>> There are 3 monsters


local fromPos = {x = 100, y = 100, z = 7, stackpos = 1}

local toPos = {x = 150, y = 150, z = 7, stackpos = 1}


local t = getCreatureInRange("monster", fromPos, toPos, "name")


for i = 1, table.maxn(t) do

	print('>> The names are ' .. getCreatureName(t[i]))

end

Exemplo como vai retornar:

  Citar

>> The names are Demon

>> The names are Troll

>> The names are Fire Elemental

Creditos:

darkhaos

 http://baiakuza.com/
IP: baiakuza.com
TIBIA: 10.96
Baiak Custom [ High Exp Rate ]

 

 

 

 

  • 6 years later...

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo