Advertisement
horato

Buff

Dec 5th, 2012
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. allowed = false
  2. buffy = false
  3. iss = ""
  4. IDbuff = {11517,11518,11519,11520,11521,11522}
  5. IDsonata = {11529,11530,11532}
  6. harmony = ""
  7. timer = 20
  8.  
  9. function OnCreate()
  10.     this:RegisterCommand("buffer", CommandChatType.CHAT_ALLY, CommandAccessLevel.ACCESS_ME)
  11.     this:RegisterCommand("iss", CommandChatType.CHAT_ALLY, CommandAccessLevel.ACCESS_ME)
  12. end;
  13.  
  14. function OnCommand_buffer(vCommandChatType, vNick, vCommandParam)
  15.     if ( allowed == false ) then
  16.         allowed = true;
  17.         ShowToClient("buffer", "ON");
  18.     else
  19.         allowed = false;
  20.         ShowToClient("buffer", "OFF");
  21.     end;
  22. end;
  23.  
  24. function OnCommand_iss(vCommandChatType, vNick, vCommandParam)
  25.     if ( vCommandParam:GetCount() ~= 1 ) then
  26.         ShowToClient("iss", "Bad input. Usage: //iss_[\"off\"|nickname]");
  27.         return;
  28.     end;
  29.     local parameter = tostring(vCommandParam:GetParam(0):GetStr(true));
  30.     if parameter == "off" then
  31.         buffy = false;
  32.         ShowToClient("iss", "OFF");
  33.         return;
  34.     end;
  35.    
  36.     buffy = true;
  37.     harmony = ""
  38.     iss = parameter;
  39.     ShowToClient("iss", "ON: Buff requests will be sent to "..iss..".");
  40. end;
  41.  
  42. function OnLTick1s()
  43.     if(buffy == false) then
  44.         return;
  45.     end;
  46.     timer = timer-1;
  47.     if(timer > 0) then
  48.         return;
  49.     end;
  50.    
  51.     timer = 20;
  52.     local count = GetMe():GetBuffsCount();
  53.     local needRebuff = false;
  54.     local needSonatas = false;
  55.    
  56.     for i=0,count-1,1 do
  57.         local buff = GetMe():GetBuffByIdx(i);
  58.         if(buff.endTime-GetTime() < 30000) then
  59.             if(inTable(IDbuff,buff.skillId)) then
  60.                 needRebuff = true
  61.             elseif(inTable(IDsonata,buff.skillId)) then
  62.                 needSonatas = true
  63.             end;
  64.             if(buff.skillId == 11523) then
  65.                 harmony = "knight"
  66.             elseif(buff.skillId == 11524) then
  67.                 harmony = "warrior"
  68.             elseif(buff.skillId == 11525) then
  69.                 harmony = "wizard"
  70.             end;
  71.         end;
  72.     end;
  73.  
  74.     issUser = nil
  75.     for user in GetPlayerList().list do
  76.         if(user:GetName():lower() == iss:lower()) then
  77.             issUser = user;
  78.         end;
  79.     end;
  80.  
  81.     if(issUser == nil) then
  82.         return;
  83.     end;
  84.     if(issUser:IsMyPartyMember()) then
  85.         return;
  86.     end;
  87.    
  88.     if(needRebuff == true) then
  89.         Command("/invite "..iss);
  90.         Sleep(5000);
  91.         SendPM(iss, ""..harmony);
  92.         SendPM(iss, "fullleave");
  93.     elseif(needSonatas == true) then
  94.         Command("/invite "..iss);
  95.         Sleep(5000);
  96.         SendPM(iss, ""..harmony);
  97.         SendPM(iss, "danceleave");
  98.     end;
  99. end;
  100.  
  101.  
  102. function OnChatSystemMessage(id, msg)
  103.     if ( allowed == true ) then
  104.         if(isStartingWith(msg,"You have acquired")) then
  105.             members = GetPartyList();
  106.             for player in members.list do
  107.                 if(player:GetHp() < 2) then
  108.                     Command("/target "..player:GetName());
  109.                     Sleep(1000);
  110.                     Command("/useskill angel's resurrection");
  111.                     Sleep(1000);
  112.                     ClearTargets();
  113.                 end;
  114.             end;
  115.         end;
  116.     end;   
  117. end;
  118.  
  119. function OnChatUserMessage(chatType, nick, msg)
  120.     if ( allowed == true ) then
  121.         local caller = GetUserByName(nick);
  122.         local Message = string.lower(msg); -- Converts message to lower case letters.
  123.         Message = Message:gsub("^%s*(.-)%s*$", "%1"); -- Trimming message of spaces on start.
  124.         if (chatType == L2ChatType.CHAT_TELL) then
  125.             if (Message == "summon mentor" or Message == "mentor summon") then
  126.                 Command("/useskill Mentee's Mentor Summon" .. nick);
  127.             end;
  128.             if (Message == "invite") then
  129.                 Command("/invite " .. nick);
  130.             end;
  131.             if (Message == "heal") then
  132.                 Command("/target " .. nick);
  133.                 Sleep (1000);
  134.                 Command("/useskill healing melody");
  135.             end;
  136.             if (Message == "fullleave" and caller:IsMyPartyMember()) then
  137.                 Sleep (1000);
  138.                 Command("/useskill pipe organ melody");
  139.                 Sleep (1000);
  140.                 Command("/useskill drum melody");
  141.                 Sleep (1000);
  142.                 Command("/useskill guitar melody");
  143.                 Sleep (1000);
  144.                 Command("/useskill lute melody");
  145.                 Sleep (1000);
  146.                 Command("/useskill horn melody");
  147.                 Sleep (1000);
  148.                 Command("/useskill harp melody");
  149.                 Sleep (1000);
  150.                 --Command("/useskill divine protection");
  151.                 --Sleep (1000);
  152.                 --Command("/useskill elemental protection");
  153.                 Command("/useshortcut 4 7");
  154.                 Sleep (1000);
  155.                 Command("/useshortcut 4 8");
  156.                 Sleep (1000);
  157.                 Command("/useshortcut 4 9");
  158.                 --Command("/useskill mental protection");
  159.                 Sleep (1000);
  160.                 Command("/useskill refreshing sonata");
  161.                 Sleep (1000);
  162.                 Command("/useskill prevailing sonata");
  163.                 Sleep (1000);
  164.                 Command("/useskill daring sonata");
  165.                 Sleep (1000);
  166.                 Command("/leave");
  167.             end;
  168.             if (Message == "knight" and caller:IsMyPartyMember()) then
  169.                 Command("/target " .. nick);
  170.                 Sleep (1000);
  171.                 Command("/useskill knight's harmony");
  172.                 Sleep (1000);
  173.                 Command("/leave");
  174.             end;
  175.             if (Message == "warrior" and caller:IsMyPartyMember()) then
  176.                 Command("/target " .. nick);
  177.                 Sleep (1000);
  178.                 Command("/useskill warrior's harmony");
  179.                 Sleep (1000);
  180.                 Command("/leave");
  181.             end;
  182.             if (Message == "wizard" and caller:IsMyPartyMember()) then
  183.                 Command("/target " .. nick);
  184.                 Sleep (1000);
  185.                 Command("/useskill wizard's harmony");
  186.                 Sleep (1000);
  187.                 Command("/leave");
  188.             end;
  189.             if(Message == "danceleave" and caller:IsMyPartyMember()) then
  190.                 Sleep (1000);
  191.                 Command("/useskill refreshing sonata");
  192.                 Sleep (1000);
  193.                 Command("/useskill prevailing sonata");
  194.                 Sleep (1000);
  195.                 Command("/useskill daring sonata");
  196.                 Sleep (1000);
  197.                 Command("/leave");
  198.             end;
  199.         end;
  200.         if (chatType == L2ChatType.CHAT_PARTY) then
  201.             if ((Message == "full") or (Message == "fullbuff") or (Message == "buffs") or (Message == "buffy") or (Message == "buff") or (Message == "melody") or (Message == "fullleave")) and (GetPartyMaster():GetName() == nick) then
  202.                 Sleep (1000);
  203.                 Command("/useskill pipe organ melody");
  204.                 Sleep (1000);
  205.                 Command("/useskill drum melody");
  206.                 Sleep (1000);
  207.                 Command("/useskill guitar melody");
  208.                 Sleep (1000);
  209.                 Command("/useskill lute melody");
  210.                 Sleep (1000);
  211.                 Command("/useskill horn melody");
  212.                 Sleep (1000);
  213.                 Command("/useskill harp melody");
  214.                 Sleep (1000);
  215.                 --Command("/useskill divine protection");
  216.                 --Sleep (1000);
  217.                 --Command("/useskill elemental protection");
  218.                 Command("/useshortcut 4 7");
  219.                 Sleep (1000);
  220.                 Command("/useshortcut 4 8");
  221.                 Sleep (1000);
  222.                 Command("/useshortcut 4 9");
  223.                 --Command("/useskill mental protection");
  224.                 Sleep (1000);
  225.                 Command("/useskill refreshing sonata");
  226.                 Sleep (1000);
  227.                 Command("/useskill prevailing sonata");
  228.                 Sleep (1000);
  229.                 Command("/useskill daring sonata");
  230.                 Sleep (1000);
  231.                 if(Message == "fullleave") then
  232.                     Command("/leave");
  233.                 end;
  234.             end;
  235.             if (Message == "knight" or Message == "knightleave") then
  236.                 Command("/target " .. nick);
  237.                 Sleep (1000);
  238.                 Command("/useskill knight's harmony");
  239.                 Sleep (1000);
  240.                 if(Message == "knightleave") then
  241.                     Command("/leave");
  242.                 end;
  243.             end;
  244.             if (Message == "warrior" or Message == "warriorleave") then
  245.                 Command("/target " .. nick);
  246.                 Sleep (1000);
  247.                 Command("/useskill warrior's harmony");
  248.                 Sleep (1000);
  249.                 if(Message == "warriorleave") then
  250.                     Command("/leave");
  251.                 end;
  252.             end;
  253.             if (Message == "wizard" or Message == "wizardleave") then
  254.                 Command("/target " .. nick);
  255.                 Sleep (1000);
  256.                 Command("/useskill wizard's harmony");
  257.                 Sleep (1000);
  258.                 if(Message == "wizardleave") then
  259.                     Command("/leave");
  260.                 end;
  261.             end;
  262.             if(Message == "sonaty") or (Message == "sonata") or (Message == "sonatas") or (Message == "dance") or (Message == "dancy") or (Message == "dances") or (Message == "danceleave") then
  263.                 Sleep (1000);
  264.                 Command("/useskill refreshing sonata");
  265.                 Sleep (1000);
  266.                 Command("/useskill prevailing sonata");
  267.                 Sleep (1000);
  268.                 Command("/useskill daring sonata");
  269.                 Sleep (1000);
  270.                 if(Message == "danceleave") then
  271.                     Command("/leave");
  272.                 end;
  273.             end;
  274.             if (Message == "res") then
  275.                 Command("/target " .. nick);
  276.                 Sleep (1000);
  277.                 Command("/useskill angel's resurrection");
  278.             end;
  279.             if (Message == "heal") then
  280.                 Command("/target " .. nick);
  281.                 Sleep (1000);
  282.                 Command("/useskill healing melody");
  283.             end;
  284.             if (Message == "cpheal") then
  285.                 Command("/target " .. nick);
  286.                 Sleep (1000);
  287.                 Command("/useskill recovery melody");
  288.             end;
  289.             if (Message == "followme") then
  290.                 Command("/target " .. nick);
  291.                 Sleep (100);
  292.                 Command("/target " .. nick);
  293.             end;
  294.             --and (GetPartyMaster():GetName() == nick)
  295.             if (Message == "debuff") then
  296.                 Sleep (1000);
  297.                 Command("/useshortcut 2 6");
  298.                 Sleep (1000);
  299.                 Command("/useshortcut 2 7");
  300.             end;
  301.             if (Message == "shadow") then
  302.                 Sleep (1000);
  303.                 Command("/useskill devil's movement");
  304.             end;
  305.     --      give xxx to yyy
  306.             if (isStartingWith(Message,"give")) then
  307.     --      split(Message, " ");
  308.                 local array = split(Message, " ");
  309.                 if (array[1] == "knight") then
  310.                     Command("/target " .. array[4]);
  311.                     Sleep (1000);
  312.                     Command("/useskill knight's harmony");
  313.                 end;
  314.                 if (array[1] == "warrior") then
  315.                     Command("/target " .. array[4]);
  316.                     Sleep (1000);
  317.                     Command("/useskill warrior's harmony");
  318.                 end;
  319.                 if (array[1] == "wizard") then
  320.                     Command("/target " .. array[4]);
  321.                     Sleep (1000);
  322.                     Command("/useskill wizard's harmony");
  323.                 end;
  324.                 if (array[1] == "res") then
  325.                     Command("/target " .. array[4]);
  326.                     Sleep (1000);
  327.                     Command("/useskill angel's resurrection");
  328.                 end;
  329.                 if (array[1] == "heal") then
  330.                     Command("/target " .. array[4]);
  331.                     Sleep (1000);
  332.                     Command("/useskill healing melody");
  333.                 end;
  334.                 if (array[1] == "cpheal") then
  335.                     Command("/target " .. array[4]);
  336.                     Sleep (1000);
  337.                     Command("/useskill recovery melody");
  338.                 end;
  339.             end;
  340.            
  341. --          jebat to
  342. --          if (Message == "cpheal full") then
  343. --              if(GetMe():GetMpPercent() < 40) then
  344. --                  Say2(L2ChatType.CHAT_PARTY,"no mp","");
  345. --              else
  346. --                  Command("/target " .. nick);
  347. --                  while(GetTarget():GetCpPercent() < 95) do
  348. --                      Sleep (1000);
  349.                         --ShowToClient("cpheal"," "..GetTarget():GetCpPercent());
  350. --                      Command("/useskill recovery melody");
  351. --                  end;
  352. --              end;
  353. --          end;
  354.         end;
  355.     end;
  356. end;
  357.  
  358. function inTable(tbl, item)
  359.     for key, value in pairs(tbl) do
  360.         if value == item then return true end
  361.     end
  362.     return false
  363. end
  364.  
  365. function isStartingWith(String,Start)
  366.    return string.sub(String,1,string.len(Start))==Start
  367. end;
  368.  
  369. function string.ends(String,End)
  370.    return End=='' or string.sub(String,-string.len(End))==End
  371. end;
  372.  
  373. function split(str, c)
  374. a = string.find(str, c)
  375. str = string.gsub(str, c, "", 1)
  376. aCount = 0
  377. start = 1
  378. array = {}
  379. last = 0
  380.    
  381.     while a do
  382.     array[aCount] = string.sub(str, start, a - 1)
  383.     start = a
  384.     a = string.find(str, c)
  385.    
  386.     str = string.gsub(str, c, "", 1)
  387.     aCount = aCount + 1
  388.     end
  389.    
  390. return array
  391. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement