• 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.5] Players from the same guild do not attack each other.

Can anyone help me with this? I need players from the same guild not to attack each other, what is the way to do this?
Try
events\scripts\creature.lua


Lua:
function Creature:onTargetCombat(target)

 if self:isPlayer() and target:isPlayer() then
        local SelfGuild, TargetGuild = self:getGuild(), target:getGuild()
        if SelfGuild and TargetGuild and SelfGuild == TargetGuild then
            return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
        end
    end
end
 
Try
events\scripts\creature.lua


Lua:
function Creature:onTargetCombat(target)

 if self:isPlayer() and target:isPlayer() then
        local SelfGuild, TargetGuild = self:getGuild(), target:getGuild()
        if SelfGuild and TargetGuild and SelfGuild == TargetGuild then
            return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
        end
    end
end
They keep attacking each other, but they don't get a skull, can you help me? I need them not to attack each other.
 
They keep attacking each other, but they don't get a skull, can you help me? I need them not to attack each other.
try


Lua:
local creatureevent = CreatureEvent("ProtectHP")

function creatureevent.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not creature or not attacker or creature == attacker then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
   
    if creature:isPlayer() and creature:getGuild() and attacker:isPlayer() and attacker:getGuild() then
        if creature:getGuild() == attacker:getGuild() then
          return false
        end
      end
 return primaryDamage, primaryType, secondaryDamage, secondaryType
end

creatureevent:register()
local creatureevent = CreatureEvent("ProtectMP")

function creatureevent.onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not creature or not attacker or creature == attacker then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
   
    if creature:isPlayer() and creature:getGuild() and attacker:isPlayer() and attacker:getGuild() then
        if creature:getGuild() == attacker:getGuild() then
          return false
        end
      end
 return primaryDamage, primaryType, secondaryDamage, secondaryType
end

creatureevent:register()


local loginEvent = CreatureEvent("login_guildProtect")
loginEvent:type("login")

function loginEvent.onLogin(player)
    player:registerEvent("ProtectHP")
    player:registerEvent("ProtectMP")
    return true
end

loginEvent:register()
 
Last edited:
Back
Top