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

Request small error fix is spell

izaak

New Member
Joined
Feb 1, 2009
Messages
161
Reaction score
3
this script summons 4 monsters on cast spell but it also gives 4 errors oncastspell
it works though the summons become mine and the dont attack me but if any1 could help me get the errors out of my console i would apreciate it

heres the script

Code:
function onCastSpell(cid, var)
local dir = getPlayerLookDir(cid)
local pos = getPlayerPosition(cid)
local Monster = demonic soldier
if(dir==1)then
	pos.x = pos.x + 1
elseif(dir==2)then
	pos.y = pos.y + 1
elseif(dir==3)then
	pos.x = pos.x - 1
elseif(dir==0)then
	pos.y = pos.y - 1
end

doSummonMonster(cid)
doConvinceCreature(cid,"demonic soldier")
doSummonMonster(cid)
doConvinceCreature(cid,"demonic soldier")	
doSummonMonster(cid)
doConvinceCreature(cid,"demonic soldier")
doSummonMonster(cid)
doConvinceCreature(cid)			
	return LUA_NO_ERROR

end

and here is my error in the console

Code:
[03/10/2010 06:38:53] [Error - Spell Interface] 
[03/10/2010 06:38:53] data/spells/scripts/Enslaver/Slaves.lua:onCastSpell
[03/10/2010 06:38:53] Description: 
[03/10/2010 06:38:53] (luaDoConvinceCreature) Creature not found

[03/10/2010 06:38:53] [Error - Spell Interface] 
[03/10/2010 06:38:53] data/spells/scripts/Enslaver/Slaves.lua:onCastSpell
[03/10/2010 06:38:53] Description: 
[03/10/2010 06:38:53] (luaDoConvinceCreature) Creature not found

[03/10/2010 06:38:53] [Error - Spell Interface] 
[03/10/2010 06:38:53] data/spells/scripts/Enslaver/Slaves.lua:onCastSpell
[03/10/2010 06:38:53] Description: 
[03/10/2010 06:38:53] (luaDoConvinceCreature) Creature not found

[03/10/2010 06:38:53] [Error - Spell Interface] 
[03/10/2010 06:38:53] data/spells/scripts/Enslaver/Slaves.lua:onCastSpell
[03/10/2010 06:38:53] Description: 
[03/10/2010 06:38:53] (luaDoConvinceCreature) Creature not found
 
This isn't tested.

Code:
function onCastSpell(cid, var)
	local dir = getPlayerLookDir(cid)
	local pos = getCreaturePosition(cid)
	
	if(dir==1)then
		pos.x = pos.x + 1
	elseif(dir==2)then
		pos.y = pos.y + 1
	elseif(dir==3)then
		pos.x = pos.x - 1
	elseif(dir==0)then
		pos.y = pos.y - 1
	end
	
	local c = "Demonic Soldier"
	if table.maxn(getCreatureSummons(cid)) <= 0 then
		for i = 1, 4 do
			doSummonCreature(c[i])
		end
	else
		return doPlayerSendCancel(cid, "Sorry, not possible.")
	end
	
	return true
end
 
hi JDB thank you for youre quik responce the script u posted returs this

Code:
[03/10/2010 07:16:35] [Error - Spell Interface] 
[03/10/2010 07:16:35] data/spells/scripts/Enslaver/Armie of the dead.lua:onCastSpell
[03/10/2010 07:16:35] Description: 
[03/10/2010 07:16:35] attempt to index a nil value
[03/10/2010 07:16:35] stack traceback:
[03/10/2010 07:16:35] 	[C]: in function 'doCreateMonster'
[03/10/2010 07:16:35] 	data/lib/050-function.lua:282: in function 'doSummonCreature'
[03/10/2010 07:16:35] 	data/spells/scripts/Enslaver/Armie of the dead.lua:18: in function <data/spells/scripts/Enslaver/Armie of the dead.lua:1>
[03/10/2010 07:16:55] Dredzor has logged out.
 
Try
Lua:
function onCastSpell(cid, var)
	if getTileInfo(getThingPos(cid)).protection then
		return not doPlayerSendDefaultCancel(cid, RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE)
	end

	local n, v = #getCreatureSummons(cid)
	for i = 1, 4 - n do
		v = doCreateMonster('Demonic Soldier', getClosestFreeTile(cid, getThingPos(cid), true), false)
		if isCreature(v) then
			doConvinceCreature(cid, v)
			doSendMagicEffect(getThingPos(v), CONST_ME_TELEPORT)
		end
	end

	local f = #getCreatureSummons(cid)
	return v and f > n and doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE) and (f < 4 and doPlayerSendCancel(cid, 'There is not enough room.') or true) or not doPlayerSendCancel(cid, 'You cannot summon more creatures.')
end
 
Last edited:
Back
Top