UW2_PRC8/_module/nss/on_player_chat.nss
Jaysyn904 5197ad9a4d Initial upload
Initial upload
2023-09-25 20:24:01 -04:00

698 lines
20 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//Script Name: on_player_chat
///////////////////////////////////////////
//Created & Designed By: Genisys (Guile)
//Created & Designed On: 9/13/08
// Udated On: 3/08/09
///////////////////////////////////////////
/*
This script goes in the New Module Event
OnPlayerChat, which will check to see
if a player has been banned from shouting,
if they are shouting we will tell them
they cannot shout, change thier channel too.
This allows you to control the player's
who love to shout TOO much. It works
off of a DM tool called "Chat Controller"
Also you can temporarily bann shouting.
IMPORTANT: You need to open the script
"dm_chat_inc" to configure the chat settings there!
(Be sure to build the module! (scripts only) & save when done!)
NOTE: These Prototypes in the include are called BEFORE color text is
added to the PC's Text Chat, so you don't have to filter color out at all!
UPDATED: Added Emotes from SimTools by FunkySwerve it's in the
"gen_chat_inc" include script w/ funky's include as well. Note:
not all of the emotes work, I will revise the list in the emote
commands item, which comes with this download.
*/
/////////////////////////////////////////////////////////////////
#include "gen_chat_inc"
//////////////////////////////////////////////////////////////////////////////
//DELCARE PROTOTYPES & CONSTANTS
//From the Hitchiker's Guide to Color (DON"T TOUCH THIS!)
const string sC= " ##################$%&'()*+,-./0123456789:;;==?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[[]^_`abcdefghijklmnopqrstuvwxyz{|}~~€<>ƒ„…†‡ˆ‰ŠŒ<E280B9>Ž<EFBFBD><C5BD>“”•˜™šœ<E280BA>žŸ¡¡¢£¤¥¦§¨©ª«¬¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþþ";
//Prorotype
string ColorString(string sText, int nRed=255, int nGreen=255, int nBlue=255);
//Prototype
void SendServerMessage(string sString);
//Prototype
void MakeTargetSpeak(string sString, object oDM);
//Prototype
void SetColorMessage(object oObject, string sChat, string sColor, int nWhich);
//////////////////////////////////////////////////////////////////////////////
//Main Script
void main()
{
//Declare Major Variables..
object oPC = GetPCChatSpeaker();
object oEPC = oPC;
string sChat = GetPCChatMessage();
string sEText = sChat;
int nVolume = GetPCChatVolume();
object oArea = GetArea(oPC);
string sName = GetName(oPC);
object oParty; //The Area Message PC(s)
effect eEffect;
effect eVis;
object oToken = GetItemPossessedBy(oPC, "idtoken");
//////////////////////////////////////////////////////////////////////
//For checking time...
int nDelay = GetLocalInt(GetModule(), "RESET_DELAY");
int nDelayCheck = GetLocalInt(GetModule(), "NO_MORE_DELAYS");
int nCount = GetLocalInt(GetModule(), "RESET_VOTE");
int nDelayPC = GetLocalInt(oEPC, "DELAYED_RESET");
int nResetTime = GetLocalInt(GetModule(), "DELAY_OK");
int nStopDelays = GetLocalInt(GetModule(), "STOP_DELAYS");
object oServer = GetObjectByTag("server_msg");
int nRTime = GetLocalInt(GetModule(), "RESET_MIN");
int nTime = nRTime - 188; //3 Minutes till restart!
string s = "EMERGENCY SERVER RESTART INITIALIZED!";
//DM Commands
//DM Chat Commands.... (Will add more later...)
if((GetIsDM(oPC)) || (GetIsDMPossessed(oPC)))
{
//NOTE: This is a NWNX2 RESET ONLY!
if(GetStringLowerCase(GetStringLeft(sChat, 10))=="!dmdoreset" )
{
//Set time to 3 minutes till restart!
SetLocalInt(GetModule(), "MODULE_BEAT", nTime);
SendMsgToAllPCs(s);
AssignCommand(oServer, ActionSpeakString(s, TALKVOLUME_SHOUT));
DelayCommand(1.0, SendMsgToAllPCs(s));
DelayCommand(1.1, ActionSpeakString(s, TALKVOLUME_SHOUT));
}
//Keep pesky PC's off of you :)
else if(GetStringLowerCase(GetStringLeft(sChat, 6))=="!dmgod")
{
eVis = EffectVisualEffect(VFX_DUR_AURA_PULSE_RED_YELLOW);
eEffect = EffectDamageShield(50, DAMAGE_BONUS_1d12, DAMAGE_TYPE_POSITIVE);
eEffect = SupernaturalEffect(eEffect);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oPC, 360.0f);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oPC, 360.0f);
}
//Kill all PC's on the module...
//Keep pesky PC's off of you :)
else if(GetStringLowerCase(GetStringLeft(sChat, 8))=="!killall")
{
DoTheDew();
}
else if(GetStringLowerCase(GetStringLeft(sChat, 8))=="!bootall")
{
object oU = GetFirstPC();
while(GetIsObjectValid(oU))
{
if(!GetIsDM(oU) && !GetIsDMPossessed(oU))
BootPC(oU);
oU = GetNextPC();
}
}
else if(GetStringLowerCase(GetStringLeft(sChat, 9))=="!blackout" )
{
object oObject = GetFirstPC();
while(GetIsObjectValid(oObject))
{
if(!GetIsDM(oPC) && !GetIsDMPossessed(oPC))
{
FadeToBlack(oObject, FADE_SPEED_FAST);
DelayCommand(30.0, FadeFromBlack(oObject, FADE_SPEED_SLOW));
}
oObject = GetNextPC();
}
}
}
///////////////////////////////////////////////////////////////////////////////
//Handle Jail...
//The PC Cannot use any channel other than tell
//and their message only reads I have been a very bad person..
if(GetLocalInt(GetArea(oPC), "JAIL")==1)
{
SetPCChatVolume(TALKVOLUME_TALK);
SetPCChatMessage("My voice, eek!");
return;
}
//////////////////////////////////////////////////////////////////////////////
if(GetItemPossessedBy(GetPCChatSpeaker(), "napper") != OBJECT_INVALID)
{
SetPCChatVolume(TALKVOLUME_TALK);
SetPCChatMessage(" ");
return;
}
///////////////////////////////////////////////////////////////////////////////
//HANDLE PLAYER EMOTES & COMMANDS
if(GetStringLeft(GetPCChatMessage(), 1)=="*")
{
HandleEmotes(oPC, sChat, nVolume);
}
else if(GetStringLeft(GetPCChatMessage(),1)=="@")
{
HandleAppearanceSet(oEPC, GetPCChatMessage());
}
else if(GetStringLeft(GetPCChatMessage(),1)=="!")
{
//Handle Reset Delay
if(GetStringLeft(GetStringLowerCase(GetPCChatMessage()), 11)=="!delayreset" &&
nDelayCheck !=1 && nDelayPC !=1 && nResetTime !=1 && nStopDelays !=2)
{
nDelay+=1;
nCount+=1;
//Set Variables on the module to know if we can do a delay or not..
SetLocalInt(GetModule(), "RESET_DELAY", nDelay);
SetLocalInt(GetModule(), "RESET_VOTE", nCount);
SetLocalInt(oEPC, "DELAYED_RESET", 1);
WriteTimestampedLogEntry("*******A Player Has Voted On Reset Delay**********");
SendMessageToAllDMs("A player has voted for a reset delay.");
//Not needed..
//SendMsgToAllPCs(IntToString(nCount) + " # of players have voted for a reset");
//Send message to PCs about the delay...
DelayCommand(2.0, DoResetCheck());
}
else
{
HandleCommands(oPC);
}
//Handle Reset end..
}
else if(GetStringLeft(GetPCChatMessage(),1)=="%")
{
int nPortID = StringToInt(GetSubString(sEText, 1, 4));
SetPortraitId(oEPC, nPortID);
SetPCChatMessage("");
//No need to continue (save lag!)
return;
}
else
{
//Do nothing...
}
/////////////////////////////////////////////////////////////////////////
//CHAT EMOTES FILTER.. (Make the PC's chat silent if using any commands)
if(nGetSilence(sChat)==1)
{
SetPCChatMessage("");
//No need to continue (save lag!)
return;
}
/////////////////////////////////////////////////////////////////////////
//Chat Logging
//Note we filter out emotes...
WriteTimestampedLogEntry("..............///***CHAT***/// - " + sName + " /// - " + GetPCChatMessage());
//If it's a DM Speaking (Tested it works! Yay!)
if(GetIsDM(oPC) || GetIsDMPossessed(oPC))
{
//If the DM has targeted a NPC or Monster..
if(GetLocalInt(oPC, "DM_NPC_CHAT")==1)
{
MakeTargetSpeak(sChat, oPC);
SetPCChatMessage("");
}
//Send a message to All PCs in the DM's Current Area ONLY.
else if(GetLocalInt(oPC, "DM_AREA_MSG")==1)
{
oParty = GetFirstObjectInArea(oArea);
while(GetIsObjectValid(oParty))
{
if(GetIsPC(oParty))
{
FloatingTextStringOnCreature(sChat, oParty, TRUE);
}
//Get the next PC in the area..
oParty = GetNextObjectInArea(oArea);
}
}
//This needs to be tested, otherwise, we may have a problem!
else if(GetLocalInt(oPC, "DM_SERVER_MSG")==1)
{
SendServerMessage(sChat);
}
else if(GetLocalInt(oPC, "DM_SERVER_MSG")==2)
{
//Once every min for 3 minutes..
SendServerMessage(sChat);
DelayCommand(60.0, SendServerMessage(sChat));
DelayCommand(120.0, SendServerMessage(sChat));
DelayCommand(180.0, SendServerMessage(sChat));
}
else if(GetLocalInt(oPC, "DM_SERVER_MSG")==3)
{
//Once every minute for 5 minutes
SendServerMessage(sChat);
DelayCommand(60.0, SendServerMessage(sChat));
DelayCommand(120.0, SendServerMessage(sChat));
DelayCommand(180.0, SendServerMessage(sChat));
DelayCommand(240.0, SendServerMessage(sChat));
DelayCommand(300.0, SendServerMessage(sChat));
}
else if(GetLocalInt(oPC, "DM_SERVER_MSG")==4)
{
//Once every minute for 10 minutes
SendServerMessage(sChat);
DelayCommand(60.0, SendServerMessage(sChat));
DelayCommand(120.0, SendServerMessage(sChat));
DelayCommand(180.0, SendServerMessage(sChat));
DelayCommand(240.0, SendServerMessage(sChat));
DelayCommand(300.0, SendServerMessage(sChat));
DelayCommand(360.0, SendServerMessage(sChat));
DelayCommand(420.0, SendServerMessage(sChat));
DelayCommand(480.0, SendServerMessage(sChat));
DelayCommand(540.0, SendServerMessage(sChat));
DelayCommand(600.0, SendServerMessage(sChat));
}
else if(GetLocalInt(oPC, "DM_SERVER_MSG")==5)
{
//Once every 3 minutes for 15 minutes..
SendServerMessage(sChat);
DelayCommand(180.0, SendServerMessage(sChat));
DelayCommand(360.0, SendServerMessage(sChat));
DelayCommand(540.0, SendServerMessage(sChat));
DelayCommand(720.0, SendServerMessage(sChat));
DelayCommand(900.0, SendServerMessage(sChat));
}
else if(GetLocalInt(oPC, "DM_SERVER_MSG")==6)
{
//Once every 5 minutes for 30 minutes..
SendServerMessage(sChat);
DelayCommand(300.0, SendServerMessage(sChat));
DelayCommand(600.0, SendServerMessage(sChat));
DelayCommand(900.0, SendServerMessage(sChat));
DelayCommand(1200.0, SendServerMessage(sChat));
DelayCommand(1500.0, SendServerMessage(sChat));
DelayCommand(1800.0, SendServerMessage(sChat));
}
else if(GetLocalInt(oPC, "DM_SERVER_MSG")==7)
{
//Once every 5 minutes for an Hour
SendServerMessage(sChat);
DelayCommand(300.0, SendServerMessage(sChat));
DelayCommand(600.0, SendServerMessage(sChat));
DelayCommand(900.0, SendServerMessage(sChat));
DelayCommand(1200.0, SendServerMessage(sChat));
DelayCommand(1500.0, SendServerMessage(sChat));
DelayCommand(1800.0, SendServerMessage(sChat));
DelayCommand(2100.0, SendServerMessage(sChat));
DelayCommand(2400.0, SendServerMessage(sChat));
DelayCommand(2700.0, SendServerMessage(sChat));
DelayCommand(3000.0, SendServerMessage(sChat));
DelayCommand(3300.0, SendServerMessage(sChat));
DelayCommand(3600.0, SendServerMessage(sChat));
}
else if(GetLocalInt(oPC, "DM_SERVER_MSG")==8)
{
//Once every 10 minutes for an Hour
SendServerMessage(sChat);
DelayCommand(600.0, SendServerMessage(sChat));
DelayCommand(1200.0, SendServerMessage(sChat));
DelayCommand(1800.0, SendServerMessage(sChat));
DelayCommand(2400.0, SendServerMessage(sChat));
DelayCommand(3000.0, SendServerMessage(sChat));
DelayCommand(3600.0, SendServerMessage(sChat));
}
else if(GetLocalInt(oPC, "DM_SERVER_MSG")==9)
{
//Once every 30 minutes for 3 hours...
SendServerMessage(sChat);
DelayCommand(1800.0, SendServerMessage(sChat));
DelayCommand(3600.0, SendServerMessage(sChat));
DelayCommand(5400.0, SendServerMessage(sChat));
DelayCommand(7200.0, SendServerMessage(sChat));
DelayCommand(9000.0, SendServerMessage(sChat));
DelayCommand(10800.0, SendServerMessage(sChat));
}
//DM Message Sending End..
}
//If it's not a PC talking stop the script here!
//This coding is to prevent others from running this section.
if(!GetIsPC(oPC) || GetIsDM(oPC) || GetIsDMPossessed(oPC))
{
//Stop the script here!
return;
}
//If the player is not wishing to use color anymore..
if(GetLocalInt(oPC, "CHAT_OFF") == 1)
{return;}
//IF The DM is overriding the colors..
if(GetLocalInt(GetModule(), "PARTY_COLOR_OVERRIDE") !=0)
{
if(nVolume==TALKVOLUME_PARTY)
{
if(GetLocalInt(GetModule(), "PARTY_COLOR_OVERRIDE")==20) //Chaotic Text by Sadju
{
SetPCChatMessage(ChaoticText(sChat));
return;
}
else
{
SetColorMessage(GetModule(), sChat, "PARTY_COLOR_OVERRIDE", 1);
return;
}
}
}
//If the DM Is overriding the colors..
if(GetLocalInt(GetModule(), "TALK_COLOR_OVERRIDE") !=0)
{
if(nVolume==TALKVOLUME_TALK)
{
if(GetLocalInt(GetModule(), "TALK_COLOR_OVERRIDE")==20) //Chaotic Text by Sadju
{
SetPCChatMessage(ChaoticText(sChat));
return;
}
else
{
SetColorMessage(GetModule(), sChat, "TALK_COLOR_OVERRIDE", 2);
return;
}
}
}
//If the DM Is overriding the colors..
if(GetLocalInt(GetModule(), "SHOUT_COLOR_OVERRIDE") !=0)
{
if(nVolume==TALKVOLUME_SHOUT)
{
if(GetLocalInt(GetModule(), "SHOUT_COLOR_OVERRIDE")==20) //Chaotic Text by Sadju
{
SetPCChatMessage(ChaoticText(sChat));
return;
}
else
{
SetColorMessage(GetModule(), sChat, "SHOUT_COLOR_OVERRIDE", 3);
return;
}
}
}
//If colors have been OKed by the Server Admin..
if(GetLocalInt(GetModule(), "COLORS_OK")==1)
{
//We will only do this for party & talk channels!
if(nVolume == TALKVOLUME_PARTY || nVolume == TALKVOLUME_TALK)
{
if(GetLocalInt(oPC, "CHAT_COLOR")==20) //Chaotic Text by Sadju
{
SetPCChatMessage(ChaoticText(sChat));
return;
}
else
{
SetColorMessage(oPC, sChat, "CHAT_COLOR", 4);
return;
}
}
}
//This only applies to players!
if(GetIsPC(oPC) && !GetIsDM(oPC) && !GetIsDMPossessed(oPC))
{
//If the Player is using the DM channel..
if(nVolume == TALKVOLUME_PARTY)
{
//If the DM Channel is turned off for players..
if(GetLocalInt(GetModule(), "BANN_PARTY_CHANNEL")==1)
{
//Turn their channel to talk..
SetPCChatVolume(TALKVOLUME_TALK);
//Tell the PC the DMs are not recieving messages..
SetPCChatMessage("The DM has turned off Party Chat temporarialy.");
}
}
//If the Player is using the DM channel..
if(nVolume == TALKVOLUME_SILENT_SHOUT)
{
//If the DM Channel is turned off for players..
if(GetLocalInt(GetModule(), "BANN_DM_CHANNEL")==1)
{
//Turn their channel to talk..
SetPCChatVolume(TALKVOLUME_TALK);
//Tell the PC the DMs are not recieving messages..
SetPCChatMessage("The DM has turned off DM tells temporarialy.");
}
}
//If the player is shouting...
if(nVolume == TALKVOLUME_SHOUT)
{
//If the DM has turned off Shouting COMPLETELY!
if(GetLocalInt(GetModule(), "BANN_SHOUTING")==1)
{
//All shout messages are converted to talk messages..
SetPCChatVolume(TALKVOLUME_TALK);
SetPCChatMessage("Shouting has been disallowed by the DM temporarily.");
}
//Otherwise just check to see if the PC Shouting is banned..
else
{
//Let's see if we are suppose to use the database
//to control shouting or a local variable..
if(GetLocalInt(GetModule(), "PERSISTENT_CHAT")==1)
{
//For Campaign Database Variables.. (Persistent Banning)
//If the player has been banned from shouting..
if(GetLocalInt(oToken, "SHOUT_BANN")==1)
{
SetPCChatVolume(TALKVOLUME_TALK);
//Inform the PC of their bann from shouting..
SetPCChatMessage(GetName(oPC) + " has been banned from shout.");
}
}
//Otherwise use local variables..
else
{
//For local variables..
if(GetLocalInt(oPC, "SHOUT_BANN")==1)
{
SetPCChatVolume(TALKVOLUME_TALK);
SetPCChatMessage(GetName(oPC) + " has been temporarily banned from shouting.");
}
}
//End Else Statment
}
//End If Shout Statement
}
//End If It's a Player Statement
}
//Main Script End..
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//PROTOTYPES DECLARED//////////////
//PROROTYPE DEFINED
string ColorString(string sText, int nRed=255, int nGreen=255, int nBlue=255)
{
return "<c" + GetSubString(sC, nRed, 1) + GetSubString(sC, nGreen, 1) + GetSubString(sC, nBlue, 1) + ">" + sText + "</c>";
//Prototype end
}
//PROTOTYPE DEFINED
void SendServerMessage(string sString)
{
object oParty;
object oServer = GetObjectByTag("server_msg");
AssignCommand(oServer, ActionSpeakString(sString, TALKVOLUME_SHOUT));
oParty = GetFirstPC();
while(GetIsObjectValid(oParty))
{
FloatingTextStringOnCreature(sString, oParty, TRUE);
oParty = GetNextPC();
}
//Prototype end..
}
void MakeTargetSpeak
(string sString, object oDM)
{
object oTarget;
object oArea = GetArea(oDM);
oTarget = GetFirstObjectInArea(oArea);
while(GetIsObjectValid(oTarget))
{
if(GetLocalInt(oTarget, "DM_CHAT")==1)
{
AssignCommand(oTarget, ActionSpeakString(sString, TALKVOLUME_TALK));
}
oTarget = GetNextObjectInArea(oArea);
}
SetPCChatMessage("");
}
////////////////////////////////////////////////////////////////////
void SetColorMessage
(object oObject, string sChat, string sColor, int nWhich)
{
int a; int b; int c;
if(GetLocalInt(oObject, sColor)==1) //Red - (Bright)
SetPCChatMessage(ColorString(sChat, 255, 60, 0));
else if(GetLocalInt(oObject, sColor)==2) //Aqua Marine
SetPCChatMessage(ColorString(sChat, 127, 255, 212));
else if(GetLocalInt(oObject, sColor)==3) //Magenta
SetPCChatMessage(ColorString(sChat, 255, 129, 255));
else if(GetLocalInt(oObject, sColor)==4)//Purple
SetPCChatMessage(ColorString(sChat, 210, 108, 205));
else if(GetLocalInt(oObject, sColor)==5) //Pink
SetPCChatMessage(ColorString(sChat, 255, 152, 185));
else if(GetLocalInt(oObject, sColor)==6) //Olive
SetPCChatMessage(ColorString(sChat, 139, 182, 96));
else if(GetLocalInt(oObject, sColor)==7)//Peach
SetPCChatMessage(ColorString(sChat, 255, 182, 120));
else if(GetLocalInt(oObject, sColor)==8) //Light Grey
SetPCChatMessage(ColorString(sChat, 192, 192, 192));
else if(GetLocalInt(oObject, sColor)==9) //Gold
SetPCChatMessage(ColorString(sChat, 245, 195, 0));
else if(GetLocalInt(oObject, sColor)==10) //Cyan
SetPCChatMessage(ColorString(sChat, 0, 255, 255));
else if(GetLocalInt(oObject, sColor)==11) //Orange
SetPCChatMessage(ColorString(sChat, 255, 165, 0));
else if(GetLocalInt(oObject, sColor)==12) //Sky Blue
SetPCChatMessage(ColorString(sChat, 0, 191, 255));
else if(GetLocalInt(oObject, sColor)==13) //Lavender
SetPCChatMessage(ColorString(sChat, 213, 190, 248));
else if(GetLocalInt(oObject, sColor)==14) //Tan
SetPCChatMessage(ColorString(sChat, 255, 218, 185));
else if(GetLocalInt(oObject, sColor)==15) //Random Color
{
if(nWhich==1)
{
a = GetLocalInt(oObject, "PRANDOM_COLOR_1");
b = GetLocalInt(oObject, "PRANDOM_COLOR_2");
c = GetLocalInt(oObject, "PRANDOM_COLOR_3");
}
else if(nWhich==2)
{
a = GetLocalInt(oObject, "TRANDOM_COLOR_1");
b = GetLocalInt(oObject, "TRANDOM_COLOR_2");
c = GetLocalInt(oObject, "TRANDOM_COLOR_3");
}
else if(nWhich==3)
{
a = GetLocalInt(oObject, "SANDOM_COLOR_1");
b = GetLocalInt(oObject, "SANDOM_COLOR_2");
c = GetLocalInt(oObject, "SANDOM_COLOR_3");
}
else
{
a = GetLocalInt(oObject, "RANDOM_COLOR_1");
b = GetLocalInt(oObject, "RANDOM_COLOR_2");
c = GetLocalInt(oObject, "RANDOM_COLOR_3");
}
SetPCChatMessage(ColorString(sChat, a, b, c));
}
//More Colors Added!
else if(GetLocalInt(oObject, sColor)==16) //Light Green
SetPCChatMessage(ColorString(sChat, 144, 238, 144));
else if(GetLocalInt(oObject, sColor)==17) //Icy Blue
SetPCChatMessage(ColorString(sChat, 190, 235, 255));
else if(GetLocalInt(oObject, sColor)==18) //Deep Blue Sea
SetPCChatMessage(ColorString(sChat, 0, 110, 255));
else if(GetLocalInt(oObject, sColor)==19) //Dark Cyan
SetPCChatMessage(ColorString(sChat, 0, 195, 197));
else
{} //Do nothing!
//PROTOTYPE END
}
////////////////////////////////////////////////////////////////////////