I ain't sure whether by 'random' you mean from a list of assigned strings or you just have the one string that you want the NPC to speak. Either way the one I made for you has only one string in it (you can add more if you wish).
Quote:
void main()
{
object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN);
AssignCommand(oPC, ClearAllActions());
object oTarget;
SpeakString("I've got best prices this side of Amn!");
}
|
The problem with the Onheartbeat and string text is that the duration the text floats never ctaches up with the heartbeat so..in-game the text will just continuosuly float over the NPC's head without actually dissapearing.
I don't know exactly what you arte wanting to do but maybe if you call the script from the Onperceived lines it will work better for you (that is everytime a PC is seen by an NPC he/she will utter the string of text). Let me know if this is what you need and i'll make one up for you.