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

Lua getCreatureSummons on getCreatureName

milbradt

New Member
Joined
Dec 25, 2011
Messages
177
Solutions
1
Reaction score
4
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

Does not work if I have summoned more monsters...

Ex: My summons = Fire Elemental + Demon + Fire Devil

Script return ELSE.. =\
 
Try this and see if it works
Code:
    local monster = "Demon"
    function onCastSpell(cid, var)
        local summons = getCreatureSummons(cid)
        if #summons > 0 then
            for _, pid in pairs(summons) do
                -- although we could have type the monster's name in lowercase when we declared it
                -- this just makes absolutely sure both names are lowercase when they are compared
                if getCreatureName(pid):lower() == monster:lower() 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
        return true
    end
 
Back
Top