PDA

View Full Version : User.getCurrentyIdentity() and User.getIdentityLabel() not working... sometimes.



zuilin
October 19th, 2020, 07:40
In my code, I have:


local sSender;
local sSenderID;
if User.isHost() then
sSenderID = "";
sSender = "GM";
else
sSenderID = User.getCurrentIdentity();
Debug.console("Just after getCurrentIdentity: ", sSenderID);

sSender = User.getIdentityLabel();
Debug.console("Just after getIdentityLabel: ", sSender);
end


When the host executes this, sSenderID always ends up being "" and sSender always ends up as "GM". Excellent, the User.isHost() portion works flawlessly.

When I connect with a localhost copy of the client, sSenderID always ends up being the correct ID for the currently selected character in that copy of the localhost client and sSender ends up as that character's name. Perfect.

However, when a non-host, non-localhost client runs this code, sSenderID=User.getCurrentIdentity(); ends up with sSenderID == nil, and the sSender = User.getIdentityLabel(); line errors out with the error "...getIdentityLabel: Invalid argument".

1. Why is sSenderID = User.getCurrentIdentity(); returning nil when a client runs it?

2. Why is sSender = User.getIdentityLabel(); crapping out when a client runs it? (Yeah, I know, User.getCurrentIdentity() is returning nil so that must be it, but just in case it isn't....)

(btw: I have similar code in another place and it always works: )

local currentID;
currentID = User.getCurrentIdentity();


This really makes no sense why it works in one place and not another.

Thanks!

zuilin
October 19th, 2020, 16:40
As of this morning, without any code changes, it works. Literally, no code changes. I just sparked up all three copies, did my exact same test again, and now, no errors.

Go figure.