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

Solved Random Added Spells with book with description

Lightonia

Lightonia.servegame.com
Joined
Jun 4, 2007
Messages
492
Reaction score
9
Hi, i have a script where you use a book and recieve a spellbook and with that you can learn a spell,
But i cant seem to find how to make it choose between a certain amount of spells randomly and show description of it for example:

You see a unidentified book. ID 6124
And then you use it and it says
You removed the dust and discovered a spell book!
and i want you too look at the book at it says for example:
You see a spellbook. ID 1982
You can learn ...Spellname.. by reading this book.

Here is the script:
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

Thanks

- - - Updated - - -

bump
 
LUA:
--[[Created by Summ
    Right click on Torn Book retrieve a Purple Tome
    Right click it and receive a spell, 
]]--

local config = {
    unidentifiedBook = 6124,
    identifiedBook = 1982,
    spells = {"Berserk", "Light Healing", "Cure Poison"}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == config.unidentifiedBook then
        local spell = getInstantSpellInfo(config.spells[math.random(#config.spells)])
        if spell then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, string.format("You removed the dust and discovered a spell book for '%s'!", spell.name))
            doTransformItem(item.uid, config.identifiedBook) 
            doItemSetAttribute(item.uid, "spellLearn", spell.name)
            doItemSetAttribute(item.uid, "description", string.format("It contains the knowledge about '%s' (%s).", spell.name, spell.words))
            doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
        else
            doPlayerSendCancel(cid, "#Spellbook: Invalid spell, contact Admins.")
        end
    elseif item.itemid == config.identifiedBook then
        local spellName = getItemAttribute(item.uid, "spellLearn")
        if spellName then      
            local spellInfo = getInstantSpellInfo(spellName)
            if not spellInfo then
                doPlayerSendCancel(cid, "#Spellbook2: Invalid spell, contact Admins.")
                return true
            end
            
            if getPlayerLearnedInstantSpell(cid, spellInfo.name) then
                doPlayerSendCancel(cid, "You already know this spell.")
                doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
                return true
            end
            
            doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
            doPlayerLearnInstantSpell(cid, spellInfo.name)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, string.format("You just learned %s!\nThe spell is '%s'.", spellInfo.name, spellInfo.words))
            doRemoveItem(item.uid)
        else
            doPlayerSendCancel(cid, "This spellbook does not contain any knowledge.")
        end
    end
    return true
end
 
Back
Top