summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/emap/init.c2
-rw-r--r--src/emap/script_buildins.c72
-rw-r--r--src/emap/script_buildins.h2
3 files changed, 76 insertions, 0 deletions
diff --git a/src/emap/init.c b/src/emap/init.c
index d4e8d11..9f02b41 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -213,6 +213,8 @@ HPExport void plugin_init (void)
addScriptCommand("getitemoptionparambyindex", "ii", getItemOptionParamByIndex);
addScriptCommand("setitemoptionbyindex", "iii*", setItemOptionByIndex);
addScriptCommand("isinstance", "i", isInstance);
+ addScriptCommand("getguildinfo","i",getguildinfo);
+ addScriptCommand("getguildmembers","i?",getguildmembers);
do_init_langs();
diff --git a/src/emap/script_buildins.c b/src/emap/script_buildins.c
index c0a7e1b..89d835f 100644
--- a/src/emap/script_buildins.c
+++ b/src/emap/script_buildins.c
@@ -14,7 +14,9 @@
#include "map/achievement.h"
#include "map/chat.h"
#include "map/chrif.h"
+#include "map/guild.h"
#include "map/instance.h"
+#include "map/mapreg.h"
#include "map/npc.h"
#include "map/pc.h"
#include "map/refine.h"
@@ -2348,3 +2350,73 @@ BUILDIN(isInstance)
script_pushint(st, instance->valid(instance_id) ? 1 : 0);
return true;
}
+
+/*==========================================
+ * Return the data of the @guild_id
+ * null if not found
+ *------------------------------------------*/
+BUILDIN(getguildinfo)
+{
+ int guild_id;
+ struct guild* g;
+
+ guild_id = script_getnum(st,2);
+
+ if( ( g = guild->search(guild_id) ) != NULL )
+ {
+ mapreg->setreg(reference_uid(script->add_variable("$@guildinfo_lvl"), guild_id),g->guild_lv);
+ mapreg->setreg(reference_uid(script->add_variable("$@guildinfo_avg"), guild_id),g->average_lv);
+ mapreg->setreg(reference_uid(script->add_variable("$@guildinfo_exp"), guild_id), (int)(g->exp));
+ mapreg->setreg(reference_uid(script->add_variable("$@guildinfo_nxp"), guild_id), (int)(g->next_exp));
+ }
+ else
+ {
+ //script_pushconststr(st,"null");
+ script_pushint(st,0);
+ }
+ 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(getguildmembers)
+{
+ 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_variable("$@guildmemberaid"), j),g->member[i].account_id);
+ break;
+ case 1:
+ mapreg->setreg(reference_uid(script->add_variable("$@guildmembercid"), j), g->member[i].char_id);
+ break;
+ default:
+ mapreg->setregstr(reference_uid(script->add_variable("$@guildmembername$"), j), g->member[i].name);
+ break;
+ }
+ mapreg->setreg(reference_uid(script->add_variable("$@guildmemberpos"), j),g->member[i].position);
+ j++;
+ }
+ }
+ }
+ mapreg->setreg(script->add_variable("$@guildmembercount"), j);
+ return true;
+}
diff --git a/src/emap/script_buildins.h b/src/emap/script_buildins.h
index fab271e..3ef7ec9 100644
--- a/src/emap/script_buildins.h
+++ b/src/emap/script_buildins.h
@@ -99,5 +99,7 @@ BUILDIN(getItemOptionValueByIndex);
BUILDIN(getItemOptionParamByIndex);
BUILDIN(setItemOptionByIndex);
BUILDIN(isInstance);
+BUILDIN(getguildinfo);
+BUILDIN(getguildmembers);
#endif // EVOL_MAP_SCRIPT_BUILDINS