Aller au contenu

Photo

How to use a UI input box to change the name of an NPC (Resolved)


  • Veuillez vous connecter pour répondre
1 réponse à ce sujet

#1
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I have an NPC that I need to allow the PC to name.  I want to use a similar that is similar to the crafting system that lets you name new weapons that you craft. 

I know that I need to call a UI input box with the function:

DisplayInputBox();

And I know I need to somehow get that information to the

SetFirstName();

function. 


I'm just not exactly sure how it all will interact. 

Modifié par M. Rieder, 09 octobre 2011 - 02:25 .


#2
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Got it. I just modified the code for naming enchanted weapons slightly to change the text in the input box. Otherwise it appears to work for creatures just as well as weapons. I suspect you could rename anything if you coded it properly.

Here's the code I used:

//renames golem.
//#include "ginc_crafting"


void SetEnchantedItemName(object oPC, object oItem)
{


string VAR_ENCHANTED_ITEM_OBJECT = "EnchantedItemObject";



int nMessageStrRef = 181743;
string sMessage = "What shall you name the golem?"; // "Please rename the item.";
string sOkCB = "gui_name_enchanted_item";
string sCancelCB = "";
int bShowCancel = FALSE;
string sScreenName = "";
int nOkStrRef = 181744;
string sOkString = "";
int nCancelStrRef = 181745;
string sCancelString = "";
string sDefaultString = GetFirstName(oItem);
string sVariableString = "";


// the gui script will always run on the owned PC, regardless of who the player has possessed.
object oObj = GetOwnedCharacter(oPC);
SetLocalObject(oObj, VAR_ENCHANTED_ITEM_OBJECT, oItem);

DisplayInputBox( oPC, nMessageStrRef, sMessage, sOkCB, sCancelCB, bShowCancel,
sScreenName, nOkStrRef, sOkString, nCancelStrRef, sCancelString,
sDefaultString, sVariableString);
}


void main()
{
object oGolem = GetObjectByTag("golem_companion");
object oPC = GetFactionLeader(GetFirstPC());
SetEnchantedItemName(oPC,oGolem);
}