• 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 Convince Creatues does not consider enough room

Sytoxian

New Member
Joined
Aug 19, 2010
Messages
40
Reaction score
1
Hey,

i created a simple spell to summon a monster:

Code:
function onCastSpell(cid, var)
   local summons = getCreatureSummons(cid)
   if(table.maxn(summons) < 2) then
     bomb_health = ((getCreatureMaxHealth(cid) / 100) * 60 )
     position = getCreaturePosition(cid)
     creature = doCreateMonster("Water Healer", position)
     doConvinceCreature(cid, creature)
     setCreatureMaxHealth(creature, bomb_health)
     doCreatureAddHealth(creature, (getCreatureMaxHealth(creature) - getCreatureHealth(creature)))
     doChangeSpeed(creature, -(2000 - getCreatureSpeed(cid)))
   else
     doPlayerSendCancel(cid, "You can only summon two creatures.")
   end
return true
end

But it does not consider the space around the player. When i cast this spell while im stucked somewhere i get this error message:

Code:
[06/05/2015 11:30:20] [Error - Spell Interface]
[06/05/2015 11:30:20] data/spells/scripts/cast/water healer.lua:onCastSpell
[06/05/2015 11:30:20] Description:
[06/05/2015 11:30:20] (luaDoCreateMonster) Cannot create monster: Water Healer

[06/05/2015 11:30:20] [Error - Spell Interface]
[06/05/2015 11:30:20] data/spells/scripts/cast/water healer.lua:onCastSpell
[06/05/2015 11:30:20] Description:
[06/05/2015 11:30:20] (luaDoConvinceCreature) Creature not found

[06/05/2015 11:30:20] [Error - Spell Interface]
[06/05/2015 11:30:20] data/spells/scripts/cast/water healer.lua:onCastSpell
[06/05/2015 11:30:20] Description:
[06/05/2015 11:30:20] (luaSetCreatureMaxHealth) Creature not found

[06/05/2015 11:30:20] [Error - Spell Interface]
[06/05/2015 11:30:20] data/spells/scripts/cast/water healer.lua:onCastSpell
[06/05/2015 11:30:20] Description:
[06/05/2015 11:30:20] (luaGetCreatureMaxHealth) Creature not found

[06/05/2015 11:30:20] [Error - Spell Interface]
[06/05/2015 11:30:20] data/spells/scripts/cast/water healer.lua:onCastSpell
[06/05/2015 11:30:20] Description:
[06/05/2015 11:30:20] (luaGetCreatureHealth) Creature not found

[06/05/2015 11:30:20] [Error - Spell Interface]
[06/05/2015 11:30:20] data/spells/scripts/cast/water healer.lua:onCastSpell
[06/05/2015 11:30:20] Description:
[06/05/2015 11:30:20] data/spells/scripts/cast/water healer.lua:9: attempt to perform arithmetic on a boolean value
[06/05/2015 11:30:20] stack traceback:
[06/05/2015 11:30:20]    data/spells/scripts/cast/water healer.lua:9: in function <data/spells/scripts/cast/water healer.lua:1>

I get the same error message when i cast the spell while the player is surronded by magic fields.

So i need a way to check if there is enough space and there are not too mouch magic fields arround the player. But i dont know how!

Thanks.
 
You can add those lines into your script and check if it will work.
Code:
local playerpos = getCreaturePosition(cid)
local pos = getClosestFreeTile(cid, playerpos)
creature = doCreateMonster("Water Healer", pos)
 
Back
Top