Added CCOH and missing areas Changed some areas to be craftable, Fixed some on death issues, Fixed the Gaurd
410 lines
13 KiB
Plaintext
410 lines
13 KiB
Plaintext
//><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>*
|
||
//:: Name: _c_inc_message
|
||
//:: Function: include for RagE's Message Board
|
||
//><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>*
|
||
/*
|
||
This include script will not compile!!
|
||
I've scripted this to the best of my ability's!
|
||
It's by no mean's the best or most efficient way to script this Message board
|
||
as my scripting skill's are still limited but i gave it a go :D
|
||
If you make any change's in here make sure to recompile your module.
|
||
Any alteration of this script is allowed as long as you include the copyright
|
||
notice & Author's name in any redistribution of this code.
|
||
|
||
///- Update's -///
|
||
|
||
A thank's to (pspeed) & his Z-Dialog System for giving me some idea's!!!
|
||
Ok this will proberbly be the last update unless any bug's are found
|
||
finger's crossed lol. Anyway some small alteration's and fix's from the
|
||
previous version. You can now store an unlimited amount of post
|
||
to the message board. For people who use this in large server's might
|
||
experience some lag when adding a message as the NWN Database is quite slow.
|
||
*/
|
||
//><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>*
|
||
//:: Created By: RagE aka Napalm-uk-RTW
|
||
//:: Created On: 25/9/05
|
||
//:: Copyright (c) 2002 *RTW* corp.
|
||
//><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>*
|
||
// - UPDATED Version 3.0
|
||
////////////////////////////////////////////////////////////////////////////////
|
||
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||
//* *RagE* * //
|
||
//* MESSAGE BOARD v3.0 * //
|
||
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||
////////////////////////////////////////////////////////////////////////////////
|
||
// - You can alter these DataBase name's if needed if any conflit's occur with
|
||
// - other DataBase's in your module
|
||
////////////////////////////////////////////////////////////////////////////////
|
||
//-----------------------CONSTANTS-DATABASE-NAMES-----------------------------//
|
||
////////////////////////////////////////////////////////////////////////////////
|
||
const string M_MB_DB = "MSGBD_DB"; // - Message Board Main Database //
|
||
const string _INDEX_ = "_INDEX_"; // - Store current page number //
|
||
const string _PAGE_ = "_PAGE_"; // - View and set page _PAGE_+(No.) //
|
||
const string M_ADMIN = "M_ADMIN"; // - Admin message entry //
|
||
const string M_POLL = "M_POLL"; // - Poll question entry //
|
||
const string M_YES = "M_YES"; // - Vote no entry //
|
||
const string M_NO = "M_NO"; // - Vote yes entry //
|
||
const string M_VOTED = "M_VOTED"; // - Check has voted //
|
||
const string M_TITLE = "M_TITLE"; // - Scribe title entry //
|
||
const string M_BODY = "M_BODY"; // - Scribe body entry //
|
||
const string M_TITLE_ = "M_TITLE_"; // - Message board title M_TITLE_+(No.)//
|
||
const string M_BODY_ = "M_BODY_"; // - Message board body M_BODY_+(No.) //
|
||
const string M_HIT = "M_HIT"; // - Message board hit rating //
|
||
const string M_COUNT = "M_COUNT"; // - Message count reset //
|
||
const string M_NAME = "M_NAME"; // - Name of the last poster //
|
||
const string AUTHORIZE = "AUTHORIZE";// - Allow DM to delete a message //
|
||
////////////////////////////////////////////////////////////////////////////////
|
||
|
||
////////////////////////////////////////////////////////////////////////////////
|
||
//-------------------------------FUNCTIONS------------------------------------//
|
||
////////////////////////////////////////////////////////////////////////////////
|
||
|
||
// - SetCampaignInt Wrapper
|
||
void SetDataBaseInt(string sDataName,int nData);
|
||
// - SetCampaignString Wrapper
|
||
void SetDataBaseString(string sDataName,string sData);
|
||
// - GetCampaignString Wrapper
|
||
string GetDataBaseString(string sDataName);
|
||
// - GetCampaignInt Wrapper
|
||
int GetDataBaseInt(string sDataName);
|
||
// - Veiw nMessage at nPage on the message board
|
||
int ShowMessage(int nMessage,int nPage);
|
||
// - Cast vote and store it
|
||
void CastVote(int nVote);
|
||
// - Delete a specific message on the message board
|
||
void DeleteMessage(int nMessage,int nPage);
|
||
// - Delete message nType
|
||
void DeleteMessageType(int nType);
|
||
// - Sware word filter function
|
||
void SwareFilter();
|
||
// - Store's the message Title to Temporary Database - "M_TITLE"
|
||
void SetMessageTitle();
|
||
// - Store's the message Body to Temporary Database - "M_BODY"
|
||
void SetMessageBody();
|
||
// - Store's the server message to Temporary Database - "M_BODY"
|
||
void SetAdminMessage();
|
||
// - Store's a message to the message board
|
||
void AddPost();
|
||
// - Store server message to the message board
|
||
void AddAdminPost();
|
||
// - Store poll question to the message board
|
||
void AddPollPost();
|
||
// - Text colour Token's
|
||
void ColourTokens();
|
||
// - Random Text
|
||
void Profanity();
|
||
// - Veiw server message
|
||
int ShowAdminMessage();
|
||
// - Veiw poll question
|
||
int ShowPollMessage();
|
||
// - View poll results
|
||
int ShowVoteResults();
|
||
|
||
////////////////////////////////////////////////////////////////////////////////
|
||
//----------------------------IMPLEMENTATION----------------------------------//
|
||
////////////////////////////////////////////////////////////////////////////////
|
||
|
||
void SetDataBaseInt(string sDataName,int nData)
|
||
{
|
||
SetCampaignInt(M_MB_DB,sDataName,nData);
|
||
}
|
||
|
||
int GetDataBaseInt(string sDataName)
|
||
{
|
||
return GetCampaignInt(M_MB_DB,sDataName);
|
||
}
|
||
|
||
void SetDataBaseString(string sDataName,string sData)
|
||
{
|
||
SetCampaignString(M_MB_DB,sDataName,sData);
|
||
}
|
||
|
||
string GetDataBaseString(string sDataName)
|
||
{
|
||
return GetCampaignString(M_MB_DB,sDataName);
|
||
}
|
||
|
||
void DeleteMessageType(int nType)
|
||
{
|
||
if(nType == 1) {
|
||
DestroyCampaignDatabase(M_MB_DB);
|
||
} else if(nType == 2) {
|
||
DeleteCampaignVariable(M_MB_DB,M_ADMIN);
|
||
} else if(nType == 3) {
|
||
SetDataBaseInt(M_YES,0);
|
||
SetDataBaseInt(M_NO,0);
|
||
DeleteCampaignVariable(M_MB_DB,M_POLL);
|
||
DeleteCampaignVariable(M_MB_DB,M_VOTED);
|
||
}
|
||
PlaySound("gui_magbag_full");
|
||
}
|
||
|
||
void DeleteMessage(int nMessage,int nPage)
|
||
{
|
||
object oPC = GetPCSpeaker();
|
||
if(GetLocalInt(oPC,AUTHORIZE) == TRUE) {
|
||
SetCustomToken(8500+nMessage,"<c<>>**Deleted**");
|
||
SetDataBaseString(M_TITLE_+IntToString(nMessage)+_PAGE_+IntToString(nPage),"<c<>>**Deleted**");
|
||
SetDataBaseString(M_BODY_+IntToString(nMessage)+_PAGE_+IntToString(nPage),"<c<>>**Deleted**");
|
||
SetLocalInt(oPC,AUTHORIZE,FALSE);
|
||
PlaySound("gui_magbag_full");
|
||
}
|
||
}
|
||
|
||
void CastVote(int nVote)
|
||
{
|
||
object oPC = GetPCSpeaker();
|
||
int nNo = GetDataBaseInt(M_NO);
|
||
int nYes = GetDataBaseInt(M_YES);
|
||
int nVoted = GetCampaignInt(M_MB_DB,M_VOTED,oPC);
|
||
|
||
if(nVoted == TRUE) {
|
||
PlaySound("gui_error");
|
||
FloatingTextStringOnCreature("You have already cast your vote in this poll",oPC);
|
||
return;
|
||
} else if(nVote == 1) {
|
||
++nYes;
|
||
SetDataBaseInt(M_YES,nYes);
|
||
SetCampaignInt(M_MB_DB,M_VOTED,TRUE,oPC);
|
||
} else if(nVote == 2) {
|
||
++nNo;
|
||
SetDataBaseInt(M_NO,nNo);
|
||
SetCampaignInt(M_MB_DB,M_VOTED,TRUE,oPC);
|
||
}
|
||
PlaySound("gui_journaladd");
|
||
}
|
||
|
||
void SetMessageTitle()
|
||
{
|
||
object oPC = GetPCSpeaker();
|
||
int nListen = GetListenPatternNumber();
|
||
string sName = GetPCPlayerName(oPC);
|
||
string sTitle = GetMatchedSubstring(0);
|
||
|
||
if(nListen == 1000 && GetIsPC(oPC))
|
||
{
|
||
if(GetStringLength(sTitle) > 30)
|
||
{
|
||
sTitle = GetStringLeft(sTitle,30);
|
||
SpeakString("Maximum Title length is 30 character's");
|
||
PlaySound("gui_error");
|
||
return;
|
||
|
||
} else {
|
||
|
||
string sSay = "<c<><63><EFBFBD>>"+sTitle+"<c<01>> By:<c<><63><EFBFBD>> ("+sName+")</c>\n";
|
||
SetLocalString(OBJECT_SELF,M_TITLE,sSay);
|
||
SwareFilter();
|
||
}
|
||
}
|
||
}
|
||
|
||
void SetMessageBody()
|
||
{
|
||
object oPC = GetPCSpeaker();
|
||
int nListen = GetListenPatternNumber();
|
||
string sBody = GetMatchedSubstring(0);
|
||
string sDate = IntToString(GetCalendarDay())+"/"+IntToString(GetCalendarMonth())+"/"+IntToString(GetCalendarYear());
|
||
string sTime = IntToString(GetTimeHour())+":"+IntToString(GetTimeMinute());
|
||
string sSay;
|
||
|
||
if(nListen == 1000 && GetIsPC(oPC))
|
||
{
|
||
if(GetStringLength(sBody) > 500)
|
||
{
|
||
sBody = GetStringLeft(sBody,500);
|
||
SpeakString("Maximum Message length is 500 character's");
|
||
PlaySound("gui_error");
|
||
return;
|
||
|
||
} else {
|
||
|
||
sSay += "<c<01>>Date: <c<><63><EFBFBD>>"+sDate+" <c<01>>Time: <c<><63><EFBFBD>>"+sTime+"\n";
|
||
sSay += "<c<>>-------------------------------------------\n";
|
||
sSay += "<c<><63><EFBFBD>>"+sBody+"\n";
|
||
sSay += "<c<>>-------------------------------------------\n";
|
||
|
||
SetLocalString(OBJECT_SELF,M_BODY,sSay);
|
||
SwareFilter();
|
||
}
|
||
}
|
||
}
|
||
|
||
void SetAdminMessage()
|
||
{
|
||
object oPC = GetPCSpeaker();
|
||
int nListen = GetListenPatternNumber();
|
||
string sBody = GetMatchedSubstring(0);
|
||
string sSay;
|
||
|
||
if(nListen == 1000 && GetIsPC(oPC))
|
||
{
|
||
if(GetStringLength(sBody) > 500)
|
||
{
|
||
sBody = GetStringLeft(sBody,500);
|
||
SpeakString("Maximum Message length is 500 character's");
|
||
PlaySound("gui_error");
|
||
return;
|
||
|
||
} else {
|
||
|
||
sSay += "<c<>>-------------------------------------------\n";
|
||
sSay += "<c<><63><EFBFBD>>"+sBody+"\n";
|
||
sSay += "<c<>>-------------------------------------------\n";
|
||
|
||
SetLocalString(OBJECT_SELF,M_BODY,sSay);
|
||
SwareFilter();
|
||
}
|
||
}
|
||
}
|
||
|
||
string RandomSpeak(int nRandom)
|
||
{
|
||
switch(nRandom)
|
||
{
|
||
case 1:
|
||
return "Didn't your mother ever teach you manner's?";
|
||
case 2:
|
||
return "Your english is very good";
|
||
case 3:
|
||
return "Did you goto Cambridge?";
|
||
case 4:
|
||
return "Wash your mouth out!";
|
||
case 5:
|
||
return "How dare you use language like that!!";
|
||
}
|
||
return ">.<";
|
||
}
|
||
void Profanity()
|
||
{
|
||
int nRandom = Random(5);
|
||
string sString = RandomSpeak(nRandom);
|
||
SpeakString(sString);
|
||
}
|
||
|
||
void SwareFilter()
|
||
{
|
||
object oPC = GetPCSpeaker();
|
||
string sFilter = "**(wanker|cunt|shit|cock|fuck|dick|prick|pussy|bitch|gay|faggot|nigger|pakki)**";
|
||
string sSaid = GetMatchedSubstring(0);
|
||
|
||
if(TestStringAgainstPattern(sFilter,sSaid))
|
||
{
|
||
Profanity();
|
||
AssignCommand(OBJECT_SELF,ActionStartConversation(oPC,"_c_message_s"));
|
||
DeleteLocalString(OBJECT_SELF,M_TITLE);
|
||
DeleteLocalString(OBJECT_SELF,M_BODY);
|
||
PlaySound("gui_error");
|
||
}
|
||
}
|
||
|
||
void ColourTokens()
|
||
{
|
||
SetCustomToken(1000,"<c<><63><EFBFBD>>"); //White
|
||
SetCustomToken(1001,"<c<>>"); //Red
|
||
SetCustomToken(1002,"<c<01>>"); //Green
|
||
SetCustomToken(1003,"<c<><63><EFBFBD>>"); //Silver
|
||
SetCustomToken(1004,"<c<01>>"); //Blue
|
||
SetCustomToken(1005,"<c<><63>>"); //Yellow
|
||
}
|
||
|
||
void AddAdminPost()
|
||
{
|
||
string sPost = GetLocalString(OBJECT_SELF,M_BODY);
|
||
SetDataBaseString(M_ADMIN,sPost);
|
||
}
|
||
|
||
void AddPollPost()
|
||
{
|
||
string sPost = GetLocalString(OBJECT_SELF,M_BODY);
|
||
SetDataBaseString(M_POLL,sPost);
|
||
SetDataBaseInt(M_YES,0);
|
||
SetDataBaseInt(M_NO,0);
|
||
DeleteCampaignVariable(M_MB_DB,M_VOTED);
|
||
}
|
||
|
||
void AddPost()
|
||
{
|
||
object oPC = GetPCSpeaker();
|
||
int nIndex = GetDataBaseInt(_INDEX_);
|
||
int nCount = GetDataBaseInt(M_COUNT);
|
||
int nPage = GetDataBaseInt(_PAGE_);
|
||
string sTitle = GetLocalString(OBJECT_SELF,M_TITLE);
|
||
string sBody = GetLocalString(OBJECT_SELF,M_BODY);
|
||
|
||
if(nCount >= 10)
|
||
{
|
||
++nPage;
|
||
++nIndex;
|
||
SetDataBaseInt(M_COUNT,1);
|
||
SetDataBaseInt(_PAGE_,nPage);
|
||
SetDataBaseInt(_INDEX_,nIndex);
|
||
SetDataBaseString(M_TITLE_+IntToString(1)+_PAGE_+IntToString(nIndex),sTitle);
|
||
SetDataBaseString(M_BODY_+IntToString(1)+_PAGE_+IntToString(nIndex),sBody);
|
||
|
||
} else {
|
||
|
||
++nCount;
|
||
SetDataBaseInt(M_COUNT,nCount);
|
||
SetDataBaseString(M_TITLE_+IntToString(nCount)+_PAGE_+IntToString(nIndex),sTitle);
|
||
SetDataBaseString(M_BODY_+IntToString(nCount)+_PAGE_+IntToString(nIndex),sBody);
|
||
}
|
||
SetDataBaseString(M_NAME,"<c<><63><EFBFBD>>("+GetPCPlayerName(oPC)+")");
|
||
}
|
||
|
||
int ShowVoteResults()
|
||
{
|
||
int nYes = GetDataBaseInt(M_YES);
|
||
int nNo = GetDataBaseInt(M_NO);
|
||
SetCustomToken(4000,"<c<>>(<c<><63><EFBFBD>>"+IntToString(nYes)+"<c<>>)");
|
||
SetCustomToken(5000,"<c<>>(<c<><63><EFBFBD>>"+IntToString(nNo)+"<c<>>)");
|
||
return TRUE;
|
||
}
|
||
|
||
int ShowMessage(int nMessage,int nPage)
|
||
{
|
||
string sMessage = GetDataBaseString(M_BODY_+IntToString(nMessage)+_PAGE_+IntToString(nPage));
|
||
string sTitle = GetDataBaseString(M_TITLE_+IntToString(nMessage)+_PAGE_+IntToString(nPage));
|
||
|
||
if(sTitle != "") {
|
||
SetCustomToken(8500+nMessage,sMessage);
|
||
SetCustomToken(7500+nMessage,sTitle);
|
||
return TRUE;
|
||
|
||
} else {
|
||
|
||
return FALSE;
|
||
}
|
||
}
|
||
|
||
int ShowPollMessage()
|
||
{
|
||
string sMessage = GetDataBaseString(M_POLL);
|
||
|
||
if(sMessage != "") {
|
||
SetCustomToken(3000,sMessage);
|
||
return TRUE;
|
||
|
||
} else {
|
||
|
||
return FALSE;
|
||
}
|
||
}
|
||
|
||
int ShowAdminMessage()
|
||
{
|
||
string sMessage = GetDataBaseString(M_ADMIN);
|
||
|
||
if(sMessage != "") {
|
||
SetCustomToken(2000,sMessage);
|
||
return TRUE;
|
||
|
||
} else {
|
||
|
||
return FALSE;
|
||
}
|
||
}
|
||
|
||
/*
|
||
void main(){}
|