summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnnieRuru <jeankof@ymail.com>2014-09-03 08:40:58 +0800
committerAnnieRuru <jeankof@ymail.com>2014-09-03 08:40:58 +0800
commitc84363d21866adb6d0fc994c0f44cc3fdce87350 (patch)
tree9936c37e5ea4c0139c20c3ab61c0be2aa8dfa081
parentfa6d3eb080a69ba5b0ee5d73ddfdf67ccf9018a6 (diff)
downloadhercules-c84363d21866adb6d0fc994c0f44cc3fdce87350.tar.gz
hercules-c84363d21866adb6d0fc994c0f44cc3fdce87350.tar.bz2
hercules-c84363d21866adb6d0fc994c0f44cc3fdce87350.tar.xz
hercules-c84363d21866adb6d0fc994c0f44cc3fdce87350.zip
Add *getguildmember script command
its so frustrating that rathena already having this for month, but we don't have =/ https://github.com/rathena/rathena/commit/eba1539
-rw-r--r--doc/script_commands.txt32
-rw-r--r--src/map/script.c44
2 files changed, 76 insertions, 0 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index 3a65c86dd..2d92779ec 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -3354,6 +3354,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
//=====================================
diff --git a/src/map/script.c b/src/map/script.c
index 2c893219c..cbea20e55 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -7407,6 +7407,49 @@ BUILDIN(getguildmasterid)
}
/*==========================================
+ * 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 :
* 0 : char_name
@@ -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"),