Ir para conteúdo
  • 0
shocks

Scripting Pet atacando players em party

Pergunta

shocks    2
shocks

Base: TFS 1.3 Custom

Os pets (summons de lvl 200), estava, atacando os players que estão na party com as magias em areas, porem foi alterado o creature.lua nos events, apenas adicionados alguns comandos, ele parou de acertar os players na party com as spells em area porem gera um erro no console. 

Erro: 

 

Lua Script Error: [Event Interface] 
data/events/scripts/creature.lua:Creature@onTargetCombat
data/global.lua:211: bad argument #1 to 'pairs' (table expected, got nil)

Linha de erro : 

 

	for _, targetColumn in pairs(array) do

 

Codigo adicionado no creature.lua em events:

Spoiler

if self:isPlayer() and target:isPlayer() then                    
        local party, guild = self:getParty(), self:getGuild()            
        if party or guild then                                            
            local targetParty, targetGuild = target:getParty(), target:getGuild()
            if targetParty and targetParty == party or targetGuild and targetGuild == guild then
                return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
            end
        end
    elseif self:isMonster() and target:isPlayer() then
        local master = self:getMaster()
        if master and master:isPlayer() then
            local party, targetParty = target:getParty(), master:getParty()
            if (party ~= nil and targetParty ~= nil) and party == targetParty then
                return RETURNVALUE_YOUMAYNOTATTACKTHISCREATURE
            end
            local guild, targetGuild = target:getGuild(), master:getGuild()
            if (guild ~= nil and targetGuild ~= nil) and guild == targetGuild then
                return RETURNVALUE_YOUMAYNOTATTACKTHISCREATURE
            end
            if not isInArray(skullTypes, target:getSkull()) and not isInArray(skullTypes, master:getSkull()) then
                return RETURNVALUE_YOUMAYNOTATTACKTHISCREATURE
            end
    end
    end

 

Codigo no global.lua:

Spoiler

table.contains = function(array, value)
    for _, targetColumn in pairs(array) do
        if targetColumn == value then
            return true
        end
    end
    return false
end

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

2 respostass a esta questão

Recommended Posts

  • 0
Kuma Bear    33
Kuma Bear

Tente isso aqui em global.lua, man

 

table.contains = function(array, value)
	if array then
		for _, targetColumn in pairs(array) do
			if targetColumn == value then
				return true
			end
		end

		return false
	end
end

 

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 0
shocks    2
shocks

Resolveu. Obrigado @bolotabunito 

Compartilhar este post


Link para o post
Compartilhar em outros sites
Visitante
Este tópico está impedido de receber novos posts.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×