Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.29 KB | None | 0 0
  1. --*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  2. -- Received information
  3. --*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  4.  
  5. local function incomingInformationTypeSent(structure, senderID)
  6.     local informationType = structure[1];
  7.     local data = structure[2];
  8.  
  9.     if not CURRENT_QUERY_EXCHANGES[senderID] or not CURRENT_QUERY_EXCHANGES[senderID][informationType] then
  10.         return; -- We didn't ask for theses information ...
  11.     end
  12.  
  13.     log(("Received %s's %s info !"):format(senderID, informationType));
  14.     CURRENT_QUERY_EXCHANGES[senderID][informationType] = nil;
  15.  
  16.     local decodedData = data;
  17.     -- If the data is a string, we assume that it was compressed.
  18.     if type(data) == "string" then
  19.         decodedData = Utils.serial.safeDecompressCodedStructure(decodedData, {});
  20.     end
  21.  
  22.     if informationType == registerInfoTypes.CHARACTERISTICS or informationType == registerInfoTypes.ABOUT
  23.     or informationType == registerInfoTypes.MISC or informationType == registerInfoTypes.CHARACTER then
  24.         saveInformation(senderID, informationType, decodedData);
  25.     elseif informationType:sub(1, COMPANION_PREFIX:len()) == COMPANION_PREFIX then
  26.         local v = informationType:sub(COMPANION_PREFIX:len() + 1, COMPANION_PREFIX:len() + 1);
  27.         local profileID = informationType:sub(COMPANION_PREFIX:len() + 2);
  28.         saveCompanionInformation(profileID, v, data)
  29.     end
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement