PDA

View Full Version : GMSay for quests


Secrets
08-06-2009, 04:09 PM
Here it is. Requested by Trevius, it sends a message to GMSay in a quest command.


Use:

gmsay("string");

Output:

Zserver GMSAYS, 'string'

Diff:

Index: parser.cpp
================================================== =================
--- parser.cpp (revision 890)
+++ parser.cpp (working copy)
@@ -837,6 +837,9 @@
else if (!strcmp(command,"shout2")) {
quest_manager.shout2(parms.c_str());
}
+ else if (!strcmp(command,"gmsay")) {
+ quest_manager.shout2(parms.c_str());
+ }
else if (!strcmp(command,"shout")) {
quest_manager.shout(parms.c_str());
}
Index: perlparser.cpp
================================================== =================
--- perlparser.cpp (revision 890)
+++ perlparser.cpp (working copy)
@@ -533,6 +533,19 @@
XSRETURN_EMPTY;
}

+XS(XS__gmsay)
+{
+ dXSARGS;
+ if (items != 1)
+ Perl_croak(aTHX_ "Usage: gmsay(str)");
+
+ char * str = (char *)SvPV_nolen(ST(0));
+
+ quest_manager.gmsay(str);
+
+ XSRETURN_EMPTY;
+}
+
XS(XS__depop);
XS(XS__depop)
{
@@ -2802,6 +2815,7 @@
newXS(strcpy(buf, "emote"), XS__emote, file);
newXS(strcpy(buf, "shout"), XS__shout, file);
newXS(strcpy(buf, "shout2"), XS__shout2, file);
+ newXS(strcpy(buf, "gmsay"), XS__gmsay, file);
newXS(strcpy(buf, "depop"), XS__depop, file);
newXS(strcpy(buf, "settarget"), XS__settarget, file);
newXS(strcpy(buf, "follow"), XS__follow, file);
Index: questmgr.cpp
================================================== =================
--- questmgr.cpp (revision 890)
+++ questmgr.cpp (working copy)
@@ -388,6 +388,10 @@
worldserver.SendEmoteMessage(0,0,0,13, "%s shouts, '%s'", owner->GetCleanName(), str);
}

+void QuestManager::gmsay(const char *str) {
+ worldserver.SendChannelMessage(0,0,11,0, 0, "%s", str);
+}
+
void QuestManager::depop(int npc_type) {
if(!owner->IsNPC())
return;
Index: questmgr.h
================================================== =================
--- questmgr.h (revision 890)
+++ questmgr.h (working copy)
@@ -62,6 +62,7 @@
void emote(const char *str);
void shout(const char *str);
void shout2(const char *str);
+ void gmsay(const char *str);
void depop(int npc_type = 0);
void depopall(int npc_type = 0);
void depopzone(bool StartSpawnTimer = true);

trevius
08-06-2009, 05:56 PM
Simple and sweet. Thanks, Secrets!

pfyon
08-06-2009, 07:30 PM
Ultimately, wouldn't it make more sense to have a generic quest::msgchannel() (or the like) that could send a message to any channel id instead of hardcoding it for gm speak?

Secrets
08-06-2009, 09:33 PM
Ultimately, wouldn't it make more sense to have a generic quest::msgchannel() (or the like) that could send a message to any channel id instead of hardcoding it for gm speak?

Probably. I don't see the purpose of it, though, as most of the other channels can be messaged with worldemote.