From 1faddc2012781ae249638a3df3a2ca95413c16b5 Mon Sep 17 00:00:00 2001 From: matix Date: Fri, 7 Dec 2018 02:36:06 -0800 Subject: [PATCH] added login/player name detection --- recast.lua | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/recast.lua b/recast.lua index f4c6acc..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/' .. AshitaCore:GetDataManager():GetParty():GetMemberName(0) .. '.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'); @@ -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