Advertisement
Guest User

Untitled

a guest
Jul 24th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.12 KB | None | 0 0
  1. --[[---------------------------------------------------------------------------
  2. Copyright (c) 2014, Timothy Bushey aka 'Matix'
  3. All rights reserved.
  4.  
  5. Redistribution and use in source and binary forms, with or without
  6. modification, are permitted provided that the following conditions are met:
  7.  
  8.     * Redistributions of source code must retain the above copyright
  9.       notice, this list of conditions and the following disclaimer.
  10.     * Redistributions in binary form must reproduce the above copyright
  11.       notice, this list of conditions and the following disclaimer in the
  12.       documentation and/or other materials provided with the distribution.
  13.     * Neither the name of Shotix nor the
  14.       names of its contributors may be used to endorse or promote products
  15.       derived from this software without specific prior written permission.
  16.  
  17. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  18. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. DISCLAIMED. IN NO EVENT SHALL MATIX BE LIABLE FOR ANY
  21. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. ---------------------------------------------------------------------------]]--
  28. _addon.author   = 'Matix';
  29. _addon.name     = 'jchange';
  30. _addon.version  = '0.1';
  31. require 'common';
  32. local jc_job_enum = {
  33.     ['WAR'] = 1,
  34.     ['MNK'] = 2,
  35.     ['WHM'] = 3,
  36.     ['BLM'] = 4,
  37.     ['RDM'] = 5,
  38.     ['THF'] = 6,
  39.     ['PLD'] = 7,
  40.     ['DRK'] = 8,
  41.     ['BST'] = 9,
  42.     ['BRD'] = 10,
  43.     ['RNG'] = 11,
  44.     ['SAM'] = 12,
  45.     ['NIN'] = 13,
  46.     ['DRG'] = 14,
  47.     ['SMN'] = 15,
  48.     ['BLU'] = 16,
  49.     ['COR'] = 17,
  50.     ['PUP'] = 18,
  51.     ['DNC'] = 19,
  52.     ['SCH'] = 20,
  53.     ['GEO'] = 21,
  54.     ['RUN'] = 22,
  55. }
  56. local function push_mjob_packet( job_id )  
  57.     local packet = { 0x100, 0x05, 0x00, 0x00, string.format('0x%X',job_id), 0x00, 0x00, 0x00 };
  58.     AddOutgoingPacket( packet, 0x100, 8 );
  59. end
  60. local function push_sjob_packet( job_id )  
  61.     local packet = { 0x100, 0x05, 0x00, 0x00, 0x00, string.format('0x%X',job_id), 0x00, 0x00 };
  62.     AddOutgoingPacket( packet, 0x100, 8 );
  63. end
  64. local function gen_job_packet(jobtype, jobname)
  65.     local valid_job = false;
  66.     for k,v in pairs(jc_job_enum) do
  67.         if (k == string.upper(jobname)) then
  68.             valid_job = true;
  69.         end
  70.     end
  71.     if (valid_job == false) then
  72.         return false;
  73.     end
  74.     if (jobtype == 1) then
  75.         push_mjob_packet( jc_job_enum[string.upper(jobname)] )
  76.     elseif (jobtype == 2) then
  77.         push_sjob_packet( jc_job_enum[string.upper(jobname)] )
  78.     end
  79. end
  80. ashita.register_event('command', function(cmd, nType)
  81.     local args = cmd:GetArgs();
  82.     if (args[1] == '/mjob') and (args[2]) then
  83.         gen_job_packet(1, args[2]);
  84.     elseif (args[1] == '/sjob') and (args[2]) then
  85.         gen_job_packet(2, args[2]);
  86.     end
  87. end );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement