From 6ccdbae7b9a7d417c428122e8f2bbbdeae9e86c6 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Wed, 26 Feb 2020 03:11:34 -0300 Subject: New utility function: instanceowner. Will return the ID of the instance owner. "0" means global instance or invalid. Party and Guilds share IDs, so be careful when not using account IDs for this. --- src/emap/init.c | 1 + src/emap/script_buildins.c | 18 ++++++++++++++++++ src/emap/script_buildins.h | 1 + 3 files changed, 20 insertions(+) diff --git a/src/emap/init.c b/src/emap/init.c index 5c5bf27..d351985 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -233,6 +233,7 @@ HPExport void plugin_init (void) addScriptCommand("homstatus","",homstatus); addScriptCommand("readparam2","i?",readparam2); addScriptCommand("npcshopattach","s?",npcshopattach); + addScriptCommand("instanceowner", "i", InstanceOwner); // Overrides addScriptCommand("debugmes","v*",debugmes); diff --git a/src/emap/script_buildins.c b/src/emap/script_buildins.c index 65ac653..f0b06a5 100644 --- a/src/emap/script_buildins.c +++ b/src/emap/script_buildins.c @@ -2984,3 +2984,21 @@ BUILDIN(countitem) } +// Returns the Acc. ID of the owner of an instance +BUILDIN(InstanceOwner) +{ + const int instance_id = script_getnum(st, 2); + + // Do instance exists? + if (!instance->valid(instance_id)) { + script_pushint(st, false); + return true; + } + + // Note: This does not returns type! + // using this against party/guilds instances not advised. + // returns 0 if either instance doesn't exists or is global + script_pushint(st, (int)instance->list[instance_id].owner_id); + return true; +} + diff --git a/src/emap/script_buildins.h b/src/emap/script_buildins.h index 53907bd..2343b12 100644 --- a/src/emap/script_buildins.h +++ b/src/emap/script_buildins.h @@ -118,6 +118,7 @@ BUILDIN(deployhomunculus); BUILDIN(recallhomunculus); BUILDIN(homstatus); BUILDIN(readparam2); +BUILDIN(InstanceOwner); // Overrides BUILDIN(countitem); -- cgit v1.2.3-70-g09d2