• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

From Unidentified Book to a spell tome

Lightonia

Lightonia.servegame.com
Joined
Jun 4, 2007
Messages
492
Reaction score
9
Hi there, im looking for a script where you randomly loot a Torn Book; ID 6124 from a random monster,
And then you right click on this Torn Book Wich ive named as An Unidentified Tome, and you retrieve a Purple Tome; ID 1982 that is named Spell Book, Description; Property of Salahadin.
And then you right click it and recieve a spell, any spell of My choice, also do-able if not possible to choose wich spell.
Well that is my request, thanks!
 
The torn book turned into a void and debugged after a few seconds, - No Errors though
Also i wonder, if there is any way to choose from wich spells you want to input or if the book can have a description of what spell that is gonna get recieved by using it, thanks!
 
The torn book turned into a void and debugged after a few seconds, - No Errors though
Also i wonder, if there is any way to choose from wich spells you want to input or if the book can have a description of what spell that is gonna get recieved by using it, thanks!

are you sure the id's you gave me are correct?

And yes but not simply. However, you can have the book add only 1 spell as how i set it up in the script and just mention in the description "It has words for xxx spell" or something

- - - Updated - - -

just checked ids and are correct.. hmm let me look
 
Yes, i want the script to add only 1 spell, but randomly mathematiced and shown which spell so that players can trade them between eachother, if they did loot a good spell.
And yeah, the ID's are right
Thanks for your time, its appreciated.
 
Yes, i want the script to add only 1 spell, but randomly mathematiced and shown which spell so that players can trade them between eachother, if they did loot a good spell.
And yeah, the ID's are right
Thanks for your time, its appreciated.

ahh ok, let me have a look how to randomly allocate a spell
aswell as try to fix script
 
Probably not the best way to do it but it will change the item nonetheless
In items .xml change the corresponding item id information to the details you specified.

I tried to make it user friendly by adding comments explaining what each line does
I have not tested this but let me know of any errors and i will try to help.

You want to place this script as book.lua inside actions
LUA:
--[[Created by Ghostx for Lightonia
    Torn Book; ID 6124 
    Purple Tome; ID 1982
    Right click on Torn Book retrieve a Purple Tome
    Right click it and receive a spell, 
]]--
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 6124 then --- The Unidentified Tome id
        doPlayerSendTextMessage(cid, 21, "You removed the dust and discovered a spell book!") --- Message you get on use
        doTransformItem(item.uid, 1982) --- Transforms into the Spell Book
    elseif item.itemid == 1982 then --- Else if the use is on id 1982 then the following happens 
        if getPlayerLearnedInstantSpell(cid, name) == true then --- Put the spell name where it says name. If player has already got spell, then it will tell them
        doPlayerSendTextMessage(cid, 21, "you have already learnt this spell!")
    else
        doPlayerLearnInstantSpell(cid, name) --- with name, put the spell name the same as the name above. Make sure it is the spell name and not the spell words
        doPlayerSendTextMessage(cid, 21, "you have learned a new spell!") --- Message when learnt the new spell.
    end
    return TRUE
    end
end
Also in the actions.xml add these lines
XML:
<action itemid="1982" script="book.lua" />
<action itemid="6124" script="book.lua" />

- - - Updated - - -

Still going to look into random allocation of spell
 
Last edited:
Probably not the best way to do it but it will change the item nonetheless

LUA:
--[[Created by Ghostx for Lightonia
    Torn Book; ID 6124 
    Purple Tome; ID 1982
    Right click on Torn Book retrieve a Purple Tome
    Right click it and receive a spell, 
]]--
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 6124 then --- The Unidentified Tome id
        doPlayerSendTextMessage(cid, 21, "You removed the dust and discovered a spell book!") --- Message you get on use
        doTransformItem(item.uid, 1982) --- Transforms into the Spell Book
    elseif item.itemid == 1982 then --- Else if the use is on id 1982 then the following happens 
        if getPlayerLearnedInstantSpell(cid, name) == true then --- Put the spell name where it says name. If player has already got spell, then it will tell them
        doPlayerSendTextMessage(cid, 21, "you have already learnt this spell!")
    else
        doPlayerLearnInstantSpell(cid, name) --- with name, put the spell name the same as the name above. Make sure it is the spell name and not the spell words
        doPlayedSendTextMessage(cid, 21, "you have learned a new spell!") --- Message when learnt the new spell.
    end
    return TRUE
    end
end
Also in the actions.xml add as well as the other action line
XML:
<action itemid="1982" script="book.lua" />

- - - Updated - - -

Still going to look into random allocation of spell

really explained code jajaj
 
Cool, but does it randomly add spells, and another question, was it able to add description?

Edit
Change
LUA:
doPlayedSendTextMessage(cid, 21, "you have learned a new spell!") [I]--- [/I]Message when learnt the new spell.

to
LUA:
doPlayerSendTextMessage(cid, 21, "you have learned a new spell!") [I]--- [/I]Message when learnt the new spell.
 
No, at the moment you have to change where it says "name" to the spell name and can only be 1 spell at the moment. I don't know how to get it to randomly allocate a spell from those listed on the spells.xml.

The description would come with that part of the script.
I need to see how i can get the script to read all spells within spells.xml and select that way... But idk how ^^
So maybe a more advanced scripter can edit my code to do so.

For now this is all i can do,
If there are any errors with the code as is, i will still provide support

regards

- - - Updated - - -

and ty, i missed that xd

- - - Updated - - -

I could list within the script a config with all the spells but that is a long way to do it..
 
Well, i appreciate that you took your time to fix this, and i hope any other more advanced when it comes to lua scripting can assist me from here,
But i still thank you for your time.
Hope you have a good day.
 
Back
Top