diff options
author | gumi <mekolat@users.noreply.github.com> | 2016-12-07 17:33:33 +0000 |
---|---|---|
committer | gumi <mekolat@users.noreply.github.com> | 2016-12-07 17:33:33 +0000 |
commit | b3dbfe6b1d3e67e0412eadb67e58563562a9f0d8 (patch) | |
tree | 801ae730d9900e5071d91f893cd9ca7b8d64e9ac | |
parent | 3ca80096980ba0d32f6d8812b848281cd88a224c (diff) | |
parent | 135f7b4555e851fe00f24ba4157d3bb177c7b52e (diff) | |
download | serverdata-b3dbfe6b1d3e67e0412eadb67e58563562a9f0d8.tar.gz serverdata-b3dbfe6b1d3e67e0412eadb67e58563562a9f0d8.tar.bz2 serverdata-b3dbfe6b1d3e67e0412eadb67e58563562a9f0d8.tar.xz serverdata-b3dbfe6b1d3e67e0412eadb67e58563562a9f0d8.zip |
Merge branch 'inventoryplace' into 'master'
Use the builtin function to check inventory place on the inventoryplace function.
See merge request !71
-rw-r--r-- | npc/functions/inventoryplace.txt | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/npc/functions/inventoryplace.txt b/npc/functions/inventoryplace.txt index 35c2b6e9..e92ec579 100644 --- a/npc/functions/inventoryplace.txt +++ b/npc/functions/inventoryplace.txt @@ -4,28 +4,34 @@ // Reid // Description: // Check if the player have enough place on his inventory to accept new items with arguments: -// getarg(0) item ID, -// getarg(1) number of items, -// Variables: -// .@iteminfo = Item information type. (See doc for list of item's types) -// .@countitem = Count item's number. +// getarg(even numbers) item ID, +// getarg(odd numbers) number of items, function script inventoryplace { - getinventorylist; - .@iteminfo = getiteminfo(getarg(0), 2); - .@countitem = countitem(getarg(0)); - if (checkweight(getarg(0), getarg(1)) == 0) goto L_Warn; - if ((.@iteminfo < 4) && (.@countitem == 0) && (.@inventorylist_count < 100)) return; - if ((.@iteminfo < 4) && (.@countitem > 0)) return; - if (.@inventorylist_count + getarg(1) <= 100) return; + .@argc = getargcount(); -L_Warn: - mes ""; - mesn "Narrator"; - mes col(l("It looks like you can't carry anything else for now."), 9); - next; - mes col(l("You should come back when you have some free space."), 9); + if (.@argc % 2 != 0) + { + debugmes "inventoryplace: Wrong argument count."; + close; + } - close; + for (.@i = .@j = 0; .@i < .@argc; .@i += 2) + { + setarray .@item[.@j], getarg(.@i); + setarray .@amount[.@j], getarg(.@i + 1); + ++.@j; + } + + if (!checkweight2(.@item, .@amount)) + { + narrator 1, + l("It looks like you can't carry anything else for now."), + l("You should come back when you have some free space."); + + close; + } + + return true; } |