From ec05dccfddedf8250f1df61ce94dafb6823dace7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 14 Dec 2018 19:46:43 +0300 Subject: Add script command getInventorySize. This command allow read current max inventory size. --- doc/script_commands.txt | 9 +++++++++ src/map/script.c | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 5a9894217..5171d65f3 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -10303,5 +10303,14 @@ Maximum inventory size is MAX_INVENTORY. Minimum inventory size is FIXED_INVENTORY_SIZE. For supported clients it send inventory change packet. For old clients, this change is silent. +Current max inventory size can be read by function getInventorySize(). + +--------------------------------------- + +*getInventorySize() + +Return current player max inventory size. +This value always smaller or equal to MAX_INVENTORY. +Size can be changed by group of functions expandInventory* --------------------------------------- diff --git a/src/map/script.c b/src/map/script.c index 8dadf6d57..3d3fba867 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -24894,6 +24894,16 @@ static BUILDIN(expandInventory) return true; } +// return current player inventory size +static BUILDIN(getInventorySize) +{ + struct map_session_data *sd = script_rid2sd(st); + if (sd == NULL) + return false; + script_pushint(st, sd->status.inventorySize); + return true; +} + /** * Adds a built-in script function. * @@ -25637,6 +25647,7 @@ static void script_parse_builtin(void) BUILDIN_DEF(expandInventoryAck, "i?"), BUILDIN_DEF(expandInventoryResult, "i"), BUILDIN_DEF(expandInventory, "i"), + BUILDIN_DEF(getInventorySize, ""), }; int i, len = ARRAYLENGTH(BUILDIN); RECREATE(script->buildin, char *, script->buildin_count + len); // Pre-alloc to speed up -- cgit v1.2.3-70-g09d2