To handle this you need to solve the following:
(1) Have a way of knowing whether at least 1 DM is logged in
(2) Capture a message sent to the DM channel
My solution to
(1) would involve incrementing a DM count in the
OnClientEnter event if a DM is logging in and decrementing the count in the
OnClientLeave event if a DM is leaving. DM count would be stored as a local integer on the module.
My solution to
(2) would use the
OnPlayerChat event to intecept chat text sent via the DM channel.
Scripts for (1)Your
OnClientEnter event script includes the following:
void main()
{
object oPC = GetEnteringObject();// The entering object which includes PCs logging in
if(!GetIsObjectValid(oPC)){return;} // Catch exceptions
object oMod = GetModule();
if(GetIsDM(oPC))
{
int nDMCount = GetLocalInt(oMod, "DMS_LOGGEDIN")+1;
SetLocalInt(oMod, "DMS_LOGGEDIN", nDMCount);
}
}
The
OnClientLeave event script includes the following:
void main()
{
object oPC = GetExitingObject(); // The exiting object which includes PCs logging out
if(!GetIsObjectValid(oPC)){return;} // Catch exceptions
object oMod = GetModule();
if(GetIsDM(oPC))
{
int nDMCount = GetLocalInt(oMod, "DMS_LOGGEDIN")-1;
if(nDMCount<0)
nDMCount = 0;
SetLocalInt(oMod, "DMS_LOGGEDIN", nDMCount);
}
}
Script for (2)Your
OnPlayerChatEvent event script includes the following:
void main()
{
object oPC = GetPCChatSpeaker();
if(!GetIsObjectValid(oPC)){return;} // Catch exceptions
int nVolume = GetPCChatVolume();
object oMod = GetModule();
int nDMCount = GetLocalInt(oMod, "DMS_LOGGEDIN");
if( nVolume == TALKVOLUME_SILENT_SHOUT
&& !nDMCount
)
{
SendMessageToPC(oPC, "No DMs are currently logged in to receive your message.");
}
}
Modifié par henesua, 25 septembre 2012 - 03:16 .