diff --git a/recast.lua b/recast.lua index 9d35874..f5f6acb 100644 --- a/recast.lua +++ b/recast.lua @@ -47,7 +47,7 @@ local default_config = }; local recast_config = default_config; local SCHJP = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - +local logged = false; --------------------------------------------------------------------------------------------------- -- func: color_recast_entry -- desc: Colors a recast entry based on the time left to use it.. @@ -91,8 +91,12 @@ end -- desc: Event called when the addon is being loaded. ---------------------------------------------------------------------------------------------------- ashita.register_event('load', function() - -- Attempt to load the fps configuration.. - recast_config = ashita.settings.load_merged(_addon.path .. 'settings/settings.json', recast_config); + -- Attempt to load the configuration.. + local party = AshitaCore:GetDataManager():GetParty(); + if (party:GetMemberServerId(0) ~= false) then + logged = true; + recast_config = ashita.settings.load_merged(_addon.path .. 'settings/' .. party:GetMemberName(0) .. '.settings.json', recast_config); + end -- Create our font object.. local f = AshitaCore:GetFontManager():Create('__recast_addon'); @@ -117,7 +121,7 @@ ashita.register_event('unload', function() recast_config.font.position = { f:GetPositionX(), f:GetPositionY() }; -- Save the configuration.. - ashita.settings.save(_addon.path .. 'settings/settings.json', recast_config); + ashita.settings.save(_addon.path .. 'settings/' .. AshitaCore:GetDataManager():GetParty():GetMemberName(0) .. '.settings.json', recast_config); -- Unload our font object.. AshitaCore:GetFontManager():Delete('__recast_addon'); @@ -235,6 +239,18 @@ ashita.register_event('incoming_packet', function(id, size, data) end return false; end - + -- on login/logoff from atom0s @ https://forums.ashitaxi.com/viewtopic.php?f=17&t=240 + if (id == 0x000A) then + if (logged == false) then + logged = true; + recast_config = ashita.settings.load_merged(_addon.path .. 'settings/' .. struct.unpack('s', data, 0x84 + 1) .. '.settings.json', recast_config); + end + end + if (id == 0x000B) then + local flag = struct.unpack('b', data, 0x04 + 1); + if (flag) then + logged = false; + end + end return false; end); \ No newline at end of file