summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2019-06-02 23:38:43 +0200
committerGitHub <noreply@github.com>2019-06-02 23:38:43 +0200
commit6772362cf2f0a08502cc7d910ed761d249d0c025 (patch)
tree33c1b15a80f86375b1060b1fb42d8287618d0c81 /src/map
parent000433f782f10f49582b8290b543d7e941e5f7a7 (diff)
parentd9b7fa499ab5ecae677e53d43057671e43b32248 (diff)
downloadhercules-6772362cf2f0a08502cc7d910ed761d249d0c025.tar.gz
hercules-6772362cf2f0a08502cc7d910ed761d249d0c025.tar.bz2
hercules-6772362cf2f0a08502cc7d910ed761d249d0c025.tar.xz
hercules-6772362cf2f0a08502cc7d910ed761d249d0c025.zip
Merge pull request #2290 from bWolfie/getguildonline
Adds buildin_getguildonline.
Diffstat (limited to 'src/map')
-rw-r--r--src/map/script.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 3661e5db6..714ece6e8 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -9043,6 +9043,63 @@ static BUILDIN(getguildmember)
return true;
}
+/**
+ * getguildonline(<Guild ID>{, type})
+ * Returns amount of guild members online.
+**/
+
+enum script_getguildonline_types {
+ GUILD_ONLINE_ALL = 0,
+ GUILD_ONLINE_VENDOR,
+ GUILD_ONLINE_NO_VENDOR
+};
+
+BUILDIN(getguildonline)
+{
+ struct guild *g;
+ int guild_id = script_getnum(st, 2);
+ int type = GUILD_ONLINE_ALL, j = 0;
+
+ if ((g = guild->search(guild_id)) == NULL) {
+ script_pushint(st, -1);
+ return true;
+ }
+
+ if (script_hasdata(st, 3)) {
+ type = script_getnum(st, 3);
+
+ if (type < GUILD_ONLINE_ALL || type > GUILD_ONLINE_NO_VENDOR) {
+ ShowWarning("buildin_getguildonline: Invalid type specified. Defaulting to GUILD_ONLINE_ALL.\n");
+ type = GUILD_ONLINE_ALL;
+ }
+ }
+
+ struct map_session_data *sd;
+ for (int i = 0; i < MAX_GUILD; i++) {
+ if (g->member[i].online && (sd = g->member[i].sd) != NULL) {
+ switch (type) {
+ case GUILD_ONLINE_VENDOR:
+ if (sd->state.vending > 0)
+ j++;
+ break;
+
+ case GUILD_ONLINE_NO_VENDOR:
+ if (sd->state.vending == 0)
+ j++;
+ break;
+
+ default:
+ j++;
+ break;
+ }
+ }
+ }
+
+ script_pushint(st, j);
+
+ return true;
+}
+
/*==========================================
* Get char string information by type :
* Return by @type :
@@ -25625,6 +25682,7 @@ static void script_parse_builtin(void)
BUILDIN_DEF(getguildmaster,"i"),
BUILDIN_DEF(getguildmasterid,"i"),
BUILDIN_DEF(getguildmember,"i?"),
+ BUILDIN_DEF(getguildonline, "i?"),
BUILDIN_DEF(strcharinfo,"i??"),
BUILDIN_DEF(strnpcinfo,"i??"),
BUILDIN_DEF(charid2rid,"i"),
@@ -26697,6 +26755,11 @@ static void script_hardcoded_constants(void)
script->set_constant("UDT_BODY2", UDT_BODY2, false, false);
script->set_constant("UDT_GROUP", UDT_GROUP, false, false);
+ script->constdb_comment("getguildonline types");
+ script->set_constant("GUILD_ONLINE_ALL", GUILD_ONLINE_ALL, false, false);
+ script->set_constant("GUILD_ONLINE_VENDOR", GUILD_ONLINE_VENDOR, false, false);
+ script->set_constant("GUILD_ONLINE_NO_VENDOR", GUILD_ONLINE_NO_VENDOR, false, false);
+
script->constdb_comment("Renewal");
#ifdef RENEWAL
script->set_constant("RENEWAL", 1, false, false);