Skip to content

Commit

Permalink
Add *getguildmember script command
Browse files Browse the repository at this point in the history
its so frustrating that rathena already having this for month, but we don't have =/
rathena/rathena@eba1539
  • Loading branch information
AnnieRuru committed Sep 3, 2014
1 parent fa6d3eb commit c84363d
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
32 changes: 32 additions & 0 deletions doc/script_commands.txt
Expand Up @@ -3353,6 +3353,38 @@ Example:

mes "You have "+getmapguildusers("prontera",getcharid(2))+" guild members in Prontera.";

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

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

This command will find all members of a specified guild and 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'.

---------------------------------------
//=====================================
2.2 - End of Guild-Related Commands
Expand Down
44 changes: 44 additions & 0 deletions src/map/script.c
Expand Up @@ -7406,6 +7406,49 @@ BUILDIN(getguildmasterid)
return true;
}

/*==========================================
* Get the information of the members of a guild by type.
* getguildmember <guild_id>{,<type>};
* @param guild_id: ID of guild
* @param type:
* 0 : name (default)
* 1 : character ID
* 2 : account ID
*------------------------------------------*/
BUILDIN(getguildmember)
{
struct guild *g = NULL;
int j = 0;

g = guild->search(script_getnum(st,2));

if (g) {
int i, type = 0;

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

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

/*==========================================
* Get char string information by type :
* Return by @type :
Expand Down Expand Up @@ -18800,6 +18843,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(getguildname,"i"),
BUILDIN_DEF(getguildmaster,"i"),
BUILDIN_DEF(getguildmasterid,"i"),
BUILDIN_DEF(getguildmember,"i?"),
BUILDIN_DEF(strcharinfo,"i"),
BUILDIN_DEF(strnpcinfo,"i"),
BUILDIN_DEF(getequipid,"i"),
Expand Down

0 comments on commit c84363d

Please sign in to comment.