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

Dmg from summon

omaraboud

Member
Joined
Jul 19, 2014
Messages
38
Reaction score
6
Location
Iraq
Does anyone have an idea how I can make my summons deal dmg by area spell and get white skull only if i have secure mode ON? I've tried a lot of things and none of them seems working. Now when a player uses summon in a fight against a monster, its area spells also deal damage to players :/ The script below makes the summons do no damage to players, but the skull is still appearing. Of course I added function secure mode function in sources. I'm using tfs 0.3.6 pl1

Lua:
function isSummon(cid)
        if getCreatureMaster(cid) then
                return true
        end
        return false
end

function onStatsChange(cid, attacker, type)
if type == STATSCHANGE_HEALTHLOSS then
if isPlayer(cid) and isSummon(attacker) or isPlayer(attacker) and isSummon(cid) or isSummon(cid) and isSummon(attacker) and getCreatureMaster(cid) == attacker then
end
end
return false
end
 
I think what you are looking for is the event onCombat

I don't know what version of TFS you're using, but here's an example:

summoncombat.lua
Lua:
function onCombat(cid, target)
    local master = getCreatureMaster(cid)
    if isPlayer(master) and getPlayerModes(master).secure == 0 then
            if isPlayer(target) or isPlayer(getCreatureMaster(target)) then
                return false
            end
        end
    end
    return true
end
This code will make your pet not deal damage to other players or other players' pets if you don't have fist pvp enabled.

creaturescripts.xml
XML:
<event type="combat" name="SummonCombat" event="script" value="summoncombat.lua"/>

I haven't tested it but I think everything should work fine, if you have any errors in the console post them here
 
So I changed getPlayerModes(master).secure == 0 to getPlayerSecureMode(cid) == 0 because I had error in console. But the script is not working. I can't attack any creature or player. I got message "Sorry not possible."
Code:
function onCombat(cid, target)
    local master = getCreatureMaster(cid)
    if isPlayer(master) and getPlayerSecureMode(cid) == 0 then
            if isPlayer(target) or isPlayer(getCreatureMaster(target)) then
                return false
            end
        end
    end
    return true
 
Lua:
function onCombat(creatureId, targetId)
    local masterId = getCreatureMaster(creatureId)
    if not isPlayer(masterId) then
        return true
    end

    if getPlayerSecureMode(masterId) == 0 then
        if isPlayer(targetId) or isPlayer(getCreatureMaster(targetId)) then
            return false
        end
    end
    return true
end

With horrible random trick but maybe for your old engine it works:
Lua:
function onCombat(creatureId, targetId)
    local masterId = getCreatureMaster(creatureId)
    if not masterId or masterId == targetId then
        return false
    end

    if not isPlayer(masterId) then
        return true
    end

    if getPlayerSecureMode(masterId) == 0 then
        if isPlayer(targetId) or isPlayer(getCreatureMaster(targetId)) then
            doPlayerSetSkullEnd(masterId, 0)
            doRemoveCondition(masterId, CONDITION_INFIGHT, CONDITIONID_COMBAT)
            return false
        end
    end
    return true
end
 
Last edited:
remasterizar
the problem remains the same when summoning when attacking area spell a trainer gives skull to the summoner
Lua:
function onCombat(creatureId, targetId)
    local masterId = getCreatureMaster(creatureId)
    if not isPlayer(masterId) then
        return true
    end

    if getPlayerSecureMode(masterId) == 0 then
        if isPlayer(targetId) or isPlayer(getCreatureMaster(targetId)) then
            return false
        end
    end
    return true
end
the problem remains the same when summoning when attacking area spell a summon gives skull to the summoner


It should be noted that I use otx 2
 
Last edited:
the problem remains the same when summoning when attacking area spell a trainer gives skull to the summoner

the problem remains the same when summoning when attacking area spell a summon gives skull to the summoner


It should be noted that I use otx 2
Check the code again I have posted another version that may work, if it doesn't work, I'm sorry to inform you that your server has problems in the sources that cannot be solved with lua codes.
 
Back
Top