• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.X+ worldType = "pvp" pvp-enforced (party)

Nuelman

Member
Joined
Nov 9, 2017
Messages
98
Solutions
1
Reaction score
6
Hello,
I have a problem with party in pvp system that I explain below...

WITH PVP SYSTEM:
-when players are partying they hurt each other

WITH PVP-ENFORCED SYSTEM:
-when players are partying, they don't hurt each other..

¿What do I want to solve?

I would like that in "pvp" system the players in party don't get damaged, the same as in "enforced" system
I don't know where to start, I don't know where the file where all the "worldType" data is saved is located

Please help
+rep
 
Solution
@Nuelman

Yes there can only be one Creature:eek:nTargetCombat(target) function inside of your creature.lua file. You just add the portion of the party code inside the function just like you did for other systems within that function:


Lua:
__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 =...
@
imkingran

Not work.....

I put this:
Lua:
function Creature:onTargetCombat(target)
    if not self then
        return true
    end

    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
    return true
end

HERE: Creatures.lua
Code:
__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
    ------party
function Creature:onTargetCombat(target)
    if not self then
        return true
    end

    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
    return true
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
Maybe I did something wrong?
Post automatically merged:

Post automatically merged:

I thought it worked, but it doesn't. I don't know what I could be doing wrong.
@
imkingran
 
Last edited:
@Nuelman

Yes there can only be one Creature:eek:nTargetCombat(target) function inside of your creature.lua file. You just add the portion of the party code inside the function just like you did for other systems within that function:


Lua:
__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

    ------party
    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
 
    --- 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
 
Solution
Back
Top