MrTrala

HealFriend By Trala

Aug 17th, 2016
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.88 KB | None | 0 0
  1. --[[
  2.     HealFriend for ArchlightOnline
  3.     By Mr Trala
  4.    
  5. Thanks to:
  6.  
  7. Colandus from Otland for the string.explode function.
  8.  
  9. Instructions;
  10.  
  11. Load the script, the instructions are in the Sio Channel.
  12.  
  13. Change Log;
  14.  
  15. 1.5.1 - First stable version.
  16. 1.5.2 - Fixed problem after Archlight HP/Mana Update.
  17. 1.5.3 - Reworked the Module for sio, the old one sometimes failed.
  18. 1.5.4 - Added the option 'Restart', you will reset the Module so you reset all your sios.
  19. ]]
  20.  
  21.  
  22.  
  23. -- You can keep adding permanent sios here, just keep adding +1 number like;
  24. -- friends[2] = {Friend = "Another Dude", HealAt = 2}
  25. friends = {}
  26. friends[1] = {SioT = "Admin Knighter", HealAt = 10}
  27.  
  28.  
  29.  
  30. -- Don't touch anything if you don't know what are you doing.
  31. function string.trim(str)
  32.     return (str:gsub("^%s*(.-)%s*$", "%1"))
  33. end
  34. version = '1.5.4F'
  35. function string.explode(str, sep, limit)
  36.     if limit and type(limit) ~= 'number' then
  37.         error("string.explode: limit must be a number", 2)
  38.     end
  39.  
  40.     if #sep == 0 or #str == 0 then return end
  41.     local pos, i, t = 1, 1, {}
  42.     for s, e in function() return str:find(sep, pos) end do
  43.         table.insert(t, str:sub(pos, s-1):trim())
  44.         pos = e + 1
  45.         i = i + 1
  46.         if limit and i == limit then break end
  47.     end
  48.     table.insert(t, str:sub(pos):trim())
  49.     return t
  50. end
  51.  
  52. function onSpeak(channel, msg)
  53.     if (msg == "start") or (msg == "Start") then
  54.         channel:SendYellowMessage('Mr Trala', 'HealFriend Script has started.')
  55.         Module.Start('HealF')
  56.        
  57.     elseif (msg == "stop") or (msg == "Stop")then
  58.         Module.Stop('HealF')
  59.         channel:SendRedMessage('Mr Trala', 'HealFriend Script has been stopped.')
  60.  
  61.     elseif (msg == "restart") or (msg == "Restart") or (msg == "reset") or (msg == "Reset") then
  62.         channel:SendRedMessage('Mr Trala', 'Resetting your Module, please wait...')
  63.         Module.Stop('HealF')
  64.         wait(1500)
  65.         friends = {}
  66.         channel:SendRedMessage('Mr Trala', 'HealFriend Script has been restarted.')
  67.         Module.Start('HealF')
  68.    
  69.     end
  70.    
  71.     if msg ~= "start" and msg ~= "stop" then
  72.     local p = string.explode(msg, ",")
  73.     local t = tonumber(p[2])
  74.     local num = t
  75.         if p[2] == '' or not string.find(msg, ",") then
  76.             channel:SendRedMessage('Mr Trala', 'Please specify the name of the player and in wich X% to heal him, as follow: "Mr Trala, 95".')
  77.            
  78.         elseif num > 99 or num == 0 then
  79.             channel:SendRedMessage('Mr Trala', 'You can only choose between 1-99 to heal someone.')
  80.            
  81.         else
  82.             friends[#friends+1] = {SioT = ''..p[1]..'', HealAt = p[2]}
  83.             channel:SendYellowMessage('Mr Trala', 'You have added the player: '..p[1]..' to heal at : '..p[2]..'% to the healing list.')
  84.         end
  85.     end        
  86. end
  87.  
  88. function onClose(channel)
  89.      print(channel:Name() .. ' has been closed.')
  90. end
  91.  
  92. local customChannel = Channel.New('Sio Channel', onSpeak, onClose)
  93.  
  94. customChannel:SendRedMessage('Mr Trala', 'Welcome to the HealFriend Script, configured specifically for ArchlightOnline.\n'..
  95.         'This Script has been made by Mr Trala, and you are using the Version '..version..'\n'..
  96.         'If you found any bug send a message to Mr Trala or Mr Trolo in Archlight.\n')
  97. customChannel:SendOrangeMessage('Instructions', '\n'..
  98.         'To start the script just write "start" or "stop" to stop healing everyone - IT IS ON BY DEFAULT.\n')
  99. customChannel:SendRedMessage('Mr Trala', 'Please specify the name of the player and in wich X% to heal him, as follow: "Mr Trala, 95".')
  100.  
  101.  
  102. function HealF()
  103.     for _, c in Creature.iPlayers() do
  104.         for i = 1, #friends do
  105. local f = friends[i]
  106. local num = tonumber(f.HealAt)
  107.             if c:Name() == f.SioT and c:HealthPercent() <= num and Self.GetSpellCooldown('exura sio') == 0 then
  108.                 Self.Say('exura sio "'..f.SioT)
  109.             end
  110.         end
  111.     end
  112. end
  113.  
  114. Module('HealF', HealF, true)
Add Comment
Please, Sign In to add comment