• 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 UH rune that can only be used on yourself

Mr.Caffeine

Active Member
Joined
Nov 4, 2018
Messages
79
Reaction score
43
Hello i have this uh rune script. I would like that rune can only be used to heal yourself, it cannot heal other players and monsters.

I tried to do it by comparing the name "if cid doesn't have the same name as target then cancel" but it didn't work. There are other ways to do this:?

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
function onGetFormulaValues(cid, level, maglevel)
    local ret = getCreatureMaxHealth(cid) * 0.5
    return ret, ret
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
local target = variantToNumber(var)
if getCreatureName(cid) ~= getCreatureName(target) then
doPlayerSendCancel(cid,"You cannot use this rune on monsters or other players")
else
    return doCombat(cid, combat, var)
end
end
 
Solution
I understand this is a different system than yours (OTHIRE) but we have some runes that can only be used on other players, and only be used on self. This is one of the one that heals only the man using it, and no one else. Perhaps you could modify this to work for you?


Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)

function onGetFormulaValues(cid)
    local min = 2000 
        local max = 2000
    return doPlayerAddMana(cid...
You don't need to compare names.
cid and target are numbers so you can just cid ~= target

try adding return false below the line with doPlayerSendCancel
 
You don't need to compare names.
cid and target are numbers so you can just cid ~= target

try adding return false below the line with doPlayerSendCancel

Thanks for the suggestion but it's not working with
Code:
cid ~= target
I can't heal other players but I can't heal myself either
 
Try this.
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
function onGetFormulaValues(cid, level, maglevel)
    local ret = getCreatureMaxHealth(cid) * 0.5
    return ret, ret
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
    print(cid, var.number)
    if cid ~= var.number then
        doPlayerSendCancel(cid,"You cannot use this rune on monsters or other players.")
        return false
    end
    return doCombat(cid, combat, var)
end
 
Try this.
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
function onGetFormulaValues(cid, level, maglevel)
    local ret = getCreatureMaxHealth(cid) * 0.5
    return ret, ret
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
    print(cid, var.number)
    if cid ~= var.number then
        doPlayerSendCancel(cid,"You cannot use this rune on monsters or other players.")
        return false
    end
    return doCombat(cid, combat, var)
end

It's still not working, I can't use it on other players/monsters but I can't use it in my character either
 
I understand this is a different system than yours (OTHIRE) but we have some runes that can only be used on other players, and only be used on self. This is one of the one that heals only the man using it, and no one else. Perhaps you could modify this to work for you?


Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)

function onGetFormulaValues(cid)
    local min = 2000 
        local max = 2000
    return doPlayerAddMana(cid, math.random(min, max))
end

setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(cid, var) 

    local mana = getPlayerMana(cid)
    
    
    
    if var.number == nil or cid == var.number then
        local playerPos = getCreaturePosition(cid)
        local pos = variantToPosition(var)
        if(pos.x == playerPos.x and pos.y == playerPos.y and pos.z == playerPos.z) then
           
            
             doCombat(cid, combat, var)
             local mana2 = getPlayerMana(cid)
             doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, "You used an ultra mana rune and recovered ".. mana2 - mana  .. " mana points")
             
            return true
        end
    end
    
     
    doPlayerSendCancel(cid, "You can only use this rune on yourself.")
    
    
    
    return true
end

In spells, it is as:
<rune name="unknown" id="2294" maglv="25" needtarget="1" aggressive="0" charges="5" script="custom/manarune.lua" />

Good luck!
 
Solution
I understand this is a different system than yours (OTHIRE) but we have some runes that can only be used on other players, and only be used on self. This is one of the one that heals only the man using it, and no one else. Perhaps you could modify this to work for you?


Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)

function onGetFormulaValues(cid)
    local min = 2000
        local max = 2000
    return doPlayerAddMana(cid, math.random(min, max))
end

setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)

    local mana = getPlayerMana(cid)
   
   
   
    if var.number == nil or cid == var.number then
        local playerPos = getCreaturePosition(cid)
        local pos = variantToPosition(var)
        if(pos.x == playerPos.x and pos.y == playerPos.y and pos.z == playerPos.z) then
          
           
             doCombat(cid, combat, var)
             local mana2 = getPlayerMana(cid)
             doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, "You used an ultra mana rune and recovered ".. mana2 - mana  .. " mana points")
            
            return true
        end
    end
   
    
    doPlayerSendCancel(cid, "You can only use this rune on yourself.")
   
   
   
    return true
end

In spells, it is as:
<rune name="unknown" id="2294" maglv="25" needtarget="1" aggressive="0" charges="5" script="custom/manarune.lua" />

Good luck!

Worked, thanks friend
 
Back
Top