[9.1+] Talking Signs

Discussion in 'GlobalEvents, Spells & CreatureEvents' started by Summ, Dec 4, 2012.

  1. Summ

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

    Joined:
    Oct 15, 2008
    Messages:
    4,130
    Likes Received:
    1,025
    Best Answers:
    2
    [​IMG]

    [​IMG]

    globalevents.xml
    Code (XML):
    1.     <globalevent name="talkingSigns" interval="2000" event="script" value="talking.lua"/>
    globalevents/scripts/talking.lua
    Code (Lua):
    1. local config = {
    2.     positions = {
    3.         {pos = {x = 851, y = 972, z = 7}, text = "Hello Sir! How are you?", effects = {CONST_ME_MAGIC_BLUE}},
    4.         {pos = {x = 855, y = 972, z = 7}, text = "How are you?"}
    5.     },
    6.     effects = {CONST_ME_POFF, CONST_ME_TELEPORT, CONST_ME_MAGIC_RED}
    7. }
    8.  
    9. function onThink(interval)
    10.     local people = getPlayersOnline()
    11.     if #people == 0 then
    12.         return true
    13.     end
    14.    
    15.     for _, info in pairs(config.positions) do
    16.         doPlayerSay(people[1], info.text, TALKTYPE_MONSTER_SAY, false, 0, info.pos)
    17.         if info.effects and #info.effects > 0 then
    18.             doSendMagicEffect(info.pos, info.effects[math.random(#info.effects)])
    19.         elseif config.effects and #config.effects > 0 then
    20.             doSendMagicEffect(info.pos, config.effects[math.random(#config.effects)])
    21.         end
    22.     end
    23.     return true
    24. end
    25.  

    Config Explanation

    Code (Lua):
    1. local config = {
    2.     positions = {
    3.         {pos = {x = 851, y = 972, z = 7}, text = "Hello Sir! How are you?", effects = {CONST_ME_MAGIC_BLUE}},
    4.         {pos = {x = 855, y = 972, z = 7}, text = "How are you?"}
    5.     },
    6.     effects = {CONST_ME_POFF, CONST_ME_TELEPORT, CONST_ME_MAGIC_RED}
    7. }
    Add new signs just like:
    >> {pos = {x = 851, y = 972, z = 7}, text = "Hello Sir! How are you?", effects = {CONST_ME_MAGIC_BLUE}},
    If you leave those effects away it will choose a random effect from this table:
    >> {CONST_ME_POFF, CONST_ME_TELEPORT, CONST_ME_MAGIC_RED}

    Thx.
     
  2. Printer

    Printer if Printer then print("LUA") end Premium User

    Joined:
    Dec 27, 2009
    Messages:
    5,591
    Likes Received:
    1,871
    Best Answers:
    5
    Great Job :)
     
    Evil Puncker likes this.
  3. ninexin

    ninexin insane.sytes.net

    Joined:
    Jun 10, 2007
    Messages:
    213
    Likes Received:
    3
    Best Answers:
    0
    ty for releasee brooo
     
  4. sn3ejk

    sn3ejk This account is inactive.

    Joined:
    Nov 16, 2011
    Messages:
    2,122
    Likes Received:
    142
    Best Answers:
    0
    It works great.
    Thanks for release :].
     
  5. gelendizer

    gelendizer The ass kicker

    Joined:
    Nov 2, 2011
    Messages:
    335
    Likes Received:
    10
    Best Answers:
    0
    Awesome ;)
     
  6. bybbzan

    bybbzan Active Member

    Joined:
    Aug 4, 2012
    Messages:
    650
    Likes Received:
    40
    Best Answers:
    0
    Fucking stunning.
     
  7. Kiwi Dan

    Kiwi Dan Kiwi Server 3.0

    Joined:
    Jun 5, 2007
    Messages:
    618
    Likes Received:
    9
    Best Answers:
    0
    Good job! Just one note, I tested this on 8.6 and it can make the account manager keep saying 'I don't understand you~' spamming it - making the account manager almost useless. I changed your code a little to fix it.

    Code (Lua):
    1.  
    2. function notAccMan(people)
    3.     local thing = 1
    4.     for v, cid in ipairs(getOnlinePlayers()) do
    5.         if cid == "Account Manager" then
    6.             thing = thing + 1
    7.         else           
    8.             return thing
    9.         end
    10.         if thing > #people then
    11.             return false
    12.         end
    13.     end
    14. end
    15.  
    16. function onThink(interval)
    17.     local people = getPlayersOnline()
    18.     if #people == 0 then
    19.         return true
    20.     end
    21.     local thing = notAccMan(people)
    22.     if thing == false then return true end
    23.     for _, info in pairs(config.positions) do
    24.        doPlayerSay(people[thing], info.text, TALKTYPE_MONSTER, false, 0, info.pos)
    25.         if info.effects and #info.effects > 0 then
    26.             doSendMagicEffect(info.pos, info.effects[math.random(#info.effects)])
    27.         elseif config.effects and #config.effects > 0 then
    28.             doSendMagicEffect(info.pos, config.effects[math.random(#config.effects)])
    29.         end
    30.     end
    31.  
     
  8. kozmo

    kozmo Member

    Joined:
    Jan 30, 2009
    Messages:
    352
    Likes Received:
    10
    Best Answers:
    0
    Thanks this was useful Rep+
     
  9. Mikelon

    Mikelon New Member

    Joined:
    Feb 25, 2008
    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    it doesnt work for me =\ why?? it needs to be in a teleport or it can be in any item?
     
  10. Summ

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

    Joined:
    Oct 15, 2008
    Messages:
    4,130
    Likes Received:
    1,025
    Best Answers:
    2
    It can be any position.
     
  11. Ayhan589

    Ayhan589 Beko

    Joined:
    Jul 8, 2008
    Messages:
    46
    Likes Received:
    0
    Best Answers:
    0
    it doesnt work for me too. what can be problem? I started to use 9.6
     
  12. Eldin

    Eldin Eldin Projects Premium User

    Joined:
    Jun 12, 2008
    Messages:
    1,260
    Likes Received:
    503
    Best Answers:
    0
    Any tip for 0.2? :)

    Code (Text):
    1.  
    2. [11/02/2013 20:52:52] Lua Script Error: [GlobalEvent Interface]
    3. [11/02/2013 20:52:53] data/globalevents/scripts/talking.lua:onThink
    4. [11/02/2013 20:52:53] data/globalevents/scripts/talking.lua:10: attempt to call global 'getPlayersOnline' (a nil value)
    5. [11/02/2013 20:52:53] stack traceback:
    6. [11/02/2013 20:52:53]   [C]: in function 'getPlayersOnline'
    7. [11/02/2013 20:52:53]   data/globalevents/scripts/talking.lua:10: in function <data/globalevents/scripts/talking.lua:9>
    8. [11/02/2013 20:52:53] [Error - GlobalEvents::think] Failed to execute event: talkingSigns
    9.  
    Hmm, standing still in my mind right now.

    Kind Regards,
    Eldin.
     
  13. Ayhan589

    Ayhan589 Beko

    Joined:
    Jul 8, 2008
    Messages:
    46
    Likes Received:
    0
    Best Answers:
    0
    yeah, will be solve?
     
  14. Sir Islam

    Sir Islam Never Give Up

    Joined:
    Jun 6, 2008
    Messages:
    500
    Likes Received:
    116
    Best Answers:
    0
  15. kosyer

    kosyer Member

    Joined:
    Feb 15, 2009
    Messages:
    116
    Likes Received:
    0
    Best Answers:
    0
    Thank you! Works good!
     
  16. Cadyan

    Cadyan Member

    Joined:
    Mar 30, 2008
    Messages:
    751
    Likes Received:
    19
    Best Answers:
    0
    Eldin, for 0.2 Im sure you change getPlayersOnline to getOnlinePlayers
    Other than that, it doesnt work for me either. I cannot figoure out the problem.
     
  17. Pnurt

    Pnurt Member

    Joined:
    Apr 22, 2009
    Messages:
    205
    Likes Received:
    0
    Best Answers:
    0
    BUMP, need to get this working for 0.2 9.6
     
  18. Wolffy

    Wolffy Ot Custom Developer

    Joined:
    Mar 29, 2009
    Messages:
    268
    Likes Received:
    13
    Best Answers:
    0
    Its messing with my account manager how do I stop it!!!!!


    SOLVED BY MYSELF LOL MY DUMB MISTAKE FORGOT TO ADD A EXTRA END TO CLOSE FUNCTION!!!!!


    HAVE THIS ERROR


    [9/5/2013 7:58:42] [Error - GlobalEvents::think] Couldn't execute event:d
     
    Last edited: May 9, 2013
  19. froie

    froie Expert Mapper

    Joined:
    May 27, 2013
    Messages:
    182
    Likes Received:
    4
    Best Answers:
    0
    [03/06/2013 10:43:24] Lua Script Error: [GlobalEvent Interface]
    [03/06/2013 10:43:24] data/globalevents/scripts/talking.lua:eek:nThink
    [03/06/2013 10:43:24] data/globalevents/scripts/talking.lua:10: attempt to call global 'getPlayersOnline' (a nil value)
    [03/06/2013 10:43:24] stack traceback:
    [03/06/2013 10:43:24] [C]: in function 'getPlayersOnline'
    [03/06/2013 10:43:24] data/globalevents/scripts/talking.lua:10: in function <data/globalevents/scripts/talking.lua:9>
    [03/06/2013 10:43:25] [Error - GlobalEvents::think] Failed to execute event: talkingSigns

    thats what i am getting
     
  20. froie

    froie Expert Mapper

    Joined:
    May 27, 2013
    Messages:
    182
    Likes Received:
    4
    Best Answers:
    0
    i get this error can someone help please?

    [06/07/2013 18:35:38] Lua Script Error: [GlobalEvent Interface]
    [06/07/2013 18:35:38] data/globalevents/scripts/talksign.lua:eek:nThink
    [06/07/2013 18:35:38] data/globalevents/scripts/talksign.lua:10: attempt to call global 'getPlayersOnline' (a nil value)
    [06/07/2013 18:35:38] stack traceback:
    [06/07/2013 18:35:38] [C]: in function 'getPlayersOnline'
    [06/07/2013 18:35:38] data/globalevents/scripts/talksign.lua:10: in function <data/globalevents/scripts/talksign.lua:9>
    [06/07/2013 18:35:38] [Error - GlobalEvents::think] Failed to execute event: talksign
     

Share This Page

Loading...