Aller au contenu

Photo

String Manip


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

#1
Tiggers.no.tail

Tiggers.no.tail
  • Members
  • 41 messages
 I was browsing through the lexicon for some string manipulation functions. I'm wondering if there's an easy way that I can get the players first name and last name by looking for the first space in the string (assuming they dont put something like John Claude Van Dam). Is such a thing possible to do purely from a script?

#2
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
#include "x3_inc_string"

void main()
{
  object oPC= GetFirstPC();
  string sFullName = GetName(oPC);
  string sFirstName = StringParse(sFullName);
  string sLastName = StringRemoveParsed(sFullName,sFirstName);
}

#3
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages
The best way is with nwnx, using dragonsong's nwnx_letoscript or acaos' nwnx_funcs. Either can retrieve first and last individually. Past that, it's impossible to do with complete confidence, because you never know what characters the player has used in his name. I think there are a few sample attempts floating around the old bioboards - you might have a look with the omnibus. None of them will work correctly 100% of the time like the nwnx solutions, though.

[Edit]
I see LF beat me to the punch. the x3 include just looks for the space, which won't always work.

Funky

Modifié par FunkySwerve, 02 juillet 2011 - 06:37 .


#4
Tiggers.no.tail

Tiggers.no.tail
  • Members
  • 41 messages
Well as long as it works most the time.