• 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 Spell storage

Black123

New Member
Joined
Nov 17, 2011
Messages
32
Reaction score
0
Hello, can you help me to do that this spell summons diffrent monster depends on player lvl? My way doesn't work :/

Code:
function onCastSpell(cid, var)
local playerpos = getPlayerPosition(cid)
local health = getCreatureHealth(cid)
local maxhealth = getCreatureMaxHealth(cid)/2
local MaxSummon = 2 --- ile mozna max przyzwac
local summons = getCreatureSummons(cid)
local lvl = getPlayerLevel(cid)
if(table.maxn(summons) < MaxSummon) then
if lvl >= 1 and <= 29 then
local clonename = "Kugutsu[10]"
elseif lvl >= 30 and <= 70 then
local clonename = "Kugutsu[30]"
return true
end
local clone = doSummonCreature(clonename, playerpos)
doConvinceCreature(cid, clone)
doChangeSpeed(clone, getCreatureBaseSpeed(cid))
setCreatureMaxHealth(clone, maxhealth)
doCreatureAddHealth(clone, health)
local posEx = getPlayerPosition(cid)
local posK = {x = posEx.x + 1, y = posEx.y, z = posEx.z}
doSendMagicEffect(posK, 50)
return TRUE
end
end
 
Code:
local cfg = {
    maxSummons = 2,
    magicEffect = 50,
    summonHealthPercent = 50, -- 50% player's hp
    list = {
        [1] = {name = "rat", minlevel = 0},
        [2] = {name = "cave rat", minlevel = 10},
        [3] = {name = "giant rat", minlevel = 20}
    }
}

function onCastSpell(cid, var)
    if table.maxn(getCreatureSummons(cid)) < cfg.maxSummons then
        local lvl = getPlayerLevel(cid)
        local t = {}
        for i = 1, #cfg.list do
            if lvl >= cfg.list[i].minlevel then
                table.insert(t, cfg.list[i].name)
            end
        end
        if t ~= nil and #t > 0 then
            local clone = doSummonCreature(t[#t], getCreaturePosition(cid))
            if isMonster(clone) then
                doConvinceCreature(cid, clone)
                doChangeSpeed(clone, getCreatureBaseSpeed(cid))
                setCreatureMaxHealth(clone, (getCreatureMaxHealth(cid) / 100) * cfg.summonHealthPercent)
                doCreatureAddHealth(clone, (getCreatureMaxHealth(cid) / 100) * cfg.summonHealthPercent)
            end
        end
        doSendMagicEffect(getCreaturePosition(cid), cfg.magicEffect)
    else
        return doPlayerSendCancel(cid, "You cannot control any more creatures at a time.")
    end
    return true
end
 
Last edited:
Code:
local cfg = {
    maxSummons = 2,
    magicEffect = 50,
    summonHealthPercent = 50, -- 50% player's hp
    list = {
        [1] = {name = "rat", minlevel = 0},
        [2] = {name = "cave rat", minlevel = 10},
        [3] = {name = "giant rat", minlevel = 20}
    }
}

function onCastSpell(cid, var)
    if table.maxn(getCreatureSummons(cid)) < cfg.maxSummons then
        local lvl = getPlayerLevel(cid)
        local t = {}
        for i = 1, #cfg.list do
            if lvl >= cfg.list[i].minlevel then
                table.insert(t, cfg.list[i].name)
            end
        end
        if t ~= nil and t > 0 then
            local clone = doSummonCreature(t[#t], getCreaturePosition(cid))
            if isMonster(clone) then
                doConvinceCreature(cid, clone)
                doChangeSpeed(clone, getCreatureBaseSpeed(cid))
                setCreatureMaxHealth(clone, (getCreatureMaxHealth(cid) / 100) * cfg.summonHealthPercent)
                doCreatureAddHealth(clone, (getCreatureMaxHealth(cid) / 100) * cfg.summonHealthPercent)
            end
        end
        doSendMagicEffect(getCreaturePosition(cid), cfg.magicEffect)
    else
        return doPlayerSendCancel(cid, "You cannot control any more creatures at a time.")
    end
    return true
end
nice 1
 
Back
Top