Jump to content

Recommended Posts

Posted

Ok so I was checking a little npc script and I realize we didn't had a proper way to check if we had enought place on storage for more then 1 item.

I'll explain by an exemple :

let say we have 500 extra weight left;

itemx = 5 n1 = 100 ok we have enought place.

itemy = 6, n2 = 3 ok we also have enought place.

But how to know if we have both ? if(checkwieght(itemx,n1) && checkwieght(itemy,n2)). we can sadly see that this condition wont fit in our case =/

Of course we could solve probably this by fetching both item weight (getiteminfo()) + our courrent weight and compare to our maxweight, but uh sound painfull, plus we won't even know if we still have place in inventory etc...

So I tought of upgrading chekweight to read not 1 item but as many as we want.

Here my base : http://pastebin.com/TK0dRs3s

Yet I'm not fully satisfied, I'd be sweet if instead reading 1 at the time we could send arrays as parameter.

Hope it's be usefull.

  • Upvote 1
Posted

Well, even though it's a good idea, it's unnecessary. You can check the weight for multiple items with GetItemInfo() function, Weight/MaxWeight constant and simple mathematics.

CheckWeight() is just a simplification...

Posted

Ok so I was checking a little npc script and I realize we didn't had a proper way to check if we had enought place on storage for more then 1 item.

I'll explain by an exemple :

let say we have 500 extra weight left;

itemx = 5 n1 = 100 ok we have enought place.

itemy = 6, n2 = 3 ok we also have enought place.

But how to know if we have both ? if(checkwieght(itemx,n1) && checkwieght(itemy,n2)). we can sadly see that this condition wont fit in our case =/

Of course we could solve probably this by fetching both item weight (getiteminfo()) + our courrent weight and compare to our maxweight, but uh sound painfull, plus we won't even know if we still have place in inventory etc...

So I tought of upgrading chekweight to read not 1 item but as many as we want.

Here my base : http://pastebin.com/TK0dRs3s

Yet I'm not fully satisfied, I'd be sweet if instead reading 1 at the time we could send arrays as parameter.

Hope it's be usefull.

Your code looks strange. You also hand out the items at the end. I think Kenpachi is right: This is rather a Change you can throw into the Release section than something everybody needs.

Posted

Kempachi, checkweight was also checking if you have enough slot in inventory for those new items.

Assuming your MAX_INVENTORY = 100 and you have 97 items there checkweight(x,5) will return false if x is unstackble, (like 5 shield etc).

-It will also check if you reach the max number for it (32k)

It's probably possible to do workarround for those too, but well I rather update a command that already do that. But if you think it's rather a mod it's ok I don't mind.

@Jonne, what's strange ?

Posted

AEGIS checks if you can carry a Knife (unstackable) and for a high value like 2000 Weight (that's why if you create a Novice and talk to some quests NPCs you're not supposed to talk, you'll constantly receive messages about needing to use the storage).

Even though it's a workaround and a bad practice, it's the official behavior...

Anyway, getiteminfo and getinventorylist can do what you want (http://pastebin.com/WsdDVNnc, not tested).

Usage: callfunc("F_CheckGetItem", 501, 30, 502, 50, 1002, 20);

Returns -2 if total new inventory entries + current inventory entries exceeds MAX_INVENTORY, -1 if new stackable amount + current stackable amount exceeds MAX_AMOUNT, 0 if the sum of all the new weigth + current weight exeeds MaxWeight and 1 if there's no problem

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...