Yes, this works on PCs. Here's a simple example to illustrate using chat commands to set a portrait, though you'd surely want a more robust chat command system handling this. Just put this OnPlayerChat and, ingame, type "!portrait x", where x is the name of the portrait. Remember to put everything but the trailing size letter (i.e., po_aragorn_, not po_aragorn_h).
void main()
{
object oPC = GetPCChatSpeaker();
string sChat = GetPCChatMessage();
// See if the PC's trying to change his portrait
if (GetStringLeft(sChat, 10) == "!portrait ")
{
string sResRef = GetStringRight(sChat, GetStringLength(sChat) - 10);
SetPortraitResRef(oPC, sResRef);
SetPCChatMessage();
}
}
EDIT: to do this from a placeable's conversation, you could have the placeable set a local int on the player and them have the OnPlayerChat script check for the int before attempting to check for the portrait command.
EDIT 2: It's probably a good idea to store the PC's current portrait, just in case they mess something up and need it reset.
Modifié par Squatting Monk, 20 octobre 2013 - 04:45 .