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

Spell monster tfs 0.4

bpm91

Intermediate OT User
Joined
May 23, 2019
Messages
928
Solutions
7
Reaction score
127
Location
Brazil
YouTube
caruniawikibr
I have a question when using the script in creature events, and
and mark the monster with the script, My monsters do not heal. Example hydra.

Could someone tell me how I can get my monsters to heal again, and summoned monsters to damage the scripted monsters again?

</immunities>
<script>
<event name="noattack"/> <<<<<< the script
</script>
<voices interval="5000" chance="10">
<voice sentence="FCHHHHH"/>
<voice sentence="HISSSS"/>
</voices>



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
 
Solution
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
        if type == STATSCHANGE_HEALTHLOSS then
            local master = getCreatureMaster(cid)
            if not master or not isPlayer(master) then
                return false
            end
        end
    end
    return true
end

Make sure you only return false if the value is negative (damage)
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
        if value < 0 then
            local master = getCreatureMaster(cid)
            if not master or not isPlayer(master) then
                return false
            end
        end
    end
    return true
end
 
before they didn't attack each other. now they attack, and my sumon takes damage. now they attack each other and do not heal themselves.
Screenshot_4.jpg

Screenshot_5.jpg
I'm not attacking them. they kill themselves
 
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
        if type == STATSCHANGE_HEALTHLOSS then
            local master = getCreatureMaster(cid)
            if not master or not isPlayer(master) then
                return false
            end
        end
    end
    return true
end
 
Solution
Could you release sumons to attack along with healing?

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
        if type == STATSCHANGE_HEALTHLOSS then
            local master = getCreatureMaster(cid)
            if not master or not isPlayer(master) then
                return false
            end
        end
    end
    return true
end

your script is very good, but summons dont atack now =/

Screenshot_6.jpg
 
:rolleyes:
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
            if type == STATSCHANGE_HEALTHLOSS then
                return false
            end
        end
    end
    return true
end
 
:rolleyes:
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
            if type == STATSCHANGE_HEALTHLOSS then
                return false
            end
        end
    end
    return true
end

no atk =/Screenshot_7.jpg
 
Alright, so you want only players and their summons to hurt the monster?

This should work.

Use <script> inside monster file you don't want hurting other monsters.
Register in creaturescripts.xml
DO NOT register in login.lua -- this will enable the script for players, and would use unnecessary resources, since players will always return true, it's pointless for them to be activating the script constantly.
Lua:
function onStatsChange(cid, attacker, type, combat, value)
    if isMonster(attacker) then
        print("Monster is targeting another monster.")
        if type == STATSCHANGE_HEALTHLOSS then
            print("monster is trying to damage another monster.")
            if not isPlayer(getCreatureMaster(attacker)) then
                print("Monster is not a player summon. Cancelling damage.")
                return false
            end
        end
    end
    print("Damage is going through to monster.")
    return true
end
 
Last edited:
Put the script into
data/creaturescripts/scripts/noattack.lua
Lua:
function onStatsChange(cid, attacker, type, combat, value)
    if isMonster(attacker) then
        print("Monster is targeting another monster.")
        if type == STATSCHANGE_HEALTHLOSS then
            print("monster is trying to damage another monster.")
            if not isPlayer(getCreatureMaster(attacker)) then
                print("Monster is not a player summon. Cancelling damage.")
                return false
            end
        end
    end
    print("Damage is going through to monster.")
    return true
end

register noattack.lua in creaturescripts.xml
XML:
<event type="statschange" name="noattack" event="script" value="noattack.lua"/>

put noattack into monster
XML:
<script>
    <event name="noattack"/>
</script>
 
Last edited:
Copy my line into creaturescripts.xml.
Delete whatever you put in there.
XML:
<event type="kill" name="noattack" event="script" value="noattack.lua"/>

most likely you've typed it as 'type="onKill"' instead of 'type="kill"'


-- EDIT EDIT EDIT
I'm a fucking nob.

USE this line.......
XML:
<event type="statschange" name="noattack" event="script" value="noattack.lua"/>
 
Back
Top