summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLupus <Lupus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2004-12-23 20:20:06 +0000
committerLupus <Lupus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2004-12-23 20:20:06 +0000
commitbe12ec3ffb1632d8f9f7727ae9a17ea137bde375 (patch)
tree821d07f7d405ec9c89010cadac06395ea5ca622b /src
parent3a582ad4976cd2672e22a33cd738346e5e09a9bd (diff)
downloadhercules-be12ec3ffb1632d8f9f7727ae9a17ea137bde375.tar.gz
hercules-be12ec3ffb1632d8f9f7727ae9a17ea137bde375.tar.bz2
hercules-be12ec3ffb1632d8f9f7727ae9a17ea137bde375.tar.xz
hercules-be12ec3ffb1632d8f9f7727ae9a17ea137bde375.zip
Added LOGMES script command
implemented an example: kafra_bank.txt git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@759 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/map/log.c38
-rw-r--r--src/map/log.h7
-rw-r--r--src/map/script.c14
3 files changed, 56 insertions, 3 deletions
diff --git a/src/map/log.c b/src/map/log.c
index be8280b7f..770d6acca 100644
--- a/src/map/log.c
+++ b/src/map/log.c
@@ -340,6 +340,34 @@ int log_atcommand(struct map_session_data *sd, const char *message)
return 0;
}
+int log_npc(struct map_session_data *sd, const char *message)
+{ //[Lupus]
+ FILE *logfp;
+ if(log_config.enable_logs <= 0)
+ return 0;
+ nullpo_retr(0, sd);
+ #ifndef TXT_ONLY
+ if(log_config.sql_logs > 0)
+ {
+ sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`npc_date`, `account_id`, `char_id`, `char_name`, `map`, `mes`) VALUES(NOW(), '%d', '%d', '%s', '%s', '%s') ", log_config.log_npc_db, sd->status.account_id, sd->status.char_id, sd->status.name, sd->mapname, message);
+ if(mysql_query(&mmysql_handle, tmp_sql))
+ printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
+ } else {
+ #endif
+ if((logfp=fopen(log_config.log_npc,"a+")) != NULL) {
+ char timestring[255];
+ time_t curtime;
+ time(&curtime);
+ strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
+ fprintf(logfp,"%s - %s[%d]: %s%s",timestring,sd->status.name,sd->status.account_id,message,RETCODE);
+ fclose(logfp);
+ }
+ #ifndef TXT_ONLY
+ }
+ #endif
+ return 0;
+}
+
int log_config_read(char *cfgName)
{
char line[1024], w1[1024], w2[1024];
@@ -385,6 +413,8 @@ int log_config_read(char *cfgName)
log_config.zeny = (atoi(w2));
} else if(strcmpi(w1,"log_gm") == 0) {
log_config.gm = (atoi(w2));
+ } else if(strcmpi(w1,"log_npc") == 0) {
+ log_config.npc = (atoi(w2));
}
else if(strcmpi(w1, "log_branch_db") == 0) {
@@ -428,6 +458,10 @@ int log_config_read(char *cfgName)
strcpy(log_config.log_gm_db, w2);
if(log_config.gm > 0)
printf("Logging GM Level %d Commands to table `%s`\n", log_config.gm, w2);
+ } else if(strcmpi(w1, "log_npc_db") == 0) {
+ strcpy(log_config.log_npc_db, w2);
+ if(log_config.npc > 0)
+ printf("Logging NPC 'logmes' to table `%s`\n", w2);
}
else if(strcmpi(w1, "log_branch") == 0) {
@@ -471,6 +505,10 @@ int log_config_read(char *cfgName)
strcpy(log_config.log_gm, w2);
if(log_config.gm > 0)
printf("Logging GM Level %d Commands to file `%s`.txt\n", log_config.gm, w2);
+ } else if(strcmpi(w1, "log_npc") == 0) {
+ strcpy(log_config.log_npc, w2);
+ if(log_config.npc > 0)
+ printf("Logging NPC 'logmes' to file `%s`.txt\n", w2);
//support the import command, just like any other config
} else if(strcmpi(w1,"import")==0){
log_config_read(w2);
diff --git a/src/map/log.h b/src/map/log.h
index d4ad0bd66..7130a8f6a 100644
--- a/src/map/log.h
+++ b/src/map/log.h
@@ -19,15 +19,16 @@ int log_trade(struct map_session_data *sd,struct map_session_data *target_sd,int
int log_vend(struct map_session_data *sd,struct map_session_data *vsd,int n,int amount,int zeny);
int log_zeny(struct map_session_data *sd, struct map_session_data *target_sd,int amount);
int log_atcommand(struct map_session_data *sd, const char *message);
+int log_npc(struct map_session_data *sd, const char *message);
int log_config_read(char *cfgName);
extern struct Log_Config {
int enable_logs;
int sql_logs;
- int branch, drop, mvpdrop, present, produce, refine, trade, vend, zeny, gm;
- char log_branch[32], log_drop[32], log_mvpdrop[32], log_present[32], log_produce[32], log_refine[32], log_trade[32], log_vend[32], log_gm[32];
- char log_branch_db[32], log_drop_db[32], log_mvpdrop_db[32], log_present_db[32], log_produce_db[32], log_refine_db[32], log_trade_db[32], log_vend_db[32], log_gm_db[32];
+ int branch, drop, mvpdrop, present, produce, refine, trade, vend, zeny, gm, npc;
+ char log_branch[32], log_drop[32], log_mvpdrop[32], log_present[32], log_produce[32], log_refine[32], log_trade[32], log_vend[32], log_gm[32], log_npc[32];
+ char log_branch_db[32], log_drop_db[32], log_mvpdrop_db[32], log_present_db[32], log_produce_db[32], log_refine_db[32], log_trade_db[32], log_vend_db[32], log_gm_db[32], log_npc_db[32];
} log_config;
#endif
diff --git a/src/map/script.c b/src/map/script.c
index 1bcb118ee..8ffa7d0ea 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -295,6 +295,7 @@ int buildin_checkoption2(struct script_state *st); // [celest]
int buildin_guildgetexp(struct script_state *st); // [celest]
int buildin_skilluseid(struct script_state *st); // originally by Qamera [celest]
int buildin_skillusepos(struct script_state *st); // originally by Qamera [celest]
+int buildin_logmes(struct script_state *st); // [Lupus]
void push_val(struct script_stack *stack,int type,int val);
int run_func(struct script_state *st);
@@ -511,6 +512,7 @@ struct {
{buildin_skilluseid,"skilluseid","ii"}, // originally by Qamera [Celest]
{buildin_skilluseid,"doskill","ii"}, // since a lot of scripts would already use 'doskill'...
{buildin_skillusepos,"skillusepos","iiii"}, // [Celest]
+ {buildin_logmes,"logmes","s"}, //this command actls as MES but prints info into LOG file either SQL/TXT [Lupus]
{NULL,NULL,NULL},
};
int buildin_message(struct script_state *st); // [MouseJstr]
@@ -6347,6 +6349,18 @@ int buildin_skillusepos(struct script_state *st)
return 0;
}
+/*==========================================
+ * Allows player to write NPC logs (i.e. Bank NPC, etc) [Lupus]
+ *------------------------------------------
+ */
+int buildin_logmes(struct script_state *st)
+{
+ if (log_config.npc <= 0 ) return 0;
+ conv_str(st,& (st->stack->stack_data[st->start+2]));
+ log_npc(script_rid2sd(st),st->stack->stack_data[st->start+2].u.str);
+ return 0;
+}
+
//
// ŽÀs•”main
//