Jump to content
  • 0

Picklog db


Yaoi

Question


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  26
  • Reputation:   0
  • Joined:  06/13/14
  • Last Seen:  


 Im trying to add columns in picklog db so ive made these queries:

ALTER TABLE `picklog` ADD `account_id` int( 11 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `char_id`;

ALTER TABLE `picklog` ADD `name` varchar( 30 ) NOT NULL DEFAULT '' AFTER `time`;

 

I already have the tables added in picklog but how do i make it works?, do i have to edit any source, log.cpp or something?

(in picklog i want it shows the char name of the char id and the account id of this char id.)

 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  16
  • Reputation:   7
  • Joined:  06/06/19
  • Last Seen:  

yes edit on your Log.cpp

 

find

Quote

void logpick

edit the query

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  658
  • Reputation:   663
  • Joined:  11/12/12
  • Last Seen:  

Heya,

You'll need to edit log_pick in log.cpp:

void log_pick(int id, int16 m, e_log_pick_type type, int amount, struct item* itm)

Something along those lines:

/// logs item transactions (generic)
void log_pick(int id, int16 m, e_log_pick_type type, int amount, struct item* itm)
{
	nullpo_retv(itm);
	if( ( log_config.enable_logs&type ) == 0 )
	{// disabled
		return;
	}

	if( !should_log_item(itm->nameid, amount, itm->refine) )
		return; //we skip logging this item set - it doesn't meet our logging conditions [Lupus]

	if( log_config.sql_logs )
	{
		int i;
		struct map_session_data *sd = map_charid2sd(id);
		SqlStmt* stmt = SqlStmt_Malloc(logmysql_handle);
		char esc_sname[NAME_LENGTH*2+1];
		StringBuf buf;
		StringBuf_Init(&buf);
		
		if (sd) {
			Sql_EscapeStringLen(logmysql_handle, esc_sname, sd->status.name, strnlen(sd->status.name, NAME_LENGTH));
		}

		StringBuf_Printf(&buf, "%s INTO `%s` (`time`, `char_id`, `account_id`, `name`, `type`, `nameid`, `amount`, `refine`, `map`, `unique_id`, `bound`", LOG_QUERY, log_config.log_pick);
		for (i = 0; i < MAX_SLOTS; ++i)
			StringBuf_Printf(&buf, ", `card%d`", i);
		for (i = 0; i < MAX_ITEM_RDM_OPT; ++i) {
			StringBuf_Printf(&buf, ", `option_id%d`", i);
			StringBuf_Printf(&buf, ", `option_val%d`", i);
			StringBuf_Printf(&buf, ", `option_parm%d`", i);
		}
		StringBuf_Printf(&buf, ") VALUES(NOW(),'%u','%u','%s','%c','%d','%d','%d','%s','%" PRIu64 "','%d'",
			id, sd ? sd->status.account_id : 0, sd ? esc_sname : "", log_picktype2char(type), itm->nameid, amount, itm->refine, map_getmapdata(m)->name[0] ? map_getmapdata(m)->name : "", itm->unique_id, itm->bound);

		for (i = 0; i < MAX_SLOTS; i++)
			StringBuf_Printf(&buf, ",'%d'", itm->card[i]);
		for (i = 0; i < MAX_ITEM_RDM_OPT; i++)
			StringBuf_Printf(&buf, ",'%d','%d','%d'", itm->option[i].id, itm->option[i].value, itm->option[i].param);
		StringBuf_Printf(&buf, ")");

		if (SQL_SUCCESS != SqlStmt_PrepareStr(stmt, StringBuf_Value(&buf)) || SQL_SUCCESS != SqlStmt_Execute(stmt))
			SqlStmt_ShowDebug(stmt);

		SqlStmt_Free(stmt);
		StringBuf_Destroy(&buf);
	}
	else
	{
		char timestring[255];
		time_t curtime;
		FILE* logfp;

		if( ( logfp = fopen(log_config.log_pick, "a") ) == NULL )
			return;
		time(&curtime);
		strftime(timestring, sizeof(timestring), log_timestamp_format, localtime(&curtime));
		fprintf(logfp,"%s - %d\t%c\t%hu,%d,%d,%hu,%hu,%hu,%hu,%s,'%" PRIu64 "',%d\n", timestring, id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], map_getmapdata(m)->name[0]?map_getmapdata(m)->name:"", itm->unique_id, itm->bound);
		fclose(logfp);
	}
}

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  26
  • Reputation:   0
  • Joined:  06/13/14
  • Last Seen:  

Im not good editing source but i will try, if success ill let you know guys, thanks

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...