GlobalEvent Effect for tutors!

Discussion in 'GlobalEvents, Spells & CreatureEvents' started by ghettobird, Aug 21, 2013.

  1. ghettobird

    ghettobird LUA newbie

    Joined:
    Aug 17, 2013
    Messages:
    679
    Likes Received:
    130
    Best Answers:
    0
    you can edit it if you want, i just saw it in highexp so i thought it would be nice if i share it with everyone, i'm not sure if it will work i didn't have time to test it so, just post errors if there are any !

    Code (Lua):
    1. function onThink(interval, lastExecution)
    2.          for _, name in ipairs(getOnlinePlayers()) do
    3.          local cid = getPlayerByName(name)
    4.                if getPlayerGroupId(cid) ==3 then
    5.                   doSendMagicEffect(getPlayerPosition(cid), 27)
    6.                   doSendAnimatedText(getPlayerPosition(cid), "HELPER", TEXTCOLOR_RED)
    7.                end
    8.          end
    9.          return true
    10. end
    11.    
    please go easy on me I'm still a beginner I'm just trying to be helpful here, also to examine myself in what i've learned/read
     
    Last edited: Aug 23, 2013
    Jikoe II likes this.
  2. megazx

    megazx Creative Mapper

    Joined:
    Mar 4, 2013
    Messages:
    415
    Likes Received:
    30
    Best Answers:
    1
    good work but i think u are missing end after return true
     
  3. ghettobird

    ghettobird LUA newbie

    Joined:
    Aug 17, 2013
    Messages:
    679
    Likes Received:
    130
    Best Answers:
    0
    did you test it btw?
     
  4. Teckman

    Teckman Active Member

    Joined:
    Jul 5, 2008
    Messages:
    918
    Likes Received:
    150
    Best Answers:
    0
    No need to loop through names. Fixed version:

    Code (Lua):
    1. function onThink(interval, lastExecution)
    2.     for k, v in pairs(getPlayersOnline()) do
    3.         if(getPlayerGroupId(v) == 3) then
    4.             doSendMagicEffect(getPlayerPosition(v), CONST_ME_GIFT_WRAPS)
    5.             doSendAnimatedText(getPlayerPosition(v), "Tutor", TEXTCOLOR_RED)
    6.         end
    7.     end
    8.     return true
    9. end
     
  5. tetra20

    tetra20 DD

    Joined:
    Jan 17, 2009
    Messages:
    1,287
    Likes Received:
    275
    Best Answers:
    2
    yup.mega is right you are missing a end(you ended *if*.but you didn't end the function)
     
  6. Flatlander

    Flatlander Species Developer

    Joined:
    Feb 17, 2009
    Messages:
    2,298
    Likes Received:
    1,111
    Best Answers:
    1
    First of all, This script would not load because you are missing 2 ends.

    Secondly, you did not need to use the "getPlayerByName(name)" function.

    Here is your script fixed with notes:
    Code (Lua):
    1.  
    2. function onThink(interval, lastExecution)
    3.     for _, pid in ipairs(getOnlinePlayers()) do -- Changed name to pid (You don't have to, but it's just how I do things)
    4.         -- local cid = getPlayerByName(name) Deleted this line because it is not needed
    5.         if getPlayerGroupId(pid) == 3 then
    6.             doSendMagicEffect(getPlayerPosition(pid), 27)
    7.             doSendAnimatedText(getPlayerPosition(pid), "HELPER", TEXTCOLOR_RED)
    8.         end
    9.     end
    10.     return true
    11. end
    12.  
     
  7. tetra20

    tetra20 DD

    Joined:
    Jan 17, 2009
    Messages:
    1,287
    Likes Received:
    275
    Best Answers:
    2
    Btw you can just make Offical Ghetto Scripts :) and keep on posting there
     
  8. ghettobird

    ghettobird LUA newbie

    Joined:
    Aug 17, 2013
    Messages:
    679
    Likes Received:
    130
    Best Answers:
    0
    i download uniserv today, i fixed this script, NOW IT WORKS 100%!

    Code (Lua):
    1. function onThink(interval, lastExecution)
    2.          for _, name in ipairs(getOnlinePlayers()) do
    3.          local cid = getPlayerByName(name)
    4.                if getPlayerGroupId(cid) ==3 then
    5.                   doSendMagicEffect(getPlayerPosition(cid), 27)
    6.                   doSendAnimatedText(getPlayerPosition(cid), "HELPER", TEXTCOLOR_RED)
    7.                end
    8.          end
    9.          return true
    10. end
     
  9. Flatlander

    Flatlander Species Developer

    Joined:
    Feb 17, 2009
    Messages:
    2,298
    Likes Received:
    1,111
    Best Answers:
    1
    @Teckman
    You beat me to it!

    @ghettobird
    You still have that getPlayerByName(name)!
    Also you may want to note that this script only works correctly for clients below 9.2 I think (doSendAnimatedText is disabled in newer clients)
     
  10. ghettobird

    ghettobird LUA newbie

    Joined:
    Aug 17, 2013
    Messages:
    679
    Likes Received:
    130
    Best Answers:
    0
    i never worked with clients more than 8.7 ^_^
     
  11. Teckman

    Teckman Active Member

    Joined:
    Jul 5, 2008
    Messages:
    918
    Likes Received:
    150
    Best Answers:
    0
    Fast like a lightning. :ninja:
     
  12. megazx

    megazx Creative Mapper

    Joined:
    Mar 4, 2013
    Messages:
    415
    Likes Received:
    30
    Best Answers:
    1
  13. ghettobird

    ghettobird LUA newbie

    Joined:
    Aug 17, 2013
    Messages:
    679
    Likes Received:
    130
    Best Answers:
    0
    yeah if anyone can help you with that script, it's the teckman ;)
     
  14. Teckman

    Teckman Active Member

    Joined:
    Jul 5, 2008
    Messages:
    918
    Likes Received:
    150
    Best Answers:
    0
    Codinablack likes this.
  15. This Is War

    This Is War Member

    Joined:
    Aug 22, 2013
    Messages:
    124
    Likes Received:
    11
    Best Answers:
    0
    Will test this soon :)
     
  16. Jikoe II

    Jikoe II New Member

    Joined:
    Feb 7, 2009
    Messages:
    174
    Likes Received:
    9
    Best Answers:
    0
    its a great idea! but its now all the time spamming helper, in my opinion its better to let the tutors chose when they have it on or off with a talkaction :)

    it would be nice if you did this for "most powerfull guild" that it says like "Leading Guild" all the time at the players that is in the guild with the most frags
     
  17. This Is War

    This Is War Member

    Joined:
    Aug 22, 2013
    Messages:
    124
    Likes Received:
    11
    Best Answers:
    0
  18. ghettobird

    ghettobird LUA newbie

    Joined:
    Aug 17, 2013
    Messages:
    679
    Likes Received:
    130
    Best Answers:
    0
    you can choose the time, once every 2.5 seconds or once every 5 seconds, etc... :p
     
  19. Jikoe II

    Jikoe II New Member

    Joined:
    Feb 7, 2009
    Messages:
    174
    Likes Received:
    9
    Best Answers:
    0
    it would be nice if you did this for "most powerfull guild" that it says like "Leading Guild" all the time at the players that is in the guild with the most frags
     
  20. ghettobird

    ghettobird LUA newbie

    Joined:
    Aug 17, 2013
    Messages:
    679
    Likes Received:
    130
    Best Answers:
    0
    you mean highest frags? i mean guilds that has highest frags?
     

Share This Page

Loading...