diff options
author | Haru <haru@dotalux.com> | 2017-06-03 18:05:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-03 18:05:48 +0200 |
commit | bab23871da1b01c9d5276fb761bb869b99343f62 (patch) | |
tree | b68217596c1cc74252d5e6606bd379aba5cc2d6e /src/map/script.c | |
parent | ce1166a0981f398d5c46bd74438ad4b3bc35d726 (diff) | |
parent | 7fa9eb8ecdeafe520fadf865ad8463a9ac1b47cb (diff) | |
download | hercules-bab23871da1b01c9d5276fb761bb869b99343f62.tar.gz hercules-bab23871da1b01c9d5276fb761bb869b99343f62.tar.bz2 hercules-bab23871da1b01c9d5276fb761bb869b99343f62.tar.xz hercules-bab23871da1b01c9d5276fb761bb869b99343f62.zip |
Merge pull request #1736 from mekolat/group2
new buildin: add_group_command
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/map/script.c b/src/map/script.c index b2a707bb0..ecb053fdc 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -21505,6 +21505,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) **/ @@ -21554,6 +21591,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; @@ -23725,6 +23764,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] |