Premise: UnitExists() returns nil if you are logged out or if the character really doesn't exist.
If this is true, why not just use it to query the "existence" of the team member before you ever send them a message? I know this might not alert you to the case where you typo'd the name, but I think you'd notice that pretty quick when it wasn't working with one of your clients. The result would be quite a bit more elegant I think, it could probably be handled with something like:
...and just use this whenever you want to send to another character.Code:function AJM:SendMsgToChar( characterName ) if(UnitExists(characterName)) then -- do whatever to send the message end; end
I tend to prefer these types of "stateless" approaches since they aren't prone to failure if, for some reason, your list of active characters gets out of sync (which, as a programmer, I can tell you they definitely will at some point).
Connect With Us