Hi, i need help, can you fix it, because i have no idea how do this? please!
If we have level 1 we can summon Monster I, when we up 30 then we can summon monster II, here is code and errors:
If we have level 1 we can summon Monster I, when we up 30 then we can summon monster II, here is code and errors:
Code:
local clones = {
[{1, 29}] = "Monster I",
[{30, 70}] = "Monster II"
}
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