CreatureEvent Spells on Level Up, let players know which spells do they learn!

Discussion in 'GlobalEvents, Spells & CreatureEvents' started by cbrm, Jul 8, 2010.

  1. cbrm

    cbrm Just another mod Staff Member Global Moderator

    Joined:
    Jan 6, 2009
    Messages:
    6,528
    Likes Received:
    808
    Best Answers:
    0
    [​IMG]
    Today I modified the action script of the book of spells. This new script shows a message displaying the detailed info of the new spells the player can make/learns when he levels up. If there are not new spells for a new level the script is not activated of course.

    CONFIGURATION

    repeatAfterDeath

    true -> player will always get the msg at lvlup
    false -> player will only get the message the 1st time he gets the new level

    detailedInfo
    true -> player will get name, words, mana & mana% info of spells
    false -> player will only get the name and the words of the spells

    messageType
    'channel' -> displays a channel message with pre-configured message class
    'popUp' -> displays a text dialog

    channelClass
    This option only applies when messageType is 'channel', default value is MESSAGE_EVENT_ORANGE
    Code (Lua):
    1. MESSAGE_STATUS_CONSOLE_RED
    2. MESSAGE_EVENT_ORANGE = 19
    3. MESSAGE_STATUS_CONSOLE_ORANGE = 20
    4. MESSAGE_STATUS_WARNING = 21
    5. MESSAGE_EVENT_DEFAULT = 23
    6. MESSAGE_STATUS_DEFAULT = 24
    7. MESSAGE_INFO_DESCR = 25
    8. MESSAGE_STATUS_SMALL = 26
    9. MESSAGE_STATUS_CONSOLE_BLUE = 27
    SETUP

    *create creaturescripts/scripts/spellup.lua

    Code (Lua):
    1. --[[------------------------------------------------<|]
    2.     |* * * * * * * * * * * * * * * * * * * * * * * * * * *|
    3.     |* * * * * * *  [SpellUp! Script] * * * * * * * * * * |
    4.     |* * * * * * * * By: Cybermaster * * * * * * * * * * *|    
    5.     |* * *  Tested on: The Forgotten Server 0.3.6pl1 * * *|
    6.     |* * * * * * * * * * * * * * * * * * * * * * * * * * *|
    7.     |>---------------------------------------------------]]
    8.  
    9. local s = { --SETUP
    10.     repeatAfterDeath = false, -- true -> player will always get the msg at lvlup | false -> player will only get the 1st time the gets the new level
    11.     detailedInfo = true, -- true -> player will get name, words, mana & mana% info of spells | false -> player will only get the name and the words of the spells
    12. -- storage below is where the newlevel will be stored ONLY IF YOU USE repeatAfterDeath
    13.     Storage = 10000,
    14.     messageType = 'channel', -- options: 'popUp' or 'channel'
    15. --this one below only used if messageType = channel
    16.     channelClass = MESSAGE_EVENT_ORANGE
    17.     }
    18.    
    19. function onAdvance(cid, skill, oldlevel, newlevel)
    20.     if skill ~= SKILL__LEVEL or not s.repeatAfterDeath and getCreatureStorage(cid, s.Storage) >= newlevel then
    21.         return true
    22.     end
    23.  
    24.     local t = {}
    25.     for i = 0, getPlayerInstantSpellCount(cid) - 1 do
    26.         local spell = getPlayerInstantSpellInfo(cid, i)
    27.         if(spell.level ~= 0) and spell.level == newlevel then
    28.             if(spell.manapercent > 0) then
    29.                 spell.mana = spell.manapercent .. '%'
    30.             end
    31.             table.insert(t, spell)
    32.         end
    33.     end
    34.  
    35.     table.sort(t, function(a, b) return a.level < b.level end)
    36.     local text, prevLevel = '', -1
    37.     for i, spell in ipairs(t) do
    38.         local line = ''
    39.         if(prevLevel ~= spell.level) then
    40.             if(i ~= 1) then
    41.                 line = '\n'
    42.             end
    43.  
    44.             line = line .. 'You have just advanced to level '..newlevel..' and learned new spells!\n'
    45.             prevLevel = spell.level
    46.         end
    47.         text = text ..line..' ['..spell.name..'] "'..spell.words..'" '..(s.detailedInfo and 'Mana['..spell.mana..']'..(spell.mlevel > 0 and ' ML['..spell.mlevel..']' or '') or '')..'\n'
    48.     end
    49.  
    50.     if text == '' then
    51.         return true
    52.     end
    53.  
    54.     doCreatureSetStorage(cid, s.Storage, newlevel)
    55.     if s.messageType == 'popUp' then
    56.         doShowTextDialog(cid, 2175, text)
    57.     elseif s.messageType == 'channel' then
    58.         doPlayerSendTextMessage(cid, s.channelClass, text)
    59.     end
    60.     return true
    61. end
    *[email protected]creaturescripts/creaturescripts.xml
    Code (XML):
    1. <event type="advance" name="SpellUp" event="script" value="spellup.lua"/>
    *[email protected]creaturescripts/scripts/login.lua
    Code (Lua):
    1. registerCreatureEvent(cid,'SpellUp')
    That's all you have to do :peace:
     
    Last edited: Aug 28, 2017
    Limos, Ub Kenobi and Spratt like this.
  2. norse123

    norse123 Active Member

    Joined:
    Jun 26, 2010
    Messages:
    1,186
    Likes Received:
    15
    Best Answers:
    0
    Good work:)Ill try it to my ot:p
     
  3. semary

    semary [BB] OTland

    Joined:
    May 3, 2009
    Messages:
    814
    Likes Received:
    21
    Best Answers:
    0
    Nice release cyber ;) REp++
     
  4. iBlue

    iBlue Banned User

    Joined:
    Feb 23, 2010
    Messages:
    1,557
    Likes Received:
    36
    Best Answers:
    0
    Always making useful scripts that I put into my imaginary OT!
     
  5. soul4soul

    soul4soul Well-Known Member

    Joined:
    Aug 13, 2007
    Messages:
    1,783
    Likes Received:
    41
    Best Answers:
    0
    i like it. its a really nice idea. especially for servers that have loads of custom spells.
     
  6. cbrm

    cbrm Just another mod Staff Member Global Moderator

    Joined:
    Jan 6, 2009
    Messages:
    6,528
    Likes Received:
    808
    Best Answers:
    0
    thanks :) keep commenting
     
  7. BeniS

    BeniS Well-Known Member

    Joined:
    Aug 8, 2009
    Messages:
    1,849
    Likes Received:
    182
    Best Answers:
    0
    thanks Cybershot!! Saves me so much time, Keep up the great scripts :D
     
  8. Renusek

    Renusek beton beton beton punk!

    Joined:
    Jul 24, 2008
    Messages:
    1,047
    Likes Received:
    9
    Best Answers:
    0
    Oh, nice script - useful. Thanks :).
     
  9. Summ

    Summ (\/)(;,,;)(\/) Y not? Staff Member Global Moderator

    Joined:
    Oct 15, 2008
    Messages:
    4,134
    Likes Received:
    1,036
    Best Answers:
    2
    Great idea Rep++ ;d
     
  10. HeberPcL

    HeberPcL [PowerOT.com.br]

    Joined:
    Aug 21, 2007
    Messages:
    1,275
    Likes Received:
    39
    Best Answers:
    0
    Really a great idea for some spells are not very used to end up getting forgotten and unused.

    Nice Job.

    ;]
     
  11. cbrm

    cbrm Just another mod Staff Member Global Moderator

    Joined:
    Jan 6, 2009
    Messages:
    6,528
    Likes Received:
    808
    Best Answers:
    0
  12. cbrm

    cbrm Just another mod Staff Member Global Moderator

    Joined:
    Jan 6, 2009
    Messages:
    6,528
    Likes Received:
    808
    Best Answers:
    0
    bump
     
  13. MindRage

    MindRage Toss Me

    Joined:
    Nov 11, 2008
    Messages:
    474
    Likes Received:
    66
    Best Answers:
    0
    sweet, it REALLY helps me in my servers :p
     
  14. Realera

    Realera New Member

    Joined:
    May 10, 2009
    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    I like it :p
     
  15. tigerx2

    tigerx2 Member

    Joined:
    Apr 5, 2010
    Messages:
    102
    Likes Received:
    2
    Best Answers:
    0
    TY, works in my TFS 0.3.6pl1
     
  16. Realy Jack...

    Realy Jack... "it-and-yes-no-be"

    Joined:
    Jan 19, 2011
    Messages:
    53
    Likes Received:
    1
    Best Answers:
    0
  17. Kudzu

    Kudzu Active Member

    Joined:
    Apr 9, 2008
    Messages:
    512
    Likes Received:
    37
    Best Answers:
    0
    Thanks!
     
  18. wladca

    wladca New Member

    Joined:
    Dec 9, 2008
    Messages:
    641
    Likes Received:
    6
    Best Answers:
    0
    Don't work in 0.4 ;-/

    Can you make for 0.4 too?
     
  19. Kudzu

    Kudzu Active Member

    Joined:
    Apr 9, 2008
    Messages:
    512
    Likes Received:
    37
    Best Answers:
    0
    For me work >.>
     
  20. Moataz Hero

    Moataz Hero Titania.Sytes.Net

    Joined:
    Jan 1, 2010
    Messages:
    417
    Likes Received:
    11
    Best Answers:
    0
    Loved it thanks :)
     

Share This Page

Loading...