Aller au contenu

Photo

Unique ID String for PCs and NPCs


  • Veuillez vous connecter pour répondre
6 réponses à ce sujet

#1
henesua

henesua
  • Members
  • 3 883 messages
I've found a need to generate unique ID strings for NPCs and PCs. I posted it to Pastebin:

GetPCIdentifier(object oPC)

Feedback is welcome.

NOTES:
Uses of PC string should be obvious as that couplet is commonly used. Feel free to ask if this is a new concept to you. The NPC string however is a novel solution as far as I am aware. Feel free to let me know about "the first solution" if this is simply a reinvention of one.

Intentions of the NPC string:
  • Easily differentiate NPC from PC
  • Uniqueness across server resets
  • Enable finding the NPC by ID, extract TAG from ID, retrieve creatures by tag, then look for one that has same unique ID.
Hopefully this solves the typical problems of storing IDs of instantiated objects in a database. Anything I missed?

Modifié par henesua, 30 octobre 2012 - 02:57 .


#2
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
I a not at the house right now and the leicon was not uch hel ( and this keyoard is dying)  ut is not 
StringReplace a core NWN function 

#3
henesua

henesua
  • Members
  • 3 883 messages
No it isn't. I just checked. Perhaps it is in an include?

Anyway, what does it do? I'm not clear on how that relates to what I posted.

#4
meaglyn

meaglyn
  • Members
  • 817 messages
I think lightfoot8 is noticing that you seem to be doing a lot of string replaces by hand to put
in the fancy symbols. It's in x3_inc_string.

Out of curiosity, why does it matter if there are * or : or whatever in your returned ID? Those
are not any of the things you are using for delimiters. It shouldn't matter what characters are
in the name as long as they are not what you are using...

And as an aside, why are you using characters that are hard to print or type?

Cheers,

Meaglyn

#5
henesua

henesua
  • Members
  • 3 883 messages
Meaglyn, I have some other systems that are data intensive with long strings and lots of delimiters. When I inject the ID of a PC or NPC into it I want to ensure that I won't mess up my parsing of those long strings.

I'll check out x3_inc_string and see if I can do some of my string manipulation more efficiently. Thanks.

#6
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages

henesua wrote...

Meaglyn, I have some other systems that are data intensive with long strings and lots of delimiters. When I inject the ID of a PC or NPC into it I want to ensure that I won't mess up my parsing of those long strings.

I'll check out x3_inc_string and see if I can do some of my string manipulation more efficiently. Thanks.


Sorry for taking so long in getting back to this. ..


Since the function is not an internal one I would not worry to much about looking at the X3 version of it. 

....

The only thing in your script that raises a flag for me is line 22:
 
sPCID   = GetName(oPC)+"¤"+GetPCPlayerName(oPC);

The GetPCPlayerName function returns the name in the case that the player used to LogIn with. For exsample if I had an account Name of lightfoot8 I could use any case to log in with: Lightfoot8, LightFoot8, LIGHTfoot8, lightFOOT8; would all be valid way to log into the same account with the MS being down. If you need to even worry about this here is dependent on how you have handled the same problem in your custom security. If you have not handled it in your custom security. you may want to look here for a possiable way to handle it.

EDIT: Read down a few posts in the link to the get the full picture.

Modifié par Lightfoot8, 04 novembre 2012 - 06:27 .


#7
henesua

henesua
  • Members
  • 3 883 messages
interesting... I did not think about that. I'll look at how I handle case in my custom security, thanks.