Author Topic: Retrieving the oldest item in a store  (Read 412 times)

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
Retrieving the oldest item in a store
« on: January 05, 2012, 06:48:02 pm »


               Hi,

Does anyone know of a reliable method of doing this? I wonder if GetFirstItemInInventory() will truly return the oldest item, thus the first one having been put in the inventory(I mean in every situation). For a PC inventory it would probably not work since players can re-order their items. However, for a store, I'm unsure. Would it be more reliable to read the store's GFF item list with LetoScript? Any info will sure be helpful, thank you!


Kato 
               
               

               


                     Modifié par Kato_Yang, 05 janvier 2012 - 06:53 .
                     
                  


            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Retrieving the oldest item in a store
« Reply #1 on: January 05, 2012, 09:25:50 pm »


               For PC inventory, GetFirstItemInInventory(), and GetNextItemInInventory() will retrieve items from newest to oldest, with the equipable slots seen as outside the inventory.  I do not recall how items in containers work.  For a store I would think the same logic would apply.
               
               

               
            

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
Retrieving the oldest item in a store
« Reply #2 on: January 05, 2012, 09:29:09 pm »


               Sweet, tyvm WhiZard!


Kato
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Retrieving the oldest item in a store
« Reply #3 on: January 05, 2012, 10:18:31 pm »


               One thing to nore here.  I do not know if the PC's inventory get reordered when they are saved.   Or leave the server and re-enter.   Since the order the are returned iin is dependent on the order tin which thay are aquired.  And the PC reaquires all of his items when he logs  in .
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Retrieving the oldest item in a store
« Reply #4 on: January 05, 2012, 10:29:58 pm »


               not sure if its what you want to do but community patch provides an solution for "overfilled stores" issue and removed oldest item once there is reached item limit per store (you can set up the limit)
               
               

               
            

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
Retrieving the oldest item in a store
« Reply #5 on: January 05, 2012, 10:34:28 pm »


               

Lightfoot8 wrote...

One thing to nore here.  I do not know if the PC's inventory get reordered when they are saved.   Or leave the server and re-enter.   Since the order the are returned iin is dependent on the order tin which thay are aquired.  And the PC reaquires all of his items when he logs  in .


Indeed, I'll have to check this, thanks for the precision. Does this also apply to stores/placeables(I mean do they re-acquire items too on server reload)?
               
               

               


                     Modifié par Kato_Yang, 05 janvier 2012 - 10:41 .
                     
                  


            

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
Retrieving the oldest item in a store
« Reply #6 on: January 05, 2012, 10:37:24 pm »


               Oh, tyvm for the info ShaDoOoW, it's indeed very close to what I'm doing. '<img'>


Kato
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Retrieving the oldest item in a store
« Reply #7 on: January 05, 2012, 10:49:44 pm »


               

Kato_Yang wrote...

Indeed, I'll have to check this, thanks for the precision. Does this also apply to stores/placeables(I mean do they re-acquire items too on server reload)?


Well,  the standard system does not save any of the items in the store when the server shuts down.  It would just reload the store from the resref.   So I guess the question is how are you adding the items back to the store after a reset.   
               
               

               
            

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
Retrieving the oldest item in a store
« Reply #8 on: January 05, 2012, 10:57:33 pm »


               Excellent then, tyvm for the infos!


Kato
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Retrieving the oldest item in a store
« Reply #9 on: January 05, 2012, 11:20:43 pm »


               

Kato_Yang wrote...

Oh, tyvm for the info ShaDoOoW, it's indeed very close to what I'm doing. '<img'>


Kato

you can find the relevand code in x2_mod_def_unaqu if you use patch just set an integer variable "70_OVERFILLED_STORES_ISSUE_FIX" with a number of your intented limit and thats all, if not you can still reuse the coding that was done by Mavrixio (in download page there are builders resources with all scripts)
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Retrieving the oldest item in a store
« Reply #10 on: January 06, 2012, 12:40:52 am »


               I ran a few tests:

Saved characters will have the item order flipped (the item position does not matter for the inventory searching commands).  I am guessing the items are stored on the character file by the inventory retrieve order and then added back in the same order, which causes the next read to flip.

Moving items within the inventory has no effect on the order.  Moving them into a container within the inventory or an equip slot, is treated as removing them from one inventory and adding them to another.

Thus the return ordering goes bullet point down an contents listing.
1. Newest Item
  A.  Newest Item In This Container
  B.  Second Newest Item In This Container
2. Second Newest Item
  A.  Newest Item In This Container
  B.  Second Newest Item In This Container


-----
For store each inventory tab (armor, weapons, etc.) functions as a separate inventory.  The newest to oldest armor will thus be returned first, followed by the newest to oldest weapon, etc.
               
               

               
            

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
Retrieving the oldest item in a store
« Reply #11 on: January 06, 2012, 01:15:49 am »


               Thank you once more for the testings, WhiZard '<img'>


Kato