Postado Agosto 13, 2012 12 anos 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 ]
Postado Março 22, 2019 6 anos Consegui. Função bem útil. Editado Março 22, 2019 6 anos por gabriel28 (veja o histórico de edições)
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.