generated from Jaysyn/ModuleTemplate
Initial upload
Initial upload
This commit is contained in:
142
_mod/_module/nss/speech_j_h.nss
Normal file
142
_mod/_module/nss/speech_j_h.nss
Normal file
@@ -0,0 +1,142 @@
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// speech_j_h - Speech Journal H
|
||||
// This journal will track speech
|
||||
// By Deva Bryson Winblood. 04/16/2005
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const int MAX_CHAT_LOG = 10;
|
||||
|
||||
///////////////////////
|
||||
// PROTOTYPES
|
||||
///////////////////////
|
||||
|
||||
// FILE: speech_j_h FUNCTION:ChatJ_AddToJournal()
|
||||
// This will add a message to the journal.
|
||||
void ChatJ_AddToJournal(object oPC,string sMsg);
|
||||
|
||||
// FILE: speech_j_h FUNCTION: ChatJ_GetFirstJournalEntry()
|
||||
// This will return the first journal entry for this PC
|
||||
string ChatJ_GetFirstJournalEntry(object oPC);
|
||||
|
||||
// FILE: speech_j_h FUNCTION: ChatJ_GetNextJournalEntry()
|
||||
// This will return the next journal entry for this PC
|
||||
string ChatJ_GetNextJournalEntry(object oPC);
|
||||
|
||||
// FILE: speech_j_h FUNCTION: ChatJ_RemoveFirstJournalEntry()
|
||||
// This will remove the first journal entry making room for more
|
||||
void ChatJ_RemoveFirstJournalEntry(object oPC);
|
||||
|
||||
// FILE: speech_j_h FUNCTION: ChatJ_UpdateJournal
|
||||
// This will update the custom token used in the journal with
|
||||
// the latest chat logs.
|
||||
void ChatJ_UpdateJournal(object oPC);
|
||||
|
||||
///////////////////////
|
||||
// FUNCTIONS
|
||||
///////////////////////
|
||||
string ChatJ_GetFirstJournalEntry(object oPC)
|
||||
{
|
||||
int nCP=GetLocalInt(oPC,"nChatPosition");
|
||||
string sS="";
|
||||
if (oPC!=OBJECT_INVALID)
|
||||
{ // PC exists
|
||||
sS=GetLocalString(oPC,"sChatLog_1");
|
||||
SetLocalInt(oPC,"nChatMonitor",1);
|
||||
} // PC exists
|
||||
return sS;
|
||||
} // ChatJ_GetFirstJournalEntry()
|
||||
|
||||
string ChatJ_GetNextJournalEntry(object oPC)
|
||||
{
|
||||
int nCP=GetLocalInt(oPC,"nChatPosition");
|
||||
string sS="";
|
||||
int nP;
|
||||
if (oPC!=OBJECT_INVALID)
|
||||
{ // PC exists
|
||||
nP=GetLocalInt(oPC,"nChatMonitor");
|
||||
nP++;
|
||||
if (nP<=MAX_CHAT_LOG)
|
||||
{ // within allowed
|
||||
sS=GetLocalString(oPC,"sChatLog_"+IntToString(nP));
|
||||
SetLocalInt(oPC,"nChatMonitor",nP);
|
||||
} // within allowed
|
||||
} // PC exists
|
||||
return sS;
|
||||
} // ChatJ_GetNextJournalEntry()
|
||||
|
||||
void ChatJ_RemoveFirstJournalEntry(object oPC)
|
||||
{
|
||||
int nCP=GetLocalInt(oPC,"nChatPosition");
|
||||
string sS="";
|
||||
int nP;
|
||||
if (oPC!=OBJECT_INVALID)
|
||||
{ // object exists
|
||||
nP=1;
|
||||
while(nP<MAX_CHAT_LOG)
|
||||
{ // copy strings
|
||||
sS=GetLocalString(oPC,"sChatLog_"+IntToString(nP+1));
|
||||
if (GetStringLength(sS)>0) SetLocalString(oPC,"sChatLog_"+IntToString(nP),sS);
|
||||
else { nP=MAX_CHAT_LOG+10; }
|
||||
nP++;
|
||||
} // copy strings
|
||||
} // object exists
|
||||
} // ChatJ_RemoveFirstJournalEntry()
|
||||
|
||||
|
||||
void fnChatUpdate(object oPC)
|
||||
{ // PURPOSE: handle the actual update
|
||||
int nCP=GetLocalInt(oPC,"nChatPosition");
|
||||
string sS="";
|
||||
string sJ;
|
||||
sS=ChatJ_GetFirstJournalEntry(oPC);
|
||||
while(GetStringLength(sS)>0)
|
||||
{ // log
|
||||
sJ=sJ+sS+" ";
|
||||
sS=ChatJ_GetNextJournalEntry(oPC);
|
||||
} // log
|
||||
if (GetStringLength(sJ)>0)
|
||||
{ // journal exists
|
||||
RemoveJournalQuestEntry("chatlog",oPC,FALSE,FALSE);
|
||||
SetCustomToken(87000+nCP,sJ);
|
||||
DelayCommand(0.5,AddJournalQuestEntry("chatlog",nCP,oPC,FALSE,FALSE));
|
||||
} // journal exists
|
||||
DeleteLocalInt(oPC,"bChatJournalUpdate");
|
||||
} // fnChatUpdate()
|
||||
|
||||
void ChatJ_UpdateJournal(object oPC)
|
||||
{
|
||||
if (oPC!=OBJECT_INVALID)
|
||||
{ // update
|
||||
if (GetLocalInt(oPC,"bChatJournalUpdate")==FALSE)
|
||||
{ // trigger update
|
||||
DelayCommand(24.0,fnChatUpdate(oPC));
|
||||
SetLocalInt(oPC,"bChatJournalUpdate",TRUE);
|
||||
} // trigger update
|
||||
} // update
|
||||
} // ChatJ_UpdateJournal()
|
||||
|
||||
void ChatJ_AddToJournal(object oPC,string sMsg)
|
||||
{
|
||||
int nCP=GetLocalInt(oPC,"nChatPosition");
|
||||
string sS="test";
|
||||
int nC;
|
||||
int nP;
|
||||
nP=0;
|
||||
while(nP<MAX_CHAT_LOG&&GetStringLength(sS)>1)
|
||||
{ // find position to plug this text
|
||||
nP++;
|
||||
sS=GetLocalString(oPC,"sChatLog_"+IntToString(nP));
|
||||
} // find position to plug this text
|
||||
if (nP<=MAX_CHAT_LOG&&GetStringLength(sS)<2)
|
||||
{ // found place to store journal
|
||||
SetLocalString(oPC,"sChatLog_"+IntToString(nP),sMsg);
|
||||
} // found place to store journal
|
||||
else
|
||||
{ // need to remove first entry
|
||||
ChatJ_RemoveFirstJournalEntry(oPC);
|
||||
SetLocalString(oPC,"sChatLog_"+IntToString(MAX_CHAT_LOG),sMsg);
|
||||
} // need to remove first entry
|
||||
DelayCommand(1.0,ChatJ_UpdateJournal(oPC));
|
||||
} // ChatJ_AddToJournal()
|
||||
|
||||
//void main(){}
|
||||
Reference in New Issue
Block a user