• 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 Summon scroll request

sick

Member
Joined
Feb 5, 2009
Messages
258
Reaction score
6
Location
Lithuania, Vilnius
So i was looking for something like summon scroll around forums and couldn't find one, so made this thread hoping someone has one or will try to do it.

The idea is that you use scroll and it summons you, lets say, demon skeleton, you loose like 500 mana and can have 2 summons at time. They act like you would say utevo res~( listens/follows you ) and the scroll has like 20 charges, after that it becomes blank piece of paper.

I don't want to enable simple summon spell cause it would ruin pvp at my server, summons has to be some kind of special thing :>

Thanks in advance :) :thumbup:
 
Code:
local config = {
	monster = "Demon Skeleton",
	charges = 20,
	manaCost = 500,
	maxSummons = 2
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(getCreatureSummons(cid) >= config.maxSummons) then
		return false
	end

	if(getCreatureMana(cid) < config.manaCost) then
		return false
	end

	if(item.actionid <= 0) then
		doItemSetAttribute(item.uid, "aid", config.charges - 1)
	elseif(item.actionid == 1) then
		doRemoveItem(item.uid)
	else
		doItemSetAttribute(item.uid, "aid", item.actionid - 1)
	end

	local monster = doCreateMonster(config.monster, fromPosition)
	doConvinceCreature(monster)
	doCreatureAddMana(cid, -config.manaCost)
	return true
end
 
Thanks for trying to help but i got this error now and dont have any ideas how to fix this, maybe there is smth wrong with function...

PHP:
[05/09/2010 17:57:39] [Error - Action Interface] 
[05/09/2010 17:57:39] data/actions/scripts/other/summonscroll.lua:onUse
[05/09/2010 17:57:39] Description: 
[05/09/2010 17:57:39] data/actions/scripts/other/summonscroll.lua:9: attempt to compare number with function
[05/09/2010 17:57:39] stack traceback:
[05/09/2010 17:57:39] 	data/actions/scripts/other/summonscroll.lua:9: in function <data/actions/scripts/other/summonscroll.lua:8>
 
Oh I forgot hash character, here's fixed version:
Code:
local config = {
	monster = "Demon Skeleton",
	charges = 20,
	manaCost = 500,
	maxSummons = 2
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(#getCreatureSummons(cid) >= config.maxSummons) then
		return false
	end

	if(getCreatureMana(cid) < config.manaCost) then
		return false
	end

	if(item.actionid <= 0) then
		doItemSetAttribute(item.uid, "aid", config.charges - 1)
	elseif(item.actionid == 1) then
		doRemoveItem(item.uid)
	else
		doItemSetAttribute(item.uid, "aid", item.actionid - 1)
	end

	local monster = doCreateMonster(config.monster, fromPosition)
	doConvinceCreature(monster)
	doCreatureAddMana(cid, -config.manaCost)
	return true
end
 
Now the errors are cleared, however when i try using it, console says that:

PHP:
[05/09/2010 18:27:30] [Error - Action Interface] 
[05/09/2010 18:27:30] data/actions/scripts/other/summonscroll.lua:onUse
[05/09/2010 18:27:30] Description: 
[05/09/2010 18:27:30] (luaDoConvinceCreature) Creature not found

I tried using simple convince creature rune and it works, it finds all the monsters but using this item it doesn't ;s
 
My fault, again :p:
Code:
local config = {
	monster = "Demon Skeleton",
	charges = 20,
	manaCost = 500,
	maxSummons = 2
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(#getCreatureSummons(cid) >= config.maxSummons) then
		return false
	end

	if(getCreatureMana(cid) < config.manaCost) then
		return false
	end

	if(item.actionid <= 0) then
		doItemSetAttribute(item.uid, "aid", config.charges - 1)
	elseif(item.actionid == 1) then
		doRemoveItem(item.uid)
	else
		doItemSetAttribute(item.uid, "aid", item.actionid - 1)
	end

	local monster = doCreateMonster(config.monster, fromPosition)
	doConvinceCreature(cid, monster)
	doCreatureAddMana(cid, -config.manaCost)
	return true
end
 
Damn, whats wrong with it i don't get it ;s Almost nothing changed, just now a new error appeared : Cannot create monster: Demon Skeleton.

Tried editing it lots if times, however I'm not good at these scripts yet, so don't even know whats wrong
 
Code:
local config = {
	[xxxx] = { -- # SCROLL ID # --
		monster = "Demon Skeleton",
		charges = 20,
		mana = 500,
		summons = 2
	}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
        local v = config[item.itemid]
	if table.maxn(getCreatureSummons(cid)) >= v.summons then
		return doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
	end

	if getCreatureMana(cid) < v.mana then
		return doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
	end

	if item.actionid <= 0 then
		doItemSetAttribute(item.uid, "aid", v.charges - 1)
	elseif item.actionid == 1 then
		doRemoveItem(item.uid)
	else
		doItemSetAttribute(item.uid, "aid", item.actionid - 1)
	end

	return doPlayerAddMana(cid, - v.mana) and doSummonMonster(v.monster, getCreaturePosition(cid).x + 1)
end
 
Last edited:
Something is wrong, it says :( :

PHP:
[07/09/2010 09:34:13] data/actions/scripts/other/summonscroll.lua:10: attempt to index global 'item' (a nil value)
[07/09/2010 09:34:13] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/summonscroll.lua)
[07/09/2010 09:34:13] data/actions/scripts/other/summonscroll.lua:10: '<name>' expected near '"v"'
 
try this, fixed doSummonCreature in script from JDB.

Lua:
local config = {
	[xxxx] = { -- # SCROLL ID # --
		monster = "Demon Skeleton",
		charges = 20,
		mana = 500,
		summons = 2
	}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
        local v = config[item.itemid]
	if table.maxn(getCreatureSummons(cid)) >= v.summons then
		return doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
	end

	if getCreatureMana(cid) < v.mana then
		return doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
	end

	if item.actionid <= 0 then
		doItemSetAttribute(item.uid, "aid", v.charges - 1)
	elseif item.actionid == 1 then
		doRemoveItem(item.uid)
	else
		doItemSetAttribute(item.uid, "aid", item.actionid - 1)
	end

	return doPlayerAddMana(cid, - v.mana) and doSummonMonster(cid,v.monster)
end
 
By the is it possible to make it to show how many charges left on it when pressed and if charges are out it doesn't disappear but becomes to piece of paper ( lets say becomes to id: 1954 )
 
Back
Top