Added script command 'getguildmember', similar to 'getpartymember'. (tid:78308, credits: AnnieRuru, GodLesZ)

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

Signed-off-by: Euphy <euphy.raliel@rathena.org>
This commit is contained in:
Euphy 2014-02-11 15:12:47 -05:00
parent a2d095f5c4
commit eba153919e
2 changed files with 71 additions and 1 deletions

View File

@ -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.
@ -2902,6 +2902,38 @@ Example:
---------------------------------------
*getguildmember <guild id>{,<type>};
This command will find all members of a specified guildand returns their names
(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

View File

@ -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
@ -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"