• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Target in a spell.

jestem pro

That is the question
Joined
Apr 20, 2013
Messages
650
Solutions
14
Reaction score
88
Hello. Is it a way to make a target definition in spells?

Code:
function onCastSpell(cid, var)
   local target = getCreatureTarget(cid)
if not isPlayer(target) then
 doCreatureSay(cid, "you cannot heal a monster!", 19)
return false
end
    return doCombat(cid, combat, var)
end
because I already don't have any ideas.
 
Holy shit I can't. It doesn't work:
Code:
function onCastSpell(cid, var)
    if not isPlayer(variantToNumber(var)) then
    doCreatureSay(cid, "you cannot heal a monster!", 19)
    else
    doCreatureSay(cid, "SMR!", TALKTYPE_ORANGE_1)
return doCombat(cid, combat, var)   
end
end
 
Maybe look at the heal_friend.lua file...Also refered to as exura sio. I don't think the player check is even necessary.
 
yeah I know, but I can't do with isMonster. In heal freind.lua there is nothing. XD

I tried to do something in spells.cpp. Add a function "canHealMonster", but I don't know how declare to check a monster.
Code:
if(!canHealMonster && creature->getMonster())
   {
      std::stringstream ss;
   ss << "You cannot heal a monster!";
       player->sendTextMessage(MSG_INFO_DESCR, ss.str().c_str());
       g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
       return false;
   }
This creature->getMosnter(), of course it doesn't work.
 
Last edited by a moderator:
Nobody know how to make it?
I'm trying and trying and fuck.
Code:
function onCastSpell(cid, var)
       local target = isPlayer(cid)
       if isPlayer(cid) == var.nnumber then 
          doCreatureSay(cid, "You cannot heal a monster!", 19)
        
  
    end
      return doCombat(cid, combat, var)
    
    end
I want to check who is the target. And I can't xd. Holy shit (isPlayer is only for test)
I searched everywhere.
 
It's a spell, rune or what? You need to aim the target to cast this spell or just use spell like "exura sio "GarQet"?

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_DISPEL, CONDITION_PARALYZE)
setHealingFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 5, 5, 10, 14)

function onCastSpell(cid, var)
   if isPlayer(variantToNumber(var)) == FALSE then
       return doPlayerSendCancel(cid, "You cannot heal monsters.")
   else
       return doCombat(cid, combat, var)
    end
end
 
Last edited:
@GarQet ooh I'm sorry. It's a healing rune, so when a target is a monster you cannot heal him. This isn't work hmm.

In that case you can use this to compare the target to cid;
LUA:
if variantToNumber(var) == cid then
     execute code
else
      fail msg?
end


It's a spell, rune or what? You need to aim the target to cast this spell or just use spell like "exura sio "GarQet"?

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_DISPEL, CONDITION_PARALYZE)
setHealingFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 5, 5, 10, 14)

function onCastSpell(cid, var)
   if isPlayer(variantToNumber(var)) == FALSE then
       return doPlayerSendCancel(cid, "You cannot heal monsters.")
   else
       return doCombat(cid, combat, var)
    end
end

FYI you could have used "not isPlayer ..." insted of == FALSE
Also it's false not FALSE.
 
Code:
function onCastSpell(cid, var)

   if variantToNumber(var) == cid then
     return doCombat(cid, combat, var)
     else
     doCreatureSay(cid, "You cannot heal the monster!", 19)     
         end
   return true
end
When I try to heal a player or a monster it's saying "You cannot heal the monster!". Hm it doesn't distinction player and monster.
 
Code:
function onCastSpell(cid, var)

   if variantToNumber(var) == cid then
     return doCombat(cid, combat, var)
     else
     doCreatureSay(cid, "You cannot heal the monster!", 19)    
         end
   return true
end
When I try to heal a player or a monster it's saying "You cannot heal the monster!". Hm it doesn't distinction player and monster.
if isMonster(variantToNumber(var)) then
doCreatureSay(cid, "You cannot heal the monster!", 19)
else
...
 
Back
Top