diff options
author | Dastgir <dastgirpojee@rocketmail.com> | 2017-09-20 06:31:00 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-20 06:31:00 +0530 |
commit | 7cbd35644b73f254fc976070cd1e993aa43a7cfc (patch) | |
tree | bbfdcd7392ad452b5bb069f6b732727c8b2417f4 | |
parent | 94b3f24afa5e77bf770fdf90cf446396165b82c6 (diff) | |
parent | 6156d03ea9654ae455ce8e741b3b4a9c3fdd5bab (diff) | |
download | hercules-7cbd35644b73f254fc976070cd1e993aa43a7cfc.tar.gz hercules-7cbd35644b73f254fc976070cd1e993aa43a7cfc.tar.bz2 hercules-7cbd35644b73f254fc976070cd1e993aa43a7cfc.tar.xz hercules-7cbd35644b73f254fc976070cd1e993aa43a7cfc.zip |
Merge pull request #1842 from mekolat/getgroupid
Allow using getgroupid on another player
-rw-r--r-- | doc/script_commands.txt | 6 | ||||
-rw-r--r-- | src/map/script.c | 22 |
2 files changed, 18 insertions, 10 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 15026cd7c..c9bdce7c5 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -3364,10 +3364,10 @@ Return true if successful, otherwise it will return false. --------------------------------------- -*getgroupid() +*getgroupid({<account id>}) -This function will return the id of player group the account to which the -invoking player belongs. +This command returns the id of the group of the attached or specified player. +If the player is not found, returns -1. --------------------------------------- diff --git a/src/map/script.c b/src/map/script.c index 8ddb056bd..533e421d8 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -9967,14 +9967,22 @@ BUILDIN(setgroupid) { /// Returns the group ID of the player. /// -/// getgroupid() -> <int> -BUILDIN(getgroupid) -{ - struct map_session_data *sd = script->rid2sd(st); - if (sd == NULL) +/// getgroupid({<account id>}) -> <int> +BUILDIN(getgroupid) { + struct map_session_data *sd = NULL; + + if (script_hasdata(st, 2)) { + sd = map->id2sd(script_getnum(st, 2)); + } else { + sd = script->rid2sd(st); + } + + if (sd == NULL) { + script_pushint(st, -1); return true; // no player attached, report source - script_pushint(st, pc_get_group_id(sd)); + } + script_pushint(st, pc_get_group_id(sd)); return true; } @@ -23861,7 +23869,7 @@ void script_parse_builtin(void) { BUILDIN_DEF(basicskillcheck,""), BUILDIN_DEF(getgmlevel,""), BUILDIN_DEF(setgroupid, "i?"), - BUILDIN_DEF(getgroupid,""), + BUILDIN_DEF(getgroupid,"?"), BUILDIN_DEF(end,""), BUILDIN_DEF(checkoption,"i?"), BUILDIN_DEF(setoption,"i??"), |