Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function script F_CheckGetItem {
- getinventorylist;
- //New inventory entries.
- set .@new_entries, 0;
- //Sum of all weights.
- set .@sum_weight, 0;
- //Loop though all parameters.
- for (set .@i, 0; getarg(.@i, 0) <= 0; set .@i, .@i + 2)
- {
- //Check if is stackable.
- if (callfunc("F_IsStackable", getarg(.@i)))
- {
- //If true, find a match.
- for (set .@j, 0; .@j < @inventorylist_count; set .@j, .@j + 1)
- {
- //Check if id matches.
- if (@inventorylist_id[.@j] == getarg(.@i))
- {
- //If true, check for possible amount overflow.
- if (@inventorylist_amount[.@j] + getarg(.@i+1) > MAX_AMOUNT)
- return -1;
- //No need to check for more inventory entries.
- break;
- }
- }
- //Check if no match was found
- if (.@j == @inventorylist_count)
- //If true, add a new inventory entry.
- set .@new_entries, .@new_entries + 1;
- }
- else
- {
- //If false, add item amount as new entries.
- set .@new_entries, .@new_entries + getarg(.@i+1);
- }
- //Add weight.
- set .@sum_weight, .@sum_weight + getiteminfo(getarg(.@i), 6) * getarg(.@i+1);
- }
- return ((.@new_entries + @inventorylist_count) > MAX_INVENTORY) ? -2 : ((.@sum_weight + Weight) > MaxWeight) ? 0 : 1;
- }
- function script F_IsStackable {
- switch (getiteminfo(getarg(0), 2)
- {
- case IT_WEAPON:
- case IT_ARMOR:
- case IT_PETEGG:
- case IT_PETARMOR:
- return 0;
- default:
- return 1;
- }
- }
- //const.txt
- MAX_INVENTORY 100
- MAX_AMOUNT 30000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement