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

190 lines
5.6 KiB
Plaintext

//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 oToken;
////////////////////////////////////////////////////////////////////////////////////////////////
//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!
oToken = GetItemPossessedBy(oTarget, "idtoken");
if(GetLocalInt(GetModule(), "PC_CHAT_CONTROL")!=1)
{
if (!GetIsDM(oPC) || !GetIsDMPossessed(oPC))
{
return;
}
}
//Make sure they are targeting a creature..
if(GetObjectType(oTarget)!= OBJECT_TYPE_CREATURE)
{
SendMessageToPC(oPC, "You must target a creature!");
return;
}
//If the DM is targeting a player. (Not targeting themself..
if((!GetIsDM(oTarget) || GetIsDMPossessed(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(GetLocalInt(oToken, "SHOUT_BANN")!=1)
{
SetLocalInt(oToken, "SHOUT_BANN", 1);
}
//Otherwise remove bann from shout..
else
{
SetLocalInt(oToken, "SHOUT_BANN", 0);
}
}
//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(GetLocalInt(oToken, "DM_CHAT_BANN")!=1)
{
SetLocalInt(oToken, "DM_CHAT_BANN", 1);
}
//Otherwise remove the bann from the DM channel
else
{
SetLocalInt(oToken, "DM_CHAT_BANN", 0);
}
}
//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
}
//Otherwise start the Chat Conversation with the DM
else
{
oTarget = oPC;
AssignCommand(oTarget, ActionStartConversation(oPC, "dm_chat_con_conv", TRUE));
}
break;
}
//Switch Statment End
}
//Pass the return value back to the calling script
SetExecutedScriptReturnValue(nResult);
//Main Script End
}