Jump to content

Player character name condition check - is it possible?


Recommended Posts

There isn't a condition function to check for the player's actual name.

 

I believe an alternative is to check for the PlayerKeyword via HasKeyword. The player is the ONLY reference that will have that keyword. If you really require name checking, I'm afraid SKSE is all there is for it.

Edited by Rasikko
Link to comment
Share on other sites

I see.

 

Wish there was any better way to make things check if player character is this particular player character, or just random player character.

 

My goal is to make it possible for NPC to "recognize" a player character as specific character and I was thinking, the name would be the best way doable (since there is no way to take into account player character's appearance or anything). Another way to do it, I guess, would be to make a pop-up menu appear asking "Are you this person?" or something like that, store it to variable and use on condition, but I would want to avoid that, because it would not be subtle enough.

My goal was to use player character's name as a "password" of sorts, so that if player character would bear a specific name, NPC would recognize him and dialogue would be different than usual.

Link to comment
Share on other sites

An alternative that might give you a bit more freedom in usage:

Using SKSE have a quest with an alias pointing to the player. Assign a script to this alias. Register for the chargen menu and / or tween menu. Using the OnMenuClose event check the player's name. If the correct name, assign a global variable to a specific value. Otherwise give that global variable a value of zero. Then you can use the global variable in any condition statement whether it be an IF block of a script or a condition block for such things as dialog, spells, etc..

 

Sample script

 

 

Scriptname SomePlayerAliasScript Extends ReferenceAlias
 
GlobalVariable Property myGlobal Auto
String Property TargetName = "" Auto
 
Event OnInit()
  RegisterForSingleUpdate(1.0)
  ;quests can send the OnInit event twice under some scenarios 
  ;registering for an update allows OnInit to fire twice but only call the code once
  ;as a second update registration replaces any previous registrations
EndEvent
 
Event OnUpdate()
  MaintWork()
EndEvent
 
Event OnPlayerLoadGame()
  MaintWork()
EndEvent
 
Function MaintWork()
  UnRegisterForAllMenus()
  If TargetName != ""  ;only register if TargetName property has been assigned valid data
    RegisterForMenu("RaceSex Menu") ; chargen menu for new games
    RegisterForMenu("TweenMenu") ;the between menu for magic, inventory, map and leveling for mid-progress games
  Else 
    ;TargetName has an empty value - make sure global is reset
    myGlobal.SetValue(0.0)
  EndIf
  ;add any other code that might need to be done when initiated or when the game is loaded again
EndFunction
 
Event OnMenuClose(String MenuName)
  If (MenuName == "RaceSex Menu" || MenuName == "TweenMenu")
    If Game.GetPlayer().GetName() == TargetName
      myGlobal.SetValue(1.0)
    Else
      myGlobal.SetValue(0.0)
    EndIf
  EndIf
EndEvent

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...