//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" #include "_inc_color_text_" ////////////////////////////////////////////////////////////////////////////// //DELCARE PROTOTYPES & CONSTANTS //From the Hitchiker's Guide to Color (DON"T TOUCH THIS!) const string sC= " ##################$%&'()*+,-./0123456789:;;==?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[[]^_`abcdefghijklmnopqrstuvwxyz{|}~~"; //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; int nRTime; int nTime; int nBC; ////////////////////////////////////////////////////////////////////// //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"); ////////////////////////////////////////////////////////////////////// //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" ) { nRTime = GetLocalInt(GetModule(), "RESET_MIN"); nTime = nRTime - 3; //3 Minutes till restart! nBC = nTime * 60; //Convert Minutes to Seconds (or heartbeats) //Set time to 3 minutes till restart! SetLocalInt(GetModule(), "MODULE_BEAT", nBC); SendMsgToAllPCs("EMERGENCY SERVER RESTART INITIALIZED!"); DelayCommand(1.0, SendMsgToAllPCs("EMERGENCY SERVER RESTART INITIALIZED!")); DelayCommand(2.0, SendMsgToAllPCs("EMERGENCY SERVER RESTART INITIALIZED!")); } //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)) 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("I have been a very bad person."); 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); } //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)) { //Stop the script here! return; } //If it's a DM no need to continue from here on.... if(GetIsDM(oPC) || GetIsDMPossessed(oPC)) { 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 temporarily."); } } //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 temporarily."); } } //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); //Tell the PC shouting is not allowed 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(GetCampaignInt(GetName(GetModule()), "SHOUT_BANN", oPC)==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 "" + sText + ""; //Prototype end } //PROTOTYPE DEFINED void SendServerMessage(string sString) { object oParty; 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)); } oTarget = GetNextObjectInArea(oArea); } } 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 } ////////////////////////////////////////////////////////////////////////