TFS 0.X Monster Skull

Discussion in 'Support' started by newby, Sep 9, 2018.

  1. newby

    newby Member

    Joined:
    Jun 11, 2016
    Messages:
    110
    Likes Received:
    15
    Best Answers:
    0
    I'm trying to add in my server a chance to every monster on spawn, can come with a skull randomly

    I've added this on my source code (from: Feature - [CreatureEvent] OnSpawn(cid))

    And add this on my creaturescript:
    Code (Text):
    1.  
    2. <event type="spawn" name="monsterThink" registerTo ="monster" event="script" value="monsterskull.lua"/>
    3.  
    monsterskull.lua
    Code (Text):
    1.  
    2. function onSpawn(cid)
    3.     -- SKULL_NONE = 0
    4.     -- SKULL_WHITE = 3
    5.     -- SKULL_RED = 4
    6.     -- SKULL_BLACK = 5
    7.     local skull, bonus_percent
    8.     local chance = math.random(1, 100)
    9.     if(chance <= 1) then
    10.         skull = 5
    11.         bonus_percent = 5
    12.     elseif(chance >= 2 and chance <= 5) then
    13.         skull = 4
    14.         bonus_percent = 3
    15.     elseif(chance >= 6 and chance <= 20) then
    16.         skull = 3
    17.         bonus_percent = 2
    18.     else
    19.         skull = 0
    20.         bonus_percent = 0
    21.     end
    22.     if(skull > 0) then
    23.         local hp = (getCreatureMaxHealth(cid)) + ((getCreatureMaxHealth(cid) * bonus_percent) / ( 100 ))
    24.         setCreatureMaxHealth(cid, hp)
    25.         doCreatureSetSkullType(cid, skull)
    26.     end
    27.  
    28.  
    29.  
    30.     doBroadcastMessage("Monster ".. getCreatureName(cid).." was created.")
    31.     return true
    32. end
    33.  
    But monster on spawn dont send the broadcastmessage...
    Do i missing something? Doing something wrong?
     
    supergt likes this.
  2. newby

    newby Member

    Joined:
    Jun 11, 2016
    Messages:
    110
    Likes Received:
    15
    Best Answers:
    0
    bump
     
  3. newby

    newby Member

    Joined:
    Jun 11, 2016
    Messages:
    110
    Likes Received:
    15
    Best Answers:
    0
    bump
     
  4. newby

    newby Member

    Joined:
    Jun 11, 2016
    Messages:
    110
    Likes Received:
    15
    Best Answers:
    0
    bump
     
  5. Sarah Wesker

    Sarah Wesker ค∂vαηcε รүηтαx ❤

    Joined:
    Mar 16, 2017
    Messages:
    313
    Likes Received:
    142
    Best Answers:
    22
    The function is not global and, therefore, you must register the event for each creature, you must try to register the event manually, so you can check!
     
    newby and supergt like this.
  6. newby

    newby Member

    Joined:
    Jun 11, 2016
    Messages:
    110
    Likes Received:
    15
    Best Answers:
    0
    I'm sorry i don't understand...
    Could you make a example or show it in some way?
     
  7. Floris

    Floris Member

    Joined:
    Apr 17, 2008
    Messages:
    213
    Likes Received:
    10
    Best Answers:
    0
    You must put it in a monster file, for example rotworm.xml
     
    newby likes this.
  8. newby

    newby Member

    Joined:
    Jun 11, 2016
    Messages:
    110
    Likes Received:
    15
    Best Answers:
    0
    What are u mean?

    Add in every monster.xml something like:
    Code (Text):
    1.  
    2. <script>
    3.         <event name="something"/>
    4. </script>
    5.  
    :eek:
     
  9. Sir Sezago

    Sir Sezago Scripter/Developer

    Joined:
    Aug 28, 2017
    Messages:
    214
    Likes Received:
    12
    Best Answers:
    0
    u need to make random skulls so u need to active it in your sources..
     
  10. Nameless#1337

    Nameless#1337 New Member

    Joined:
    Jul 6, 2016
    Messages:
    23
    Likes Received:
    3
    Best Answers:
    1
  11. Sir Sezago

    Sir Sezago Scripter/Developer

    Joined:
    Aug 28, 2017
    Messages:
    214
    Likes Received:
    12
    Best Answers:
    0
    Random Skull code with more heath .
    Code (Text):
    1.  
    2. function onSpawn(cid)
    3.                if math.random(1, 50) == 1 and isMonster(cid) then
    4.                    doCreatureSetSkullType(cid, 5)
    5.                    doCreatureSetStorage(cid, 110, 1)
    6.                    setCreatureMaxHealth(cid, getCreatureHealth(cid) + (getCreatureHealth(cid) * 2))
    7.                doCreatureAddHealth(cid, getCreatureHealth(cid) * 2)
    8.                elseif math.random(1, 30) == 1 and isMonster(cid) then
    9.                    doCreatureSetSkullType(cid, 4)
    10.                    doCreatureSetStorage(cid, 111, 1)
    11.                    setCreatureMaxHealth(cid, getCreatureHealth(cid) + (getCreatureHealth(cid) * 0.50))
    12.                doCreatureAddHealth(cid, getCreatureHealth(cid) * 0.50)
    13.                elseif math.random(1, 20) == 1 and isMonster(cid) then
    14.                    doCreatureSetSkullType(cid, 3)
    15.                    doCreatureSetStorage(cid, 112, 1)
    16.             setCreatureMaxHealth(cid, getCreatureHealth(cid) + (getCreatureHealth(cid) * 0.30))
    17.                doCreatureAddHealth(cid, getCreatureHealth(cid) * 0.30)
    18.                end
    19.    return true
    20. end
    21.  
     

Share This Page

Loading...