• 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!

Lua Prevent monsters to hit other monsters

KingKing

Member
Joined
Nov 6, 2019
Messages
33
Reaction score
6
Hello,

I am using this script to prevent monsters to hit other monsters.
Lua:
function onStatsChange(cid, attacker, type, combat, value)
    -- This should block all damage monster cause on eachother expect player summons
    if isMonster(cid) and isMonster(attacker) then
        local master = getCreatureMaster(cid)
        if not master or not isPlayer(master) then
            return false
        end
    end

    return true
end

The good thing,
It is working for monsters vs monsters.
Also monsters vs player's summon.

But not working for player's summon vs monsters. ( normal monster block hits from player's summon )
how to fix that and make player's summon can hit normal monsters?

TFS 0.4
 
Solution
I found something wrong, when a normal monster make healing it no effect.
ex: Training monks no heal.
but player's summon can heal.
how to fix that?
try it
Lua:
function onStatsChange(cid, attacker, type, combat, value)
    -- This should block all damage monster cause on eachother expect player summons
    if type == STATSCHANGE_HEALTHLOSS then
        local master_cid = getCreatureMaster(cid) or cid
        local master_attacker = getCreatureMaster(attacker) or attacker
        if isMonster(master_cid) and isMonster(master_attacker) then
            return false
        end
    end
   
    return true
end
But not working for player's summon vs monsters. ( normal monster block hits from player's summon )
how to fix that and make player's summon can hit normal monsters?

TFS 0.4
try
Lua:
function onStatsChange(cid, attacker, type, combat, value)
    -- This should block all damage monster cause on eachother expect player summons
    if isMonster(cid) and isMonster(attacker) then
        local master_cid = getCreatureMaster(cid) or cid
        local master_attacker = getCreatureMaster(attacker) or attacker
        if isMonster(master_cid) and isMonster(master_attacker) then
            return false
        end
    end

    return true
end
 
try
Lua:
function onStatsChange(cid, attacker, type, combat, value)
    -- This should block all damage monster cause on eachother expect player summons
    if isMonster(cid) and isMonster(attacker) then
        local master_cid = getCreatureMaster(cid) or cid
        local master_attacker = getCreatureMaster(attacker) or attacker
        if isMonster(master_cid) and isMonster(master_attacker) then
            return false
        end
    end

    return true
end
Thanks man, it worked.
 
try
Lua:
function onStatsChange(cid, attacker, type, combat, value)
    -- This should block all damage monster cause on eachother expect player summons
    if isMonster(cid) and isMonster(attacker) then
        local master_cid = getCreatureMaster(cid) or cid
        local master_attacker = getCreatureMaster(attacker) or attacker
        if isMonster(master_cid) and isMonster(master_attacker) then
            return false
        end
    end

    return true
end
I found something wrong, when a normal monster make healing it no effect.
ex: Training monks no heal.
but player's summon can heal.
how to fix that?
 
I found something wrong, when a normal monster make healing it no effect.
ex: Training monks no heal.
but player's summon can heal.
how to fix that?
try it
Lua:
function onStatsChange(cid, attacker, type, combat, value)
    -- This should block all damage monster cause on eachother expect player summons
    if type == STATSCHANGE_HEALTHLOSS then
        local master_cid = getCreatureMaster(cid) or cid
        local master_attacker = getCreatureMaster(attacker) or attacker
        if isMonster(master_cid) and isMonster(master_attacker) then
            return false
        end
    end
   
    return true
end
 
Solution
try it
Lua:
function onStatsChange(cid, attacker, type, combat, value)
    -- This should block all damage monster cause on eachother expect player summons
    if type == STATSCHANGE_HEALTHLOSS then
        local master_cid = getCreatureMaster(cid) or cid
        local master_attacker = getCreatureMaster(attacker) or attacker
        if isMonster(master_cid) and isMonster(master_attacker) then
            return false
        end
    end
  
    return true
end
Thanks man, worked.
 
Back
Top