Jump to content

Question

Posted

I'm trying to put an announcement whenever a GM inputs these following commands
 

  • @item and any of its variants (including #)
  • @monster and any of its variants
  • @killmonster and any of its variants

For instance, @item -> will announce "[ Quality Control ]: <name here> created <name of item>(item id) with the <command used> command"
For @monster -> will announce "[ Quality Control ]: <name here> summoned <name of monsters>(mob id) with the <command used> command in <name of map>"

For #item -> will announce "[ Quality Control ]: <name here> created <name of item>(item id) for <player name> with the <command used> command"

For @killmonster -> will announce "[ Quality Control ]: <name here> has killed all monsters in <name of map>"

 

I can probably do this if someone can provide me a few hints here and there on how to implement it. Thanks and appreciate it!

5 answers to this question

Recommended Posts

  • 0
Posted

i could do it via script, however I do want to learn how to fiddle around with source, and I believe this might be a good area to start.

Also, I have no clue if I can capture a #command via script. Not that I am aware of.

  • 0
Posted (edited)
7 hours ago, Hijirikawa said:

however I do want to learn how to fiddle around with source, and I believe this might be a good area to start.

 src/custom/atcommand.inc     | 24 ++++++++++++++++++++++++
 src/custom/atcommand_def.inc |  2 ++
 2 files changed, 26 insertions(+)

diff --git a/src/custom/atcommand.inc b/src/custom/atcommand.inc
index 9dd4a3856..44d8d7b11 100644
--- a/src/custom/atcommand.inc
+++ b/src/custom/atcommand.inc
@@ -17,3 +17,27 @@
 //	clif_specialeffect(&sd->bl, EF_HEARTCASTING, AREA);
 //	return 0;
 //}
+
+ACMD_FUNC(custom) {
+	intif_broadcast( message, strlen(message) + 1, BC_DEFAULT );
+	return 0;
+}
+
+ACMD_FUNC(custom_item) {
+	char item_name[99];
+	int number = 0;
+	struct item_data *item_data;
+
+	if ( sscanf( message, "\"%99[^\"]\" %11d", item_name, &number) < 1 && sscanf( message, "%99s %11d", item_name, &number ) < 1 ) {
+		clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
+		return -1;
+	}
+	if ( (item_data = itemdb_searchname(item_name)) == NULL && (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
+		clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
+		return -1;
+	}
+
+	safesnprintf( atcmd_output, CHAT_SIZE_MAX, "[ Quality Control ]: %s created %s(%d) with the %s command", sd->status.name, item_data->jname, item_data->nameid, command );
+	intif_broadcast( atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT );
+	return 0;
+}
\ No newline at end of file
diff --git a/src/custom/atcommand_def.inc b/src/custom/atcommand_def.inc
index 54d9e74ba..86acf41da 100644
--- a/src/custom/atcommand_def.inc
+++ b/src/custom/atcommand_def.inc
@@ -9,3 +9,5 @@
  **/
 
 //ACMD_DEF(newcommand),
+ACMD_DEF(custom),
+ACMD_DEF(custom_item),

http://www.cplusplus.com/doc/tutorial/structures/
http://www.cplusplus.com/reference/cstdio/sscanf/
http://www.cplusplus.com/reference/cstdio/sprintf/

screen2019rAthena006.jpg

 

EDIT: apparently rAthena the client has a bug for char-command , the command repeat itself, due to the # symbol

Spoiler

ACMD_FUNC(custom2) {
	int number = 0;
	char item_name[99];
	struct item_data *item_data;

	if ( sscanf( message, "\"%99[^\"]\" %11d", item_name, &number) < 1 && sscanf( message, "%99s %11d", item_name, &number ) < 1 ) {
		clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
		return -1;
	}
	if ( (item_data = itemdb_searchname(item_name)) == NULL && (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
		clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
		return -1;
	}

	if ( command[0] == '@' )
		safesnprintf( atcmd_output, CHAT_SIZE_MAX, "[ Quality Control ]: %s created %s(%d) with the %s command", sd->status.name, item_data->jname, item_data->nameid, command );
	else if ( command[0] == '#' ) {
		char *temp = (char*)aMalloc( strlen( command ) +1 );
		struct map_session_data *ssd;
		struct s_mapiterator* iter = mapit_getallusers();
		for ( ssd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); ssd = (TBL_PC*)mapit_next(iter) )
			if ( ssd->fd == fd )
				break;
		mapit_free(iter);
		safesnprintf( temp, CHAT_SIZE_MAX, "%s", command );
		temp[0] = ' '; // replace this space into '#' and you get the bug, due to the client
		safesnprintf( atcmd_output, CHAT_SIZE_MAX, "[ Quality Control ]: %s created %s(%d) for %s with the %s command", ssd->status.name, item_data->jname, item_data->nameid, sd->status.name, temp );
	}

	intif_broadcast( atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT );
	return 0;
}

 

 

Edited by AnnieRuru
  • Love 1

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...