Evaluating a String

Post » Wed Jun 29, 2011 6:55 pm

I was wondering if anyone could remind me how to check the PC's Name for certain letters/words? I know it is possible, as I have done it at least once before, but cannot for the life of remember how-- the one I am looking for is where it contains any occurence of the letters, regardless of position or if other words are connected.

I think the code is as follows, but am about 80% sure it is wrong:
   Set [StringVal] to ( Player.GetActorFullName )  If ( Eval_SV "[String]" == 0 )     ;Do Whatever  EndIf


Thanks in advance :)
User avatar
jenny goodwin
 
Posts: 3461
Joined: Wed Sep 13, 2006 4:57 am

Post » Thu Jun 30, 2011 5:44 am

Let StringVar to Player.GetNameIf  eval sv_find  "[String]" StringVar  == 0       ;Do Whatever EndIf

User avatar
Leanne Molloy
 
Posts: 3342
Joined: Sat Sep 02, 2006 1:09 am

Post » Thu Jun 30, 2011 5:53 am

Let StringVar to Player.GetNameIf  eval sv_find  "[String]" StringVar  == 0       ;Do Whatever EndIf


But note that this will only succeed if the player name starts with "[String]". If you want it to succeed if "[String]" is anywhere in the name, you must change "==0" to ">=0", as the return value is the position "[String]" is found (starting the count at zero).

...and change from "Let StringVar to Player.GetName" to "Let StringVar := Player.GetName"
User avatar
Stu Clarke
 
Posts: 3326
Joined: Fri Jun 22, 2007 1:45 pm

Post » Wed Jun 29, 2011 11:20 pm

Thanks guys :) I'll check it in a bit and confirm-- but I'll bet it is right ;)
User avatar
Flash
 
Posts: 3541
Joined: Fri Oct 13, 2006 3:24 pm


Return to IV - Oblivion