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

Solved getCreatureSummons on getCreatureName

KamilM

New Member
Joined
Jul 19, 2013
Messages
14
Reaction score
0
something like
local monster = "Demon"
... if getCreatureName(cid) == monster then
then perform a spell
Code:
function onCastSpell(cid, var)
    local summons = getCreatureSummons(cid)--wrong, need name monster
    if #summons > 0 then-- wrong, need name monster
        for _, pid in pairs(summons) do
            var.pos = getCreaturePosition(pid)
            doCombat(cid, combat, var)
        end
        return true
    end
    return doPlayerSendCancel(cid, "You dont have any summon.")
end
Please, help
 
What exactly are you trying to do?
If the summon name should be demon, you can do it like this (under the for loop)
Code:
if getCreatureName(pid) == "Demon" then

Or is the demon a wild monster, so just the target of the player?
 
Want to remove from this script the number of monsters needed to complete the spell and be replaced with this one monster called Demon
will show on the function
Code:
function onCastSpell(cid, var)
    local monster = "Demon"
    if getCreatureName(cid) == monster then
        for _, pid in pairs(monster) do
            var.pos = getCreaturePosition(pid)
            doCombat(cid, combat, var)
        end
        return true
    end
    return doPlayerSendCancel(cid, "You need Demon monster to use this spell.")
end
 
So you want the target to be a demon? What exactly should the spell do?
You can use
Code:
local target = getCreatureTarget(cid)
if getCreatureName(target) == "Demon" then
If players need to target the monster while using the spell.

If the spell is an area combat, like an ue, so it's the players aren't supposed to target the monster, you can use
Code:
function onTargetCreature(cid, target)
     if isMonster(target) and getCreatureName(target) == "Demon" then
         -- what it should do
     end
     return true
end
setCombatCallback(combat, CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")
 
Ok, so a player summons a demon, and the player can only do the spell if one of the summons is a demon?
Then what you had before is correct, just add this under the loop (and remove this: var.pos = getCreaturePosition(pid))
Code:
if getCreatureName(pid) == "Demon" then

Also remove the return from the cancelmessage, so it will return false and won't cost mana when a player doesn't have a summon.
Or do it like this
Code:
for _, pid in pairs(summons) do
     if getCreatureName(pid) == "Demon" then
         return doCombat(cid, combat, var)
     end
end
doPlayerSendCancel(cid, "You need Demon summon to use this spell.")
 
Last edited:
Code:
function onCastSpell(cid, var)
     local summons = getCreatureSummons(cid)
     if #summons > 0 then
         for _, pid in pairs(summons) do
             if getCreatureName(pid) == "Demon" then
                 return doCombat(cid, combat, var)
             end
         end
         doPlayerSendCancel(cid, "You need to summon a Demon to use this spell.")
     else
         doPlayerSendCancel(cid, "You don't have any summons, you need to summon a Demon to use this spell.")
     end
end
 
Back
Top