Ok will show you my way of doing that.
I have this in my OnPlayerChat event script
void main()
{
object oModule = OBJECT_SELF;
object oPC = GetPCChatSpeaker();
string listening_script = GetLocalString(oPC,"START_LISTENING");
if(listening_script!="")
{
SetLocalInt(oModule,"GetRunningEvent()",15);
ExecuteScript(listening_script,oPC);
DeleteLocalInt(oModule,"GetRunningEvent()");
return;
}
}
and now I got two custom functions that will start and stop listening of current player and they can be used inside one script like this
void StartListening(object oPlayer, string sScript)
{
SetLocalString(oPlayer,"START_LISTENING",sScript);
}
void StopListening(object oPlayer)
{
DeleteLocalString(oPlayer,"START_LISTENING");
}
void main()
{
int nEvent = GetLocalInt(GetModule(),"GetRunningEvent()");
if(nEvent == 15)//script fired from OnChat
{
object oPC = OBJECT_SELF;
string sMessage = GetPCChatMessage();
SetPCChatMessage();//message wont be displayed
StopListening(oPC);//disable further listening
ActionResumeConversation();//unpause conversation
}
else//script fired from conversation
{
object oPC = GetPCSpeaker();
object oNPC = OBJECT_SELF;
StartListening(oPC,"listen_template");//start listen the player
ActionPauseConversation();//pause an conversation until player says something
}
}
This is used for conversation, so if you use some npc or placeable (which cannot use the first option to do this cos it missing OnConversation event) you can have a conversation where will be:
you see a bridge, blah blah - continue (the script above must be set on this line in Actions Taken event)
say password nub - and now continue doesnt appear since the conversation is paused until you say something.
then you must make a two options depending if the player spoken correct password
(will complete this after I re-check something, stay tuned)