summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgumi <mekolat@users.noreply.github.com>2017-05-16 21:34:11 -0400
committergumi <mekolat@users.noreply.github.com>2017-05-28 11:51:34 -0400
commit5ceccb77064b557a2f616040f937417c8f002a72 (patch)
tree7e60d26b2385f81633d9f1a2194d9100bdb8ef5e
parent9ef0c24ba9c2cff4ae6fcf5884a14aa8111faf27 (diff)
downloadhercules-5ceccb77064b557a2f616040f937417c8f002a72.tar.gz
hercules-5ceccb77064b557a2f616040f937417c8f002a72.tar.bz2
hercules-5ceccb77064b557a2f616040f937417c8f002a72.tar.xz
hercules-5ceccb77064b557a2f616040f937417c8f002a72.zip
add buildin add_group_command()
-rw-r--r--src/map/script.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 75f747fb6..1f3c2801f 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -21499,6 +21499,43 @@ BUILDIN(issit)
return true;
}
+BUILDIN(add_group_command)
+{
+ AtCommandInfo *acmd_d;
+ struct atcmd_binding_data *bcmd_d;
+ GroupSettings *group;
+ int group_index;
+ const char *atcmd = script_getstr(st, 2);
+ int group_id = script_getnum(st, 3);
+ bool self_perm = (script_getnum(st, 4) == 1);
+ bool char_perm = (script_getnum(st, 5) == 1);
+
+ if (!pcg->exists(group_id)) {
+ ShowWarning("script:add_group_command: group does not exist: %i\n", group_id);
+ script_pushint(st, 0);
+ return false;
+ }
+
+ group = pcg->id2group(group_id);
+ group_index = pcg->get_idx(group);
+
+ if ((bcmd_d = atcommand->get_bind_byname(atcmd)) != NULL) {
+ bcmd_d->at_groups[group_index] = self_perm;
+ bcmd_d->char_groups[group_index] = char_perm;
+ script_pushint(st, 1);
+ return true;
+ } else if ((acmd_d = atcommand->get_info_byname(atcmd)) != NULL) {
+ acmd_d->at_groups[group_index] = self_perm;
+ acmd_d->char_groups[group_index] = char_perm;
+ script_pushint(st, 1);
+ return true;
+ }
+
+ ShowWarning("script:add_group_command: command does not exist: %s\n", atcmd);
+ script_pushint(st, 0);
+ return false;
+}
+
/**
* @commands (script based)
**/
@@ -21548,6 +21585,8 @@ BUILDIN(bindatcmd)
atcommand->binding[i]->group_lv = group_lv;
atcommand->binding[i]->group_lv_char = group_lv_char;
atcommand->binding[i]->log = log;
+ CREATE(atcommand->binding[i]->at_groups, char, db_size(pcg->db));
+ CREATE(atcommand->binding[i]->char_groups, char, db_size(pcg->db));
}
return true;
@@ -23719,6 +23758,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(useatcmd, "s"),
BUILDIN_DEF(has_permission, "v?"),
BUILDIN_DEF(can_use_command, "s?"),
+ BUILDIN_DEF(add_group_command, "siii"),
/**
* Item bound [Xantara] [Akinari] [Mhalicot/Hercules]