diff options
author | Reid <reidyaro@gmail.com> | 2016-12-04 05:26:05 +0100 |
---|---|---|
committer | Reid <reidyaro@gmail.com> | 2016-12-07 17:05:02 +0100 |
commit | 7ebc17f8b4ba8cb03a6251084bd896ac5a6fdc06 (patch) | |
tree | a545f46cc7620a58ed22d4a4c71560a2bc71f989 /npc | |
parent | 3ca80096980ba0d32f6d8812b848281cd88a224c (diff) | |
download | serverdata-7ebc17f8b4ba8cb03a6251084bd896ac5a6fdc06.tar.gz serverdata-7ebc17f8b4ba8cb03a6251084bd896ac5a6fdc06.tar.bz2 serverdata-7ebc17f8b4ba8cb03a6251084bd896ac5a6fdc06.tar.xz serverdata-7ebc17f8b4ba8cb03a6251084bd896ac5a6fdc06.zip |
Use the builtin function to check inventory place on the inventoryplace function.
Diffstat (limited to 'npc')
-rw-r--r-- | npc/functions/inventoryplace.txt | 63 |
1 files changed, 41 insertions, 22 deletions
diff --git a/npc/functions/inventoryplace.txt b/npc/functions/inventoryplace.txt index 35c2b6e9..02c28b1c 100644 --- a/npc/functions/inventoryplace.txt +++ b/npc/functions/inventoryplace.txt @@ -4,28 +4,47 @@ // 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; - -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); - - close; + + function inventoryplace_warn { + narrator + l("It looks like you can't carry anything else for now."), + l("You should come back when you have some free space."); + + bye; + } + + .@argc = getargcount(); + + if (.@argc < 2) + { + debugmes "Wrong argument count."; + } + else if (.@argc == 2) + { + if (!checkweight(getarg(0), getarg(1))) + { + inventoryplace_warn(); + } + } + else + { + for (.@i = .@j = 0; .@i < .@argc; .@i += 2) + { + setarray .@item[.@j], getarg(.@i); + setarray .@amount[.@j], getarg(.@i + 1); + + .@j++; + } + + if (!checkweight2(.@item, .@amount)) + { + inventoryplace_warn(); + } + } + return; + } |