summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormekolat <mekolat@users.noreply.github.com>2017-10-20 15:32:26 -0400
committerGitHub <noreply@github.com>2017-10-20 15:32:26 -0400
commit018f1ffc77c8f690a6a5643365f64794451c9aa9 (patch)
treecb2413045d91d9fcdfad100b019793554c2d18b8
parent6b1fe2d069cb0251bc5798767f97454ab63a47c0 (diff)
parent7bc1b1c09e3c3e7d0c4460803d16dfc01cd56a22 (diff)
downloadhercules-018f1ffc77c8f690a6a5643365f64794451c9aa9.tar.gz
hercules-018f1ffc77c8f690a6a5643365f64794451c9aa9.tar.bz2
hercules-018f1ffc77c8f690a6a5643365f64794451c9aa9.tar.xz
hercules-018f1ffc77c8f690a6a5643365f64794451c9aa9.zip
Merge pull request #1843 from mekolat/logmes2
-rw-r--r--doc/script_commands.txt18
-rw-r--r--src/map/script.c40
2 files changed, 44 insertions, 14 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index 331bed1c7..92fb53445 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -7506,13 +7506,21 @@ window). It will not be displayed anywhere else.
debugmes("\033[38D\033[K ==Message== \n"); // enable colour code.
---------------------------------------
-*logmes("<message>")
+*logmes("<message>"{, <log type>})
-This command will write the message given to the map server NPC log file,
-as specified in 'conf/map/logs.conf'. If SQL logging is enabled, the message
-will go to the 'npclog' table.
+This command will write the message given to the map server log files, as
+specified in 'conf/map/logs.conf'. If SQL logging is enabled, the message will
+go to the specified log table. If logs are not enabled, nothing will happen.
-If logs are not enabled for NPCs, nothing will happen.
+Log types are:
+
+LOGMES_NPC - log to the 'npclog' table (Default)
+LOGMES_ATCOMMAND - log to the 'atcommandlog' table
+
+Example:
+
+ logmes("foobar");
+ logmes("foobar", LOGMES_ATCOMMAND);
---------------------------------------
diff --git a/src/map/script.c b/src/map/script.c
index 367c9927d..da079c082 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -15785,19 +15785,37 @@ BUILDIN(getmapxy)
return true;
}
+enum logmes_type {
+ LOGMES_NPC,
+ LOGMES_ATCOMMAND
+};
+
/*==========================================
- * Allows player to write NPC logs (i.e. Bank NPC, etc) [Lupus]
+ * Allows player to write logs (i.e. Bank NPC, etc) [Lupus]
*------------------------------------------*/
-BUILDIN(logmes)
-{
- const char *str;
+BUILDIN(logmes) {
+ const char *str = script_getstr(st, 2);
struct map_session_data *sd = script->rid2sd(st);
+ enum logmes_type type = LOGMES_NPC;
+ nullpo_retr(sd, false);
- if (sd == NULL)
- return true;
+ if (script_hasdata(st, 3)) {
+ type = script_getnum(st, 3);
+ }
+
+ switch (type) {
+ case LOGMES_ATCOMMAND:
+ logs->atcommand(sd, str);
+ break;
+ case LOGMES_NPC:
+ logs->npc(sd, str);
+ break;
+ default:
+ ShowError("script:logmes: Unknown log type!\n");
+ st->state = END;
+ return false;
+ }
- str = script_getstr(st,2);
- logs->npc(sd,str);
return true;
}
@@ -24070,7 +24088,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(checkoption2,"i?"),
BUILDIN_DEF(guildgetexp,"i"),
BUILDIN_DEF(guildchangegm,"is"),
- BUILDIN_DEF(logmes,"s"), //this command actls as MES but rints info into LOG file either SQL/TXT [Lupus]
+ BUILDIN_DEF(logmes,"s?"), //this command actls as MES but rints info into LOG file either SQL/TXT [Lupus]
BUILDIN_DEF(summon,"si??"), // summons a slave monster [Celest]
BUILDIN_DEF(isnight,""), // check whether it is night time [Celest]
BUILDIN_DEF(isequipped,"i*"), // check whether another item/card has been equipped [Celest]
@@ -24597,6 +24615,10 @@ void script_hardcoded_constants(void)
script->set_constant("DATATYPE_VAR", DATATYPE_VAR, false, false);
script->set_constant("DATATYPE_LABEL", DATATYPE_LABEL, false, false);
+ script->constdb_comment("Logmes types");
+ script->set_constant("LOGMES_NPC", LOGMES_NPC, false, false);
+ script->set_constant("LOGMES_ATCOMMAND", LOGMES_ATCOMMAND, false, false);
+
script->constdb_comment("Item Subtypes (Weapon types)");
script->set_constant("W_FIST", W_FIST, false, false);
script->set_constant("W_DAGGER", W_DAGGER, false, false);