Skip to content

Commit

Permalink
Added script command 'getguildmember', similar to 'getpartymember'. (…
Browse files Browse the repository at this point in the history
…tid:78308, credits: AnnieRuru, GodLesZ)

http://rathena.org/board/topic/78308-getguildmember/

Signed-off-by: Euphy <euphy.raliel@rathena.org>
  • Loading branch information
euphyy committed Feb 11, 2014
1 parent a2d095f commit eba1539
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
34 changes: 33 additions & 1 deletion doc/script_commands.txt
Expand Up @@ -3,7 +3,7 @@
//===== By: ==================================================
//= rAthena Dev Team
//===== Last Updated: ========================================
//= 20140210
//= 20140211
//===== Description: =========================================
//= A reference manual for the rAthena scripting language.
//= Commands are sorted depending on their functionality.
Expand Down Expand Up @@ -2902,6 +2902,38 @@ Example:

---------------------------------------

*getguildmember <guild id>{,<type>};

This command will find all members of a specified guildand returns their names

This comment has been minimized.

Copy link
@marky291

marky291 Feb 12, 2014

Contributor

This command will find all the members of a specified guild and return their names

This comment has been minimized.

Copy link
@euphyy

euphyy Feb 12, 2014

Author Contributor

Thanks! ._.

(or character id or account id depending on the value of "type") into an array
of temporary global variables.

Upon executing this,

$@guildmembername$[] is a global temporary string array which contains all the
names of these guild members.
(only set when type is 0 or not specified)

$@guildmembercid[] is a global temporary number array which contains the
character id of these guild members.
(only set when type is 1)

$@guildmemberaid[] is a global temporary number array which contains the
account id of these guild members.
(only set when type is 2)

$@guildmembercount is the number of guild members that were found.

The guild members will be found regardless of whether they are online or offline.
Note that the names come in no particular order.

Be sure to use $@guildmembercount to go through this array, and not
'getarraysize', because it is not cleared between runs of 'getguildmember'.

For usage examples, see 'getpartymember'.

---------------------------------------

*getguildmaster(<guild id>)

This function return the name of the master of the guild which has the specified
Expand Down
38 changes: 38 additions & 0 deletions src/map/script.c
Expand Up @@ -18508,6 +18508,43 @@ BUILDIN_FUNC(disable_command) {
return SCRIPT_CMD_SUCCESS;
}

/** Get the information of the members of a guild by type.
* getguildmember <guild_id>{,<type>};
* @param guild_id: ID of guild
* @param type: Type of option (optional)
*/
BUILDIN_FUNC(getguildmember)
{
int i, j = 0, type = 0;
struct guild *g = NULL;

g = guild_search(script_getnum(st,2));

if (script_hasdata(st,3))
type = script_getnum(st,3);

if (g) {
for (i = 0; i < MAX_GUILD; i++) {
if (g->member[i].account_id) {
switch (type) {
case 2:
mapreg_setreg(reference_uid(add_str("$@guildmemberaid"), j),g->member[i].account_id);
break;
case 1:
mapreg_setreg(reference_uid(add_str("$@guildmembercid"), j), g->member[i].char_id);
break;
default:
mapreg_setregstr(reference_uid(add_str("$@guildmembername$"), j), g->member[i].name);
break;
}
j++;
}
}
}
mapreg_setreg(add_str("$@guildmembercount"), j);
return SCRIPT_CMD_SUCCESS;
}

#include "../custom/script.inc"

// declarations that were supposed to be exported from npc_chat.c
Expand Down Expand Up @@ -19037,6 +19074,7 @@ struct script_function buildin_func[] = {
BUILDIN_DEF(getgroupitem,"i"),
BUILDIN_DEF(enable_command,""),
BUILDIN_DEF(disable_command,""),
BUILDIN_DEF(getguildmember,"i?"),

#include "../custom/script_def.inc"

Expand Down

0 comments on commit eba1539

Please sign in to comment.