Kaynağa Gözat

Added LOGMES script command
implemented an example: kafra_bank.txt

git-svn-id: https://svn.code.sf.net/p/rathena/svn/branches/stable@759 54d463be-8e91-2dee-dedb-b68131a5f0ec

Lupus 20 yıl önce
ebeveyn
işleme
99638c9c8d
6 değiştirilmiş dosya ile 99 ekleme ve 26 silme
  1. 3 2
      npc/Changelog.txt
  2. 27 21
      npc/other/kafra_bank.txt
  3. 13 0
      sql-files/logs.sql
  4. 38 0
      src/map/log.c
  5. 4 3
      src/map/log.h
  6. 14 0
      src/map/script.c

+ 3 - 2
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]

+ 27 - 21
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;
- 
-}
+}
+
+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

+ 13 - 0
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 ;

+ 38 - 0
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);

+ 4 - 3
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

+ 14 - 0
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
 //