Ir para conteúdo

Featured Replies

Postado

Usando rev 3884 - 0.4 - 8.60

 

Erro acontece qnd eu mato um rat pra testar

XlcjqCm.png

 

 

function autoGP(cid, pos, corpseId)
    local player = Player(cid)
    if not player then
        return
    end
   
    local corpse = Tile(pos):getItemById(corpseId)
    if corpse then
        local container = Container(corpse:getUniqueId())
        if container then
            local gold = 0
            for i = 1, container:getSize() do
                local item = container:getItem(i)
                if item then
                    local id = item:getId()
                    local count = item:getCount()
                    local goldAdded = id == 2148 and count or id == 2152 and count * 100 or id == 2160 and count * 10000 or 0
                    if goldAdded > 0 then
                        gold = gold + goldAdded
                        item:remove(count)
                    end
                else
                    break
                end
            end
           
            player:addMoney(gold)
        end
    end
end
 
function onKill(creature, target)
    if target:isPlayer() then
        return true
    end
   
    local monsterType = MonsterType(target:getName())
    addEvent(autoGP, 1, creature:getId(), target:getPosition(), monsterType:getCorpseId())
    return true
end

Resolvido por Garou

Ir para solução
  • Respostas 8
  • Visualizações 637
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • function autoloot(cid, position, corpseID) if not isPlayer(cid) then return end local corpse = getTileItemById(position, corpseID) if corpse and isContainer(corpse.uid) then local gold = 0

  • Me diz o nome dos monstros que o loot falha que eu posso simular e estudar o problema.

  • Não se incomode com reputação, não preciso disso.   Então, quando falha, dá algum erro no console? Todos os testes que fiz, matando vários Rat, ele foi normal.

Postado
function autoloot(cid, position, corpseID)
	if not isPlayer(cid) then
		return
	end
	
	local corpse = getTileItemById(position, corpseID)
	if corpse and isContainer(corpse.uid) then
		local gold = 0
		for slot = 1, getContainerSize(corpse.uid) do
			local item = getContainerItem(corpse.uid, slot)
			local amount = (item.itemid == 2148 and item.type or (item.itemid == 2152 and item.type * 100 or (item.itemid == 2160 and item.type * 10000)) or 0)
			
			if item.uid > 0 then
				if amount > 0 then
					gold = gold + amount
					doRemoveItem(item.uid)
				end
			else
				break
			end
		end
		
		doPlayerAddMoney(cid, gold)
	end
end

function onKill(cid, target)
	if isPlayer(target) then
		return true
	end
	
	local position = getCreaturePosition(target)
	
	local info = getMonsterInfo(getCreatureName(target))
	addEvent(autoloot, 3, cid, position, info.lookCorpse)
	return true
end

Editado por Garou (veja o histórico de edições)

Postado
  • Autor
function autoloot(cid, position, corpseID)
	if not isPlayer(cid) then
		return
	end
	
	local corpse = getTileItemById(position, corpseID)
	if corpse and isContainer(corpse.uid) then
		local gold = 0
		for slot = 1, getContainerSize(corpse.uid) do
			local item = getContainerItem(corpse.uid, slot)
			local amount = (item.itemid == 2148 and item.type or (item.itemid == 2152 and item.type * 100 or (item.itemid == 2160 and item.type * 10000)) or 0)
			
			if item.uid > 0 then
				if amount > 0 then
					gold = gold + amount
					doRemoveItem(item.uid)
				end
			else
				break
			end
		end
		
		doPlayerAddMoney(cid, gold)
	end
end

function onKill(cid, target)
	if isPlayer(target) then
		return true
	end
	
	local position = getCreaturePosition(target)
	
	local info = getMonsterInfo(getCreatureName(target))
	addEvent(autoloot, 3, cid, position, info.lookCorpse)
	return true
end

 

 

Vou te dar 6 reps, sabe o pq alguns loots tão falhando?

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