Author Topic: Alert All DMs Online..  (Read 356 times)

Legacy_The Dragonator

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Alert All DMs Online..
« on: August 24, 2013, 04:01:19 am »


               Heya'. I'm trying to go about making my OnPlayerChat script to send a message (sString) to the DM if they have a campaign int of "enablemessages", sName set to true. I would like to do this to all DMs online. How would I go about doing that? Thanks. '<img'>

Current Code:

void main()
{
object oPC = GetPCChatSpeaker();
object oFamiliar = GetAssociate(ASSOCIATE_TYPE_FAMILIAR, oPC);

string sChat  = GetPCChatMessage();
SetLocalString(oPC, "message", sChat);

int nLength = GetStringLength(sChat);

string sSpoke = GetLocalString(oPC, "message");
string sSend;
string sTalk  = GetStringRight(sSpoke, nLength - 2);

string sRed   = "<cþ  >";
string sClear = "</c>";
string sBlack = "<c   >";

string sEmotes   = "-EmoteList";
string sDate     = "-Date";
string sSave     = "-Save";
string sFamiliar = "-Familiar";

if (GetIsDM(oPC))
{
  sSend =sRed + sEmotes + sDate + sSave + sFamiliar;
}

else
{
 sSend =sRed + sEmotes + sDate + sSave + sFamiliar;
}
if (GetStringLowerCase(sChat) == "-help")
{
 SetPCChatMessage("");
 SendMessageToPC(oPC, sSend);
}

if (GetStringLowerCase(sChat) == "-")
{
 SetPCChatMessage("");
 SendMessageToPC(oPC, sSend);
}

if (GetStringLowerCase(sChat) == "-save")
{
 SetPCChatMessage("");
 ExportSingleCharacter(oPC);
 SendMessageToPC(oPC, sRed + "Your character has been saved.");
}
}
               
               

               


                     Modifié par The Dragonator, 24 août 2013 - 03:07 .
                     
                  


            

Legacy_BelowTheBelt

  • Hero Member
  • *****
  • Posts: 699
  • Karma: +0/-0
Alert All DMs Online..
« Reply #1 on: August 24, 2013, 04:09:57 am »


               Once you know what message to send, loop through all PCs in the module and if the PC is a DM or DM Possessed, send them the string. You could even set something up such that DMs have their CD keys recorded in your code and check by that. The advantage of that way is that even if the DM was logged-on as a player, he/she would still get the message.

A simple loop could look like:

object oDM = GetFirstPC();
while (oDM != OBJECT_INVALID)
{
if (GetIsDM(oDM) || GetIsDMPossessed(oDM))
{
SendMessageToPC(oDM, sString);
}
oDM = GetNextPC();
}

In the more complete version, rather than checking to see if the PC is a DM, you would check the player's CD key. If it matched with one in a central DM list, then send the message.
               
               

               


                     Modifié par BelowTheBelt, 24 août 2013 - 03:12 .
                     
                  


            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
Alert All DMs Online..
« Reply #2 on: August 24, 2013, 04:31:30 am »


               Why not use SendMessageToAllDMs?
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Alert All DMs Online..
« Reply #3 on: August 24, 2013, 04:42:48 am »


               

Squatting Monk wrote...

Why not use SendMessageToAllDMs?



The Dragonator wrote...

Heya'. I'm trying to go about making my OnPlayerChat script to send a message (sString) to the DM if they have a campaign int of "enablemessages", sName set to true. I would like to do this to all DMs online. How would I go about doing that? Thanks. '<img'>


               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
Alert All DMs Online..
« Reply #4 on: August 24, 2013, 04:50:05 am »


               Ah. For some reason, I was reading that as the players having the int set on them. That makes more sense.