Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require('functions')
- function find_usable_item(item_id)
- local items = windower.ffxi.get_items()
- local inventory_index,bag_id
- for i,v in pairs(items.temporary) do
- if v and v.id == item_id then
- inventory_index = i
- bag_id = 3
- break
- end
- end
- -- Should I add some kind of filter for enchanted items?
- if not inventory_index then
- for i,v in pairs(items.inventory) do
- if v and v.id == item_id then
- inventory_index = i
- bag_id = 0
- break
- end
- end
- end
- if not inventory_index then
- for i,v in pairs(items.wardrobe) do
- if v and v.id == item_id then
- inventory_index = i
- bag_id = 8
- break
- end
- end
- end
- return inventory_index,bag_id
- end
- function assemble_menu_item_packet(target_id,target_index,item_id)
- local outstr = string.char(0x36,0x20,0,0)
- -- Target ID
- outstr = outstr..string.char( (target_id%256), math.floor(target_id/256)%256, math.floor( (target_id/65536)%256) , math.floor( (target_id/16777216)%256) )
- -- One unit traded
- outstr = outstr..string.char(1,0,0,0,0,0,0,0)..string.char(0,0,0,0,0,0,0,0)..string.char(0,0,0,0,0,0,0,0)..
- string.char(0,0,0,0,0,0,0,0)..string.char(0,0,0,0,0,0,0,0)
- -- Inventory Index for the one unit
- inventory_index,bag_id = find_usable_item(item_id)
- if inventory_index then
- outstr = outstr..string.char(inventory_index%256)
- else
- --debug_mode_chat('Proposed item: '..(res.items[item_id][language] or item_id)..' not found in inventory.')
- return
- end
- -- Nothing else being traded
- outstr = outstr..string.char(0,0,0,0,0,0,0,0,0)
- -- Target Index
- outstr = outstr..string.char( (target_index%256), math.floor(target_index/256)%256)
- -- Only one item being traded
- outstr = outstr..string.char(1,0,0,0)
- return outstr
- end
- -- _addon.commands = {'keyboxes'}
- -- _global = {
- -- frames = 0
- -- }
- -- windower.register_event('prerender',function()
- -- if (_global.frames % 5000 == 0) then
- -- local mob_array = windower.ffxi.get_mob_array()
- -- for str_index,mob_table in pairs(mob_array) do
- -- if mob_table.models[1] == 965 and mob_table.valid_target and mob_table.distance <= 50 and mob_table.name == 'Sturdy Pyxis' then
- -- windower.send_command('input /echo found a box')
- -- local textvar = assemble_menu_item_packet(mob_table.id,mob_table.index,2490)
- -- windower.packets.inject_outgoing(0x36,textvar)
- -- coroutine.sleep(5000)
- -- end
- -- end
- -- end
- -- end)
- function runstuff()
- local mob_array = windower.ffxi.get_mob_array()
- for str_index,mob_table in pairs(mob_array) do
- if mob_table.models[1] == 965 and mob_table.valid_target and mob_table.distance <= 50 and mob_table.name == 'Sturdy Pyxis' then
- --windower.send_command('input /echo found a box')
- local textvar = assemble_menu_item_packet(mob_table.id,mob_table.index,2490)
- windower.packets.inject_outgoing(0x36,textvar)
- end
- end
- end
- runstuff:loop(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement