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

Spell Tomes

Jaffstern

Jaff Sourceworks
Joined
Jan 6, 2013
Messages
33
Reaction score
0
Location
Sweden
Is there any script out there with a function that provides spell learning through books? For example, if you use a book with a certain ID then the character learns a new spell. It'd be nice, because of this you'd be able trade spells, make quests with powerful spell tomes as reward, etc. I'd be grateful if anyone could provide me this sort of script!
 
Yes, just create an onUse action script.
Check if the user already knows the spell using this function:
Lua:
getPlayerLearnedInstantSpell(cid, name)
If he hasn't learned it, then use this function to learn it:
Lua:
playerLearnInstantSpell(cid, name)
 
Makes sense, but since I'm not a scripter nor having much experience with it I'm sure I'd go through a whole lot of errors while trying to put the whole thing together.
 
Lua:
local config = {
	spell = 'Name', -- name of the spell
	vocations = {1, 2, 5, 6},
	level = 100
}

function onUse(cid, item, fromPosition, itemEx, toPosition)

	if getPlayerLearnedInstantSpell(cid, config.spell) then
		return doPlayerSendCancel(cid, "You have already learned the spell "..config.spell..".")
	end

	if not isInArray(config.vocations, getPlayerVocation(cid)) then
		return doPlayerSendCancel(cid, "This spell is not for your vocation.")
	end

	if getPlayerLevel(cid) >= config.level then
    		doPlayerLearnInstantSpell(cid, config.spell)
    		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have learned the spell "..config.spell..".")
	else
		doPlayerSendCancel(cid, "You need to be level "..config.level.." to learn this spell.")
	end
	return true
end
 
Last edited:
Back
Top