Lighta Posted February 20, 2012 Group: Members Topic Count: 16 Topics Per Day: 0.00 Content Count: 737 Reputation: 216 Joined: 11/29/11 Last Seen: December 20, 2020 Share Posted February 20, 2012 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. 1 Link to comment Share on other sites More sharing options...
Kenpachi Posted February 20, 2012 Group: Members Topic Count: 22 Topics Per Day: 0.00 Content Count: 764 Reputation: 220 Joined: 11/14/11 Last Seen: November 19, 2020 Share Posted February 20, 2012 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... Link to comment Share on other sites More sharing options...
Jonne Posted February 20, 2012 Group: Members Topic Count: 8 Topics Per Day: 0.00 Content Count: 153 Reputation: 33 Joined: 12/24/11 Last Seen: September 30, 2024 Share Posted February 20, 2012 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. Link to comment Share on other sites More sharing options...
Lighta Posted February 20, 2012 Group: Members Topic Count: 16 Topics Per Day: 0.00 Content Count: 737 Reputation: 216 Joined: 11/29/11 Last Seen: December 20, 2020 Author Share Posted February 20, 2012 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 ? Link to comment Share on other sites More sharing options...
Vianna Posted February 20, 2012 Group: Members Topic Count: 0 Topics Per Day: 0 Content Count: 47 Reputation: 8 Joined: 12/06/11 Last Seen: January 13, 2013 Share Posted February 20, 2012 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 Link to comment Share on other sites More sharing options...
Jonne Posted February 21, 2012 Group: Members Topic Count: 8 Topics Per Day: 0.00 Content Count: 153 Reputation: 33 Joined: 12/24/11 Last Seen: September 30, 2024 Share Posted February 21, 2012 @Jonne, what's strange ? Can't point my figner at it, sorry. But something seems odd. Dunno. Maybe just me having a bad day Link to comment Share on other sites More sharing options...
Recommended Posts