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

Summon convice stage

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
 
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 clones = {
    [{1, 29}] = "Kugutsu[10]",
    [{30, 70}] = "Kugutsu[30]"
}

local cloneName, MaxSummon = '', 2

function summonCreatureBasedOnLevel(playerLevel)
    for level, creatureName in pairs(clones) do
        if playerLevel >= level[1] and playerLevel <= level[2] then
            cloneName = creatureName
            return true
        end
    end
    return false
end

function onCastSpell(cid, var)
    if(#getCreatureSummons(cid) < MaxSummon) then
        if summonCreatureBasedOnLevel(getPlayerLevel(cid)) then
            local pos = getPlayerPosition(cid)
            local clone = doSummonCreature(cid, cloneName, pos)
            doConvinceCreature(cid, clone)
            doChangeSpeed(clone, getCreatureBaseSpeed(cid))
            local creatureHealth = (getCreatureMaxHealth(cid) / 2)
            setCreatureMaxHealth(clone, creatureHealth)
            doCreatureAddHealth(clone, creatureHealth)
            pos.x = pos.x + 1
            doSendMagicEffect(pos, CONST_ME_BIGPLANTS)
            return true
        end
    end
    doSendMagicEffect(pos, CONST_ME_POFF)
    return false
end
 
Back
Top