Ir para conteúdo
  • Cadastre-se

(Resolvido)PROBLEMAS COM O PK


Ir para solução Resolvido por Pedriinz,

Posts Recomendados

  • 3 weeks later...
  • Respostas 7
  • Created
  • Última resposta

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Troque seu creature.lua por este: function Creature:onChangeOutfit(outfit) return true end function Creature:onAreaCombat(tile, isAggressive) return RETURNVALUE_NOERROR end local function removeCombatProtection(cid) local player = Player(cid) if not player then return true end local time = 0 if player:isMage() then time = 10 elseif player:isPaladin() then time = 20 else time = 30 end player:setStorageValue(Storage.co

  Em 20/04/2017 em 05:14, Pedriinz disse:

Troque seu creature.lua por este:

function Creature:onChangeOutfit(outfit)
    return true
end
function Creature:onAreaCombat(tile, isAggressive)
    return RETURNVALUE_NOERROR
end
local function removeCombatProtection(cid)
    local player = Player(cid)
    if not player then
        return true
    end
    local time = 0
    if player:isMage() then
        time = 10
    elseif player:isPaladin() then
        time = 20
    else
        time = 30
    end
    player:setStorageValue(Storage.combatProtectionStorage, 2)
    addEvent(function(cid)
        local player = Player(cid)
        if not player then
            return
        end
        player:setStorageValue(Storage.combatProtectionStorage, 0)
        player:remove()
    end, time * 1000, cid)
end
function Creature:onTargetCombat(target)
    if not self then
        return true
    end
    if target:isPlayer() then
        if self:isMonster() then
            local protectionStorage = target:getStorageValue(Storage.combatProtectionStorage)
            if target:getIp() == 0 then -- If player is disconnected, monster shall ignore to attack the player
            	if not target:isPzLocked() then
	                if protectionStorage <= 0 then
	                    addEvent(removeCombatProtection, 30 * 1000, target.uid)
	                    target:setStorageValue(Storage.combatProtectionStorage, 1)
	                elseif protectionStorage == 1 then
	                    self:searchTarget()
	                    return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
	                end
	            end
                return true
            end
            if protectionStorage >= os.time() then
                return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
            end
        end
    end
    if PARTY_PROTECTION ~= 0 then
        if self:isPlayer() and target:isPlayer() then
            local party = self:getParty()
            if party then
                local targetParty = target:getParty()
                if targetParty and targetParty == party then
                    return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
                end
            end
        end
    end
    if ADVANCED_SECURE_MODE ~= 0 then
        if self:isPlayer() and target:isPlayer() then
            if self:hasSecureMode() then
                return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
            end
        end
    end
     return true
end

E teste. (:

Mostrar mais  

ou amigo vc poderia me ajudar ?      estou com um problema no meu otserve......  O cara chega pk e me ataca.... se eu atacar o cara viro pk também ... como posso resolver isso ?

 

Link para o post
Compartilhar em outros sites

Tive que mudar de servidor e estou com o mesmo problema, tentei substituir por este que você me passou mais não resolveu.

Quais alterações você fez@Pedriinz ?

 

 

  Citar

creature.lua

Mostrar mais  
  Citar

__picif = {}
function Creature:onChangeOutfit(outfit)
    if self:isPlayer() then
        local battlefieldInfo = Battlefield:findPlayer(self)
        if battlefieldInfo then
            return false
        end
    end
    return true
end
 
function Creature:onAreaCombat(tile, isAggressive)
    return true
end
 
local function removeCombatProtection(cid)
    local player = Player(cid)
    if not player then
        return true
    end
 
    local time = 0
    if player:isMage() then
        time = 10
    elseif player:isPaladin() then
        time = 20
    else
        time = 30
    end
 
    player:setStorageValue(Storage.combatProtectionStorage, 2)
    addEvent(function(cid)
        local player = Player(cid)
        if not player then
            return
        end
 
        player:setStorageValue(Storage.combatProtectionStorage, 0)
        player:remove()
    end, time * 1000, cid)
end
 
 
 -- AQUI TREINER ONLINE
 
 local staminaBonus = {
    target = 'Training Monk',
    period = 120000, -- período em milisegundos
    bonus = 1, -- stamina que ganha
    events = {}
}
 
local function addStamina(name)
    local player = Player(name)
    if not player then
        staminaBonus.events[name] = nil
    else
        local target = player:getTarget()
        if not target or target:getName() ~= staminaBonus.target then
            staminaBonus.events[name] = nil
        else
            player:setStamina(player:getStamina() + staminaBonus.bonus)
            staminaBonus.events[name] = addEvent(addStamina, staminaBonus.period, name)
        end
    end
end


function Creature:onTargetCombat(target)
    if not self then
        return true
    end
    if not __picif[target.uid] then
        if target:isMonster() then
            target:registerEvent("RewardSystemSlogan")
            __picif[target.uid] = {}
        end
    end
    
    --- BATTLEFIELD
    if self:isPlayer() and target:isPlayer() then
        if self:getStorageValue(_Lib_Battle_Info.TeamOne.storage) >= 1 and target:getStorageValue(_Lib_Battle_Info.TeamOne.storage) >= 1 or self:getStorageValue(_Lib_Battle_Info.TeamTwo.storage) >= 1 and target:getStorageValue(_Lib_Battle_Info.TeamTwo.storage) >= 1 then
            return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
        end
    end    
    
    if self:isPlayer() and target:isPlayer() then
        if self:getStorageValue(_Lib_Battle_Info1.TeamOne1.storage1) >= 1 and target:getStorageValue(_Lib_Battle_Info1.TeamOne1.storage1) >= 1 or self:getStorageValue(_Lib_Battle_Info1.TeamTwo1.storage1) >= 1 and target:getStorageValue(_Lib_Battle_Info1.TeamTwo1.storage1) >= 1 then
            return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
        end
    end
        
    --- BATTLEFIELD
   
    if target:isPlayer() then
        if self:isMonster() then
            local protectionStorage = target:getStorageValue(Storage.combatProtectionStorage)
 
            if target:getIp() == 0 then -- If player is disconnected, monster shall ignore to attack the player
                if protectionStorage <= 0 then
                    addEvent(removeCombatProtection, 30 * 1000, target.uid)
                    target:setStorageValue(Storage.combatProtectionStorage, 1)
                elseif protectionStorage == 1 then
                    self:searchTarget()
                    return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
                end
 
                return true
            end
 
            if protectionStorage >= os.time() then
                return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
            end
        end
    end
 
 -- AQUI TREINER ONLINE 
 
 if self:isPlayer() then
        if target and target:getName() == staminaBonus.target then
            local name = self:getName()
            if not staminaBonus.events[name] then
                staminaBonus.events[name] = addEvent(addStamina, staminaBonus.period, name)
            end
        end
    end
    
    -- FIM TREINER ONLINE
    return true
end

Expand   Mostrar mais  

 

Link para o post
Compartilhar em outros sites

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

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

  • Estatísticas dos Fóruns

    96844
    Tópicos
    519603
    Posts



×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo