summaryrefslogtreecommitdiff
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
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
-rw-r--r--npc/Changelog.txt5
-rw-r--r--npc/other/kafra_bank.txt48
-rw-r--r--sql-files/logs.sql13
-rw-r--r--src/map/log.c38
-rw-r--r--src/map/log.h7
-rw-r--r--src/map/script.c14
6 files changed, 99 insertions, 26 deletions
diff --git a/npc/Changelog.txt b/npc/Changelog.txt
index 0f4015674..636348afb 100644
--- a/npc/Changelog.txt
+++ b/npc/Changelog.txt
@@ -21,8 +21,6 @@ Shinigami
Mass Zero
* Novice Training Ground.
* (Probably unofficial) Lou Yang NPC's, mobs, etc...
-Shadowlady
- * Marriage (Fix, optimization) ?%
MC Cameri
* Bank NPC - Now 100% done for new payon
@@ -36,6 +34,9 @@ Other Ppl
Date Added
======
+12/23
+ * Added logs into kafra_bank.txt (it keeps logs of all bank operations! Very handy to find abusers/cheaters) [Lupus]
+
12/22
* Added Arrow Quivers to the scrolls_arrows.txt and removed some rare arrows from the shop [Lupus]
* Corrected a typo in other/pvp.txt [Ajarn]
diff --git a/npc/other/kafra_bank.txt b/npc/other/kafra_bank.txt
index 8d8bf4fc9..6e6fd8635 100644
--- a/npc/other/kafra_bank.txt
+++ b/npc/other/kafra_bank.txt
@@ -3,7 +3,7 @@
//===== By: ==================================================
//= Lupus (1.0)
//===== Current Version: =====================================
-//= 1.0
+//= 1.1
//===== Compatible With: =====================================
//= eAthena 1.x
//===== Description: =========================================
@@ -13,11 +13,12 @@
// #kafrabank/1000 = 0.1% of interest per day
// #kafrabank/100 = 1% of interest per day
// #kafrabank/10 = 10% of interest per day
+//
+// 1.1 Added log of bank operation -> logmes "some info";
//============================================================
-prontera.gat,131,190,1 script Bank Clerk 112,{
- cutin "kafra_06",2;
- mes"[Manya]";
+prontera.gat,131,190,1 script Bank Clerk 833,{
+ mes"[Maniss]";
mes strcharinfo(0)+", welcome to the 2nd Bank of Prontera!";
set @kb_int,(gettime(6)*31)+gettime(5); //today's number
@@ -29,7 +30,7 @@ L_NoIncomeToday:
set #kb_int,@kb_int; //reset days timer
if(#kafrabank==0) mes "We could open you an account.";
- if(@income>0) mes "Today's income ^135445" + @income + "^000000 zeny.";
+ if(@income>0) mes "Today's income: ^135445" + @income + "^000000 zeny.";
set #kafrabank,#kafrabank+@income;
if(#kafrabank>0) mes "Your account: ^135445" + #kafrabank + "^000000 zeny.";
mes "What would you like?";
@@ -37,58 +38,61 @@ L_NoIncomeToday:
if(#kafrabank==0) menu "-Open a bank account",-,"-Quit",B_EXIT2;
if(#kafrabank>0) menu "-Deposit money",-,"-Withdraw money",M_WITHDRAW,"-Quit",B_EXIT2;
- mes"[Manya]";
+ mes"[Maniss]";
mes "Please, tell me how much zeny you would like to deposit.";
next;
input @kafrabank;
if(@kafrabank<1000) goto L_LESS_1000;
- if(@kafrabank>1000000) goto L_TOO_BIG_AMOUNT;
+ if(@kafrabank>10000000) goto L_TOO_BIG_AMOUNT;
if(@kafrabank>zeny) goto L_NOT_ENOUGH;
set zeny,zeny-@kafrabank;
set #kafrabank,#kafrabank+@kafrabank;
- mes"[Manya]";
+ mes"[Maniss]";
mes "You've made a deposit of ^135445" + @kafrabank + "z^000000.";
-
+//we log these zeny operations into the log db
+ logmes "Bank %: " + @income +"z, Deposit: "+ @kafrabank +"z, Final: "+ #kafrabank +"z";
goto B_EXIT;
M_WITHDRAW:
if(#kafrabank==0) goto L_ZERO_ACCOUNT;
- mes"[Manya]";
+ mes"[Maniss]";
mes "Your account: ^135445" + #kafrabank + "^000000 zeny.";
mes "How much zeny would you like to withdraw?";
next;
input @kafrabank;
if(@kafrabank<1) goto B_EXIT2;
- if(@kafrabank>1000000) goto L_TOO_BIG_AMOUNT;
+ if(@kafrabank>10000000) goto L_TOO_BIG_AMOUNT;
if(@kafrabank>#kafrabank) goto L_NOT_ENOUGH;
set #kafrabank,#kafrabank-@kafrabank;
set zeny,zeny+@kafrabank;
- mes"[Manya]";
+ mes"[Maniss]";
mes "Here is your ^135445" + @kafrabank + "z^000000, put your sign here...";
+//we log these zeny operations into the log db
+ logmes "Bank %: " + @income +"z, Withdraw: "+ @kafrabank +"z, Final: "+ #kafrabank +"z";
goto B_EXIT;
L_NOT_ENOUGH:
- mes"[Manya]";
+ mes"[Maniss]";
mes "You don't have enough zeny for this operation.";
next;
goto B_EXIT2;
L_ZERO_ACCOUNT:
- mes"[Manya]";
+ mes"[Maniss]";
mes "You don't have any zeny on your account!";
next;
goto B_EXIT2;
L_TOO_BIG_AMOUNT:
- mes"[Manya]";
- mes "Sorry. The maximum deposit you can make on a time is 1,000,000 zeny.";
+ mes"[Maniss]";
+ mes "Sorry. The maximum deposit you can make on a time is 10,000,000 zeny.";
next;
goto B_EXIT2;
L_LESS_1000:
- mes"[Manya]";
+ mes"[Maniss]";
mes "We're sorry, the minimum amount of zeny you can deposit is 1,000 zeny.";
next;
goto B_EXIT2;
@@ -98,9 +102,11 @@ B_EXIT:
next;
B_EXIT2:
- mes"[Manya]";
+ mes"[Maniss]";
mes "Thank you for using our Bank Service. We hope to see you again soon.";
- cutin "kafra_06",255;
close;
-
-} \ No newline at end of file
+}
+
+geffen.gat,125,73,3 duplicate(bankg) Bank Clerk#2 833
+izlude.gat,145,107,1 duplicate(bankg) Bank Clerk#3 833
+morocc.gat,147,84,7 duplicate(bankg) Bank Clerk#4 833
diff --git a/sql-files/logs.sql b/sql-files/logs.sql
index 332873648..25a52443b 100644
--- a/sql-files/logs.sql
+++ b/sql-files/logs.sql
@@ -151,4 +151,17 @@ CREATE TABLE `atcommandlog` (
`map` varchar(20) NOT NULL default '',
`command` varchar(50) NOT NULL default '',
PRIMARY KEY (`atcommand_id`)
+) TYPE=MyISAM AUTO_INCREMENT=1 ;
+
+#Database: log
+#Table: npclog
+CREATE TABLE `npclog` (
+ `npc_id` mediumint(9) unsigned NOT NULL auto_increment,
+ `npc_date` datetime NOT NULL default '0000-00-00 00:00:00',
+ `account_id` int(11) unsigned NOT NULL default '0',
+ `char_id` int(11) unsigned NOT NULL default '0',
+ `char_name` varchar(30) NOT NULL default '',
+ `map` varchar(20) NOT NULL default '',
+ `mes` varchar(255) NOT NULL default '',
+ PRIMARY KEY (`npc_id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ; \ No newline at end of file
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
//