logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Sharing my script

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Technical support
View previous topic :: View next topic  
Author Message
PNJ



Joined: 30 Jun 2007
Posts: 67

PostPosted: Tue Aug 07, 2007 11:59    Post subject: Sharing my script Reply with quote

Hello i don't know where to post this, but since this forum is about using NWNX4 i m puting it here.

Here is the code i made for NWNX4 1.8 & CHAT plugin.

Made for our persistant world, it intercept player text to put roleplay emotes in italic.

exemple : *look his foot* Where this shadow come from? *rise the head and scan the sky*
become : *look his foot* Where this shadow come from? *rise the head and scan the sky*

Just a détail, but add a a lot for role-players and encourage them to describe more their actions.

Code:
   if (nMode==1)
   {
   
   int iItalic=FALSE;
   string sTemp;
   string sOutput;
   
   while ( GetStringLength( sText) > 0)
    {
   sTemp = GetStringLeft( sText, 1);
    if (sTemp == "*")
      {
      if (!iItalic) sTemp = "*<i>";
      if (iItalic) sTemp = "*</i>";
      if (!iItalic)
         {iItalic=TRUE;}
         else
         {iItalic=FALSE;}
      }
   sOutput = sOutput + sTemp;
    sText = GetStringRight( sText, GetStringLength( sText) - 1);
    }
   NWNXSetInt("CHAT", "SUPRESS", "", 0, 1);
   SpeakString(sOutput);
   // debut SendMessageToPC(oPC,sOutput);
   }
Back to top
View user's profile Send private message
ShaDoOoW



Joined: 20 Aug 2005
Posts: 584

PostPosted: Thu Aug 09, 2007 14:03    Post subject: Reply with quote

EDITED: Im sorry, again, I find this thread by looking for new posts so I overlooked that this is thread for nwnx4. So I cannot post source of it.

One idea from my chat system.

I have my own system and it working a little different then Funky's one, but for scripter experienced in struct will be easy to understand.

This idea is an similar system to bioware listener, but better. Bioware listener listens PCs near some NPC, this system listen PC wherever is it. It could be also improved like SetListenPattern but i don't like it.

part of chat script
Code:
void main()
{
struct message m = GetPlayerMessage(OBJECT_SELF);
string listening_script = GetLocalString(OBJECT_SELF,"START_LISTENING");
 if(listening_script!="")
 {
 object oModule = GetModule();
SetLocalInt(oModule,"GetRunningEvent()",EVENT_NWNX_ON_SEND_MESSAGE);
 ExecuteScript(listening_script,OBJECT_SELF);
 DeleteLocalInt(oModule,"GetRunningEvent()");
 LogPlayerMessage(OBJECT_SELF,m);
 return;
 }
}


include file with my functions
Code:
const int EVENT_NWNX_ON_SEND_MESSAGE                   = 20;//very special case, nwnx event

//Get current running event (PRC's idea)
int GetRunningEvent();

int GetRunningEvent()
{
return GetLocalInt(GetModule(),"GetRunningEvent()");
}

//start listening given player and when player say something, sScript is executed
void StartListening(object oPlayer, string sScript);

void StartListening(object oPlayer, string sScript)
{
SetLocalString(oPlayer,"START_LISTENING",sScript);
}

//no comment
void StopListening(object oPlayer);

void StopListening(object oPlayer)
{
DeleteLocalString(oPlayer,"START_LISTENING");
}


and there is listen_template script that shows how and what for it's good
Code:
#include "_sh_inc_newfce"
#include "_sh_inc_chat"

void main()
{
int nEvent = GetRunningEvent();
 if(nEvent==EVENT_NWNX_ON_SEND_MESSAGE)//script was run from OnSendMessage event
 {
 object oPC = OBJECT_SELF;
 struct message m = GetPlayerMessage();
 MutePlayerMessage();//disable show message
 StopListening(OBJECT_SELF);
 ActionResumeConversation();
 }
 else//script was run from conversation
 {
 StartListening(GetPCSpeaker(),"listen_start");
 ActionPauseConversation();
 }
}


Note1: This need some of my chat function, but the point is that idea. So I think there are experienced scripters that could rewrite it.
Note2: If someone like it, I can offer full source of my chat system.
_________________
Community Patch / NWNX Patch / NWNX Files / NWNX Connect
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Technical support All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group