text input
#1
Posté 07 avril 2011 - 06:42
What I'd like to know is how easy it would be in implement a scanner or text input box. To give you a simple idea, I'd have a bridge that would require you to input several correct words to make the next piece of the bridge appear - the script would obviously be called from conversation, but I'm not sure how to implement it if it is, at all, possible.
#2
Posté 07 avril 2011 - 07:06
1) use and invisible npc (no problem since you can click on it but also may be invisible but you need a script for that again) that starts a conversation where you can do it via OnConversation event (SetListenPattern) well quite hard to understand and I dont have any similar script in my module to show you
2) using a trigger and OnPlayerChat event you can make that once you enter trigger the OnPlayerChat event will listen this player and run a script you need. I got nice function for this if you would try this route.
#3
Posté 07 avril 2011 - 07:23
Number 2 sounds interesting though - i take it the player walks into a trigger- you could probably alert the player to that with a simple floating text, then you can chat as normal with certain key words..
#4
Posté 07 avril 2011 - 08:14
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
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: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
}
}
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)
#5
Posté 07 avril 2011 - 08:25
something like
if(sMessage == "password")
{
SetLocalInt(oPC,"SAID_PASSWORD",TRUE);
}
and then you need those two options and first (and "correct") line must have a conditional script to check "SAID_PASSWORD" to TRUE while second doesnt need any script just tell you that the password is incorrect and end a conversation.
If you want I can send you an example with everythin set already and working, so you would need just to change password and texts.
The trigger way would be easier it would looked 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 uncomment if you want to display it
StopListening(oPC);//disable further listening
if(sMessage == "password)
{
//do whatever you want to do, teleport to waypoint? etc
}
}
else//script fired from trigger
{
object oPC = GetEnteringObject();
if(!GetIsPC(oPC))return;
StartListening(oPC,"listen_template");//start listen the player
FloatingTextStringOnCreature("tell the password nub!",oPC);
}
}
Modifié par ShaDoOoW, 07 avril 2011 - 08:26 .
#6
Posté 07 avril 2011 - 08:28
#7
Posté 07 avril 2011 - 10:37
SetListening() . . is it only for NPCs?
SetListenPattern()
It also does not hurt to look at the lexicon.
Function - GetIsListening
Function - SetListeningPatterns
Function - SetListening
Event - OnConversation
Function - GetListenPatternNumber
#8
Posté 08 avril 2011 - 11:06





Retour en haut






