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()