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

Solved Animate Dead Rune

Some1

New Member
Joined
Jan 12, 2013
Messages
40
Reaction score
4
Hello, could anyone tell me whats wrong with this? I mean, until level 20 the player summons Skeletons, after 21 he summons Skeleton Warriors but after 40 he still summons Skeleton Warriors instead of Demon Skeletons.
Code:
local function doTargetCorpse(cid, position)
    position.stackpos = 255
    local corpse = getThingFromPos(position)
    if(corpse.uid > 0 and isCorpse(corpse.uid) and isMoveable(corpse.uid) and getCreatureSkullType(cid) ~= SKULL_BLACK) then
        if getPlayerLevel(cid) <= 20 then
               doRemoveItem(corpse.uid)
               doPlayerRemoveItem(cid, 2316, 1)
        doConvinceCreature(cid, doCreateMonster("Skeleton", position))
        doSendMagicEffect(position, CONST_ME_MAGIC_BLUE) else   
       
        if getPlayerLevel(cid) >= 21 then
            doPlayerRemoveItem(cid, 2316, 1)
            doRemoveItem(corpse.uid)
        doConvinceCreature(cid, doCreateMonster("Skeleton Warrior", position))
        doSendMagicEffect(position, CONST_ME_MAGIC_BLUE) else       
       
        if getPlayerLevel(cid) >= 40 then
            doPlayerRemoveItem(cid, 2316, 1)
            doRemoveItem(corpse.uid)
        doConvinceCreature(cid, doCreateMonster("Demon Skeleton", position))
        doSendMagicEffect(position, CONST_ME_MAGIC_BLUE) else           
        return true
    end
end
end
end

    doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    return false
end

function onCastSpell(cid, var)
    local position = variantToPosition(var)
    if(position.x ~= 0 and position.y ~= 0) then
        return doTargetCorpse(cid, position)
    end

    doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    return false
end
 
If you have a problem with a script, post your server version and explain what the problem is so people don't have to guess.
Use elseif instead of if and else for the level checks. Atm it works like this.
Code:
if getPlayerLevel(cid) <= 20 then -- if level is 20 or lower
     doRemoveItem(corpse.uid)
     doPlayerRemoveItem(cid, 2316, 1)
     doConvinceCreature(cid, doCreateMonster("Skeleton", position))
     doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)
else -- if higher then level 20
     if getPlayerLevel(cid) >= 21 then -- if level is 21 or higher
         doPlayerRemoveItem(cid, 2316, 1)
         doRemoveItem(corpse.uid)
         doConvinceCreature(cid, doCreateMonster("Skeleton Warrior", position))
         doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)
     else -- if not level 21 or higher
         if getPlayerLevel(cid) >= 40 then -- so it will never do that since this is higher than level 21
             doPlayerRemoveItem(cid, 2316, 1)
             doRemoveItem(corpse.uid)
             doConvinceCreature(cid, doCreateMonster("Demon Skeleton", position))
             doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)
         else
             return true
         end
     end
end
You can also do this.
Code:
getPlayerLevel(cid) < 20 and "Skeleton" or (getPlayerLevel(cid) >= 40 and "Demon Skeleton" or "Skeleton Warrior")
Then use this in doCreateMonster, this way you don't have to repeat the functions.
 

Similar threads

Back
Top