//Script Name: dm_chat_control ////////////////////////////////////////// // Created By: Genisys (Guile) // Created On: 9/13/08 ///////////////////////////////////////// /* This tagbased item script allows the DM (Or possibly player, if allowed to) to bann a player from shout, or control chat channels across the whole server.. */ //////////////////////////////////////// #include "x2_inc_switches" //Main Script void main() { //All Major Variables Declared (Commonly used variables as well) int nEvent = GetUserDefinedItemEventNumber(); //Which event triggered this object oPC; //The player character using the item object oItem; //The item being used object oSpellOrigin; //The origin of the spell object oSpellTarget; //The target of the spell int iSpell; //The Spell ID number object oTarget; //Define oTarget below object oObject; //Define oObject below int nInt; //A commonly used intergal (Must be defined) int nLvl; //Commonly used intergal for levels (ie. GetHitDice(oTarget); etc.) string sTag; //Used to define a tagname of something string sResref; //Used to define a resref name of something string sMsg; //Used to define a message effect eEffect; //Used to define an effect to be applied to an object or location effect eVis; //Used to define a visual effect to be applied to an object or location location lTarget; //The Target Location of the PC ONLY! (USE - Getlocation(oPC);) location lway; //The Target location for the Activated Item's Target only! (See below) object oDM; //////////////////////////////////////////////////////////////////////////////////////////////// //Set the return value for the item event script // * X2_EXECUTE_SCRIPT_CONTINUE - continue calling script after executed script is done // * X2_EXECUTE_SCRIPT_END - end calling script after executed script is done int nResult = X2_EXECUTE_SCRIPT_END; /////////////////////////////////////////////////////////////////////////////////////////////// //Deterimine which event has fired for the item... switch (nEvent) { /////////////////////////////////////////////////////////////////////////// /////////////Cast Spell: Unique Power /or/ Activate Item////////////////// //I seperated this cause it's more commonly used.. case X2_ITEM_EVENT_ACTIVATE: { // * This code runs when the Unique Power property of the item is used // * or the item is activated. Note that this event fires for PCs only. oPC = GetItemActivator(); // The player who activated the item oItem = GetItemActivated(); // The item that was activated oTarget = GetItemActivatedTarget(); //The target of the item's power lway = GetItemActivatedTargetLocation(); //To get the location of the target! //////////////////////////////////////////////////////////// //Let's see if the Administrator has allowed PCs to use the item. if(GetLocalInt(GetModule(), "PC_CHAT_CONTROL")!=1) { //If not, then stop the script here if it's not a DM! if (!GetIsDM(oPC) || !GetIsDMPossessed(oPC)) { return; } } //Otherwise allow the PC to use the conversation.. else { //If it's a PC using the item and not a DM.. if(GetIsPC(oPC) && !GetIsDM(oPC) && !GetIsDMPossessed(oPC)) { //Start the DM chat controls with the PC given the wand.. oDM = oPC; AssignCommand(oDM, ActionStartConversation(oPC, "dm_chat_con_conv")); //NOTE: They cannot use ALL of the options of the wand! } } ///////////////////////////////////////////////////////////// //If a DM is using the item.. //Make sure the target is valid! if(GetObjectType(oTarget)==OBJECT_TYPE_INVALID || GetObjectType(oTarget)== OBJECT_TYPE_ITEM || GetObjectType(oTarget)== OBJECT_TYPE_ENCOUNTER || GetObjectType(oTarget)== OBJECT_TYPE_STORE || GetObjectType(oTarget)== OBJECT_TYPE_WAYPOINT || GetObjectType(oTarget)== OBJECT_TYPE_TRIGGER) { FloatingTextStringOnCreature("You must target a creature or object!", oPC, FALSE); return; } //If the DM is targeting an object.. if(GetObjectType(oTarget)!= OBJECT_TYPE_CREATURE) { //Tell the chat script to have the object say what the dm says. SetLocalInt(oTarget, "DM_CHAT", 1); //Start the DM conversation with the DM oDM = oPC; AssignCommand(oDM, ActionStartConversation(oPC, "dm_chat_con_conv")); } //If the DM is targeting a creature that isn't themself or a PC.. else if(!GetIsPC(oTarget) && !GetIsDM(oTarget) && !GetIsDMPossessed(oTarget)) { //Tell the chat script to have the targeted creature speak what the DM says. SetLocalInt(oTarget, "DM_CHAT", 1); //Start the DM conversation with the DM oDM = oPC; AssignCommand(oDM, ActionStartConversation(oPC, "dm_chat_con_conv")); } //If the dm is targeting themself... else if(GetIsDM(oTarget) || GetIsDMPossessed(oTarget)) { //Start the DM conversation with the DM oDM = oPC; AssignCommand(oDM, ActionStartConversation(oPC, "dm_chat_con_conv")); } //If the DM is targeting a PC else if(GetIsPC(oTarget)) { //If the item is set to Bann the target from the Shout Channel if(GetLocalInt(oItem, "DM_CHAT_OPTION")==1) { //Let's check to see if we are suppose to use the database. if(GetLocalInt(GetModule(), "PERSISTENT_CHAT")==1) { //If they have not been banned, bann them now.. if(GetCampaignInt(GetName(GetModule()), "SHOUT_BANN", oTarget)!=1) { SetCampaignInt(GetName(GetModule()), "SHOUT_BANN", 1, oTarget); } //Otherwise bann them from shout (permanently till removed!) else { SetCampaignInt(GetName(GetModule()), "SHOUT_BANN", 0, oTarget); } } //Otherwise use local variables.. else { //If they have not been banned, then bann them from shout //NOTE: This is only till restart! if(GetLocalInt(oTarget, "SHOUT_BANN") !=1) { SetLocalInt(oTarget, "SHOUT_BANN", 1); } //Otherwise allow them to shout again.. else { SetLocalInt(oTarget, "SHOUT_BANN", 0); } } } //Otherwise we are banning them from the DM Channel! else { //Let's check to see if we are suppose to use the database. if(GetLocalInt(GetModule(), "PERSISTENT_CHAT")==1) { //If they have not been banned, bann them now.. if(GetCampaignInt(GetName(GetModule()), "DM_CHAT_BANN", oTarget)!=1) { SetCampaignInt(GetName(GetModule()), "DM_CHAT_BANN", 1, oTarget); } //Otherwise bann them from the DM Channel (permanently till removed!) else { SetCampaignInt(GetName(GetModule()), "DM_CHAT_BANN", 0, oTarget); } } //Otherwise use local variables.. else { //If they have not been banned, then bann them from the DM Channel //NOTE: This is only till restart! if(GetLocalInt(oTarget, "DM_CHAT_BANN") !=1) { SetLocalInt(oTarget, "DM_CHAT_BANN", 1); } //Otherwise allow them to use the DM Channel else { SetLocalInt(oTarget, "DM_CHAT_BANN", 0); } } //Else Statement End } //If Get is PC The Target - IF Statement End } break; } //Switch Statment End } //Pass the return value back to the calling script SetExecutedScriptReturnValue(nResult); //Main Script End }