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

TFS 0.X Manarune Problem

potinho

Active Member
Joined
Oct 11, 2009
Messages
415
Solutions
11
Reaction score
38
Location
Brazil
I have a manarune script that works fine, but there's a problem: if I use the rune on me it works as expected, but if I click on the rune and on another player (to add mana to the other player) it gets added to myself (character who uses the rune).

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

function onCastSpell(cid, var)
doSendAnimatedText(getPlayerPosition(cid), "Aaaah...", TEXTCOLOR_ORANGE)
local level = getPlayerLevel(cid)
local magicl = getPlayerMagLevel(cid)
local min = ((level * 0.2) + (magicl * 2) + 50)
local max = ((level * 0.2) + (magicl * 2.5) + 75)

doCreatureAddMana(cid, math.random(min, max))
return doCombat(cid, combat, var)
end
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,612
Solutions
395
Reaction score
3,731
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_MANADRAIN)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
combat:setParameter(COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)

function onGetFormulaValues(cid, level, magicLevel)
    local min = ((level * 0.2) + (magicLevel * 2) + 50)
    local max = ((level * 0.2) + (magicLevel * 2.5) + 75)
    return min, max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
    doSendAnimatedText(getPlayerPosition(cid), "Aaaah...", TEXTCOLOR_ORANGE)
    return doCombat(cid, combat, var)
end
Post automatically merged:

Edited recently. Didn't realize you were using 0.X server
 
OP
OP
potinho

potinho

Active Member
Joined
Oct 11, 2009
Messages
415
Solutions
11
Reaction score
38
Location
Brazil
Got error, using tfs 0.3:

1632868154233.png
Post automatically merged:

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_MANADRAIN)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
combat:setParameter(COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)

function onGetFormulaValues(cid, level, magicLevel)
    local min = ((level * 0.2) + (magicLevel * 2) + 50)
    local max = ((level * 0.2) + (magicLevel * 2.5) + 75)
    return min, max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
    doSendAnimatedText(getPlayerPosition(cid), "Aaaah...", TEXTCOLOR_ORANGE)
    return doCombat(cid, combat, var)
end
Post automatically merged:

Edited recently. Didn't realize you were using 0.X server
still gotting error

1632868520568.png
 
Last edited:

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,612
Solutions
395
Reaction score
3,731
Got error, using tfs 0.3:

View attachment 62415
Post automatically merged:


still gotting error

View attachment 62416
Lua:
local combat = createCombatObject()
setParameter(combat, COMBAT_PARAM_TYPE, COMBAT_MANADRAIN)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

function onGetFormulaValues(cid, level, maglevel)
    local min = ((level * 0.2) + (maglevel * 2) + 50)
    local max = ((level * 0.2) + (maglevel * 2.5) + 75)
    return min, max
end

setCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
    doSendAnimatedText(getPlayerPosition(cid), "Aaaah...", TEXTCOLOR_ORANGE)
    return doCombat(cid, combat, var)
end
 
OP
OP
potinho

potinho

Active Member
Joined
Oct 11, 2009
Messages
415
Solutions
11
Reaction score
38
Location
Brazil
Error yet

1632868820730.png
Lua:
local combat = createCombatObject()
setParameter(combat, COMBAT_PARAM_TYPE, COMBAT_MANADRAIN)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

function onGetFormulaValues(cid, level, maglevel)
    local min = ((level * 0.2) + (maglevel * 2) + 50)
    local max = ((level * 0.2) + (maglevel * 2.5) + 75)
    return min, max
end

setCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
    doSendAnimatedText(getPlayerPosition(cid), "Aaaah...", TEXTCOLOR_ORANGE)
    return doCombat(cid, combat, var)
end
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,612
Solutions
395
Reaction score
3,731
lmao
lmao. trying to convert everything is such a pain.

try
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_MANADRAIN)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

function onGetFormulaValues(cid, level, maglevel)
    local min = ((level * 0.2) + (maglevel * 2) + 50)
    local max = ((level * 0.2) + (maglevel * 2.5) + 75)
    return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
    doSendAnimatedText(getPlayerPosition(cid), "Aaaah...", TEXTCOLOR_ORANGE)
    return doCombat(cid, combat, var)
end
 

Alberto Cabrera

Active Member
Joined
Sep 17, 2020
Messages
37
Solutions
12
Reaction score
38
Location
México
I have a manarune script that works fine, but there's a problem: if I use the rune on me it works as expected, but if I click on the rune and on another player (to add mana to the other player) it gets added to myself (character who uses the rune).

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

function onCastSpell(cid, var)
doSendAnimatedText(getPlayerPosition(cid), "Aaaah...", TEXTCOLOR_ORANGE)
local level = getPlayerLevel(cid)
local magicl = getPlayerMagLevel(cid)
local min = ((level * 0.2) + (magicl * 2) + 50)
local max = ((level * 0.2) + (magicl * 2.5) + 75)

doCreatureAddMana(cid, math.random(min, max))
return doCombat(cid, combat, var)
end

Lua:
-- <action itemid="XXXX" event="script" value="script.lua"/>
local config = {
    level = false,
    magiclevel = false,
    effect = CONST_ME_MAGIC_BLUE,
    remove = false
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local pid = itemEx.uid
    if not isPlayer(pid) then
        return doPlayerSendCancel(cid, "It can only be used on players.")
    end

    local level = getPlayerLevel(pid)
    local magiclevel = getPlayerMagLevel(pid)

    if config.level then
        if level < config.level then
            return doPlayerSendCancel(cid, "It can only be used on players level " .. config.level .. " or higher.")
        end
    end

    if config.magiclevel then
        if magiclevel < config.magiclevel then
            return doPlayerSendCancel(cid, "It can only be used on players magic level " .. config.magiclevel .. " or higher.")
        end
    end

    if config.remove then
        doRemoveItem(item.uid, 1)
    end

    local min = ((level * 0.2) + (magiclevel * 2) + 50)
    local max = ((level * 0.2) + (magiclevel * 2.5) + 75)
    doCreatureAddMana(pid, math.floor(math.random(min, max)))
    doSendMagicEffect(getThingPosition(pid), config.effect)
    doSendAnimatedText(getThingPosition(pid), "Aaaah...", TEXTCOLOR_ORANGE)
    return true
end

This can be useful to you. It is not a spell, it is an action.
 
Top