420 wrote...
So even though the placeable can listen there is no Event fired when it hears its pattern listened for.
As of patch 1.69 there is a new module event called OnPlayerChat which could replace listening pattern scripts but I haven't experimented with it at all.
I did. This set of function may be useful.
functions
//starts listening given player, if he write something into chat (do not need to be near NPC), script gets run
void StartListening(object oPlayer, string sScript);
//stops listenning given player
void StopListening(object oPlayer);
void StartListening(object oPlayer, string sScript)
{
SetLocalString(oPlayer,"START_LISTENING",sScript);
}
void StopListening(object oPlayer)
{
DeleteLocalString(oPlayer,"START_LISTENING");
}
this code goes in top of OnPlayerChat event
object oPC = GetPCChatSpeaker();
string listening_script = GetLocalString(oPC,"START_LISTENING");
if(listening_script!="")
{
SetLocalString(GetModule(),"GetRunningEvent()","OnPlayerChat");
ExecuteScript(listening_script,oPC);
SetLocalString(GetModule(),"GetRunningEvent()","");
return;
}
template for listening script - this script name is "listen_template"
void main()
{
string sEvent = GetLocalString(GetModule(),"GetRunningEvent()");
if(sEvent == "OnPlayerChat")//script ran from OnChat event
{
object oPC = OBJECT_SELF;
string sMessage = GetPCChatMessage();
//now do something
SetPCChatMessage();//message do not appear - optional
StopListening(oPC);
ActionResumeConversation();
}
else//script ran from conversation action node
{
object oNPC = OBJECT_SELF;
object oPC = GetPCSpeaker();
StartListening(oPC,"listen_template");//must match with script name
ActionPauseConversation();
}
}
Modifié par ShaDoOoW, 13 août 2010 - 12:25 .