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

{Solved}Party Mana Steal

Cadyan

Well-Known Member
Joined
Mar 30, 2008
Messages
845
Reaction score
63
Mystic Spirit 0.2.15
Code:
function onCastSpell(cid, var)
    local party = getPartyMembers(cid)
    if party then
        for i = 1, #party do
            if getDistanceBetween(getCreaturePosition(cid), getCreaturePosition(party[i])) <= 6 then
                if getPlayerMana(party[i]) >= 1 then
                    mpAm = (getPlayerMana(party[i]) / 4)
                    doTargetCombatMana(0, party[i], -mpAm, -mpAm, CONST_ME_MAGIC_BLUE)
                    doPlayerSendTextMessage(party[i], MESSAGE_INFO_DESCR, 'You have given '..getPlayerByName(cid)..' some of your mana!')
                    doTargetCombatMana(0, cid, mpAm, mpAm, CONST_ME_MAGIC_BLUE)
                end
            end
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have no party members!')
    end
end
Code:
[18/01/2014 21:50:48] Lua Script Error: [Spell Interface]
[18/01/2014 21:50:48] data/spells/scripts/mana steal.lua:onCastSpell
[18/01/2014 21:50:48] data/spells/scripts/mana steal.lua:9: attempt to concatenate a boolean value
[18/01/2014 21:50:48] stack traceback:
[18/01/2014 21:50:48]    [C]: in function '__concat'
[18/01/2014 21:50:48]    data/spells/scripts/mana steal.lua:9: in function <data/spells/scripts/mana steal.lua:1>
 
try This One
Code:
function onCastSpell(cid, var)
    local party = getPartyMembers(cid)
    if party then
        for i = 1, #party do
            if getDistanceBetween(getCreaturePosition(cid), getCreaturePosition(party[i])) <= 6 then
                if getPlayerMana(party[i]) >= 1 then
                    mpAm = (getPlayerMana(party[i]) / 4)
                    doTargetCombatMana(0, party[i], -mpAm, -mpAm, CONST_ME_MAGIC_BLUE)
                    doPlayerSendTextMessage(party[i], MESSAGE_INFO_DESCR, 'You have given '..getPlayerByName(getCreatureName(cid))..' some of your mana!')
                    doTargetCombatMana(0, cid, mpAm, mpAm, CONST_ME_MAGIC_BLUE)
                end
            end
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have no party members!')
    end
end
 
Code:
function onCastSpell(cid, var)
     local party = getPartyMembers(cid)
     if party then
         for i = 1, #party do
             if getDistanceBetween(getCreaturePosition(cid), getCreaturePosition(party[i])) <= 6 then
                 if getPlayerMana(party[i]) >= 1 then
                     mpAm = (getPlayerMana(party[i]) / 4)
                     doTargetCombatMana(0, cid, mpAm, mpAm, CONST_ME_MAGIC_BLUE)
                     if party[i] ~= cid then
                         doTargetCombatMana(0, party[i], -mpAm, -mpAm, CONST_ME_MAGIC_BLUE)
                         doPlayerSendTextMessage(party[i], MESSAGE_INFO_DESCR, 'You have given '..getPlayerName(cid)..' some of your mana!')
                     end        
                 end
             end
         end
         return true
     else
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have no party members!')
     end
end
 
Last edited:
00:49 You have given 268436563 some of your mana!
I cannot really see if it is working or not, but that message appears on both the caster and the casted.
 
Tested with TFS 0.2.15.
All party members got this:
ePZQ0T.png

The person (Sorcerer) who casted the spell didn't get any message.
 
Oh, that was just for more party members, else it will only work for the first party member, the rest of the party members would be ignored, like they are not in the party :p
That didn't had influence on the name in the message and if the caster got the message.
 
Last edited:
Back
Top