Ir para conteúdo
  • 0
Entre para seguir isso  
Lightwood

Scripting Autoloot

Pergunta

Lightwood    8
Lightwood

Versão do Servidor: TFS - 0.3.6

Tipo de Script: creaturescript

Código:

Spoiler

function onLogin(cid)
	registerCreatureEvent(cid, "aloot_kill")
	return true
end

local stor = 7575

function autoloot(cid, target, pos)
	local function doPlayerAddItemStacking(cid, itemid, quant) 
		local item = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, itemid)
		local piles = 0
		if #item > 0 then
			for i,x in pairs(item) do
				if getThing(x).type < 100 then
					local it = getThing(x)
					doTransformItem(it.uid, itemid, it.type+quant)
					if it.type+quant > 100 then
						doPlayerAddItem(cid, itemid, it.type+quant-100)
					end
				else
					piles = piles+1
				end
				break
			end
		else
			return doPlayerAddItem(cid, itemid, quant)
		end
		if piles == #item then
			doPlayerAddItem(cid, itemid, quant)
		end
	end
	
	local function scanContainer(cid, uid, list)
		for k = (getContainerSize(uid) - 1), 0, -1 do
			local tmp = getContainerItem(uid, k)
			if (isInArray(list, tmp.itemid)) then
				if isItemStackable(tmp.itemid) and (getPlayerItemCount(cid, tmp.itemid) > 0) then
					doPlayerAddItemStacking(cid, tmp.itemid, tmp.type)
				else
					local item = doCreateItemEx(tmp.itemid, tmp.type)
					doPlayerAddItemEx(cid, item, true)
				end
				doPlayerSendTextMessage(cid, 20, "Looted " .. tmp.type .. "x " .. getItemNameById(tmp.itemid) .. ".")
				doRemoveItem(tmp.uid)
			elseif isContainer(tmp.uid) then
				scanContainer(cid, tmp.uid, list)
			end
		end
	end
	
	local items = {}
	for i = getTileInfo(pos).items, 1, -1 do
		pos.stackpos = i
		table.insert(items, getThingFromPos(pos))
	end
	
	if (#items == 0) then
		return
	end
	
	local corpse = -1
	for _, item in ipairs(items) do
		local name = getItemName(item.uid):lower()
		if name:find(target:lower()) then
			corpse = item.uid
			break
		end
	end
	
	if (corpse ~= -1) and isContainer(corpse) then
		scanContainer(cid, corpse, tostring(getPlayerStorageValue(cid, stor)):gsub('_', ''):explode(','))
	end
end

function onKill(cid, target, lastHit)
	if not isPlayer(target) then
		local infos = getPlayerStorageValue(cid, stor)
		if (infos == -1) then
			return true
		end
		local list = tostring(infos):explode(',')
		if (#list == 0) then
			return true
		end
		addEvent(autoloot, 150, cid, getCreatureName(target), getCreaturePosition(target))
	end
	return true
end

 

Salve galera, tudo certo?
Eu encontrei esse sistema de autoloot aqui no fórum porem antes ele deixava de coletar alguns itens, isso eu consegui arrumar trocando a função de Stack!

Agora estou com o seguinte problema, ele coleta apenas 500 itens, vou dar um exemplo para melhor a explicação do erro:

 

Ex: Estou matando blastoise e coloquei para coletar Water Gem, ele coleta tranquilamente e stacka os item normal, porem quando chega em 500 Water Gem ele para de coletar.


Ou seja ele funciona de boa até chegar em 500 daquele item, se alguém souber me ajudar com isso agradeço!

Compartilhar este post


Link para o post

0 respostass a esta questão

Recommended Posts

Até agora não há respostas para essa pergunta

Visitante
Este tópico está impedido de receber novos posts.
Entre para seguir isso  
  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×