Author Topic: Copy item into store?  (Read 363 times)

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Copy item into store?
« on: July 26, 2015, 09:17:30 pm »


               

Got a little problem trying to copy item from PC into store inventory.


 


I tried both CopyItem and CopyObject, I verified the oStore is valid, I even tried to put some item into store first and disable "buy restrictions" but with no effect.


 



 


object oBazar = GetObjectByTag("sh_bazar_obchod");

object item = CopyItem(oItem,oBazar,TRUE);



both oBazar and oItem are valid, but instead of the item being created in store inventory its created on the ground under store position in area.


 


Is this a know bug? Couldnt find anything in lexicon.



               
               

               
            

Legacy_Tarot Redhand

  • Hero Member
  • *****
  • Posts: 4165
  • Karma: +0/-0
Copy item into store?
« Reply #1 on: July 27, 2015, 12:12:56 am »


               

Did you try


 


void ActionGiveItem(

    object oItem,

    object oGiveTo

);


 


TR



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Copy item into store?
« Reply #2 on: July 27, 2015, 03:43:11 am »


               


Did you try


 


void ActionGiveItem(

    object oItem,

    object oGiveTo

);


 


TR




didnt work


 


but I was sure I was doing this kind of stuff before and it worked so I made a chat command test which took axe from ground and copied it into store and it worked so there is something wrong here


 


my script is conditional script running on plot npc without any AI scripts, item is in players inventory, but I tried to copy it twice, once into npc inventory first then store with same result item appeared under store position, I dont know...


               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Copy item into store?
« Reply #3 on: July 30, 2015, 05:56:53 am »


               

So I found the problem!


 


It looks that any item with Plot flag fails to get copied into store, instead it will be created on the ground under store location.


 


To workaround this you need to remove Plot flag before copying and restore it later (if needed).


 


sample code



 


 object oItem = GetObjectByTag("testaxe");

 object oStore = GetObjectByTag("teststore");

 int bPlot = GetPlotFlag(oItem);

  if(bPlot)

  {

  SetPlotFlag(oItem,FALSE);

  }

 oItem = CopyItem(oItem,oStore,TRUE);

  if(bPlot)

  {

  SetPlotFlag(oItem,TRUE);

  }



Anyone wants to update lexicon about this?



               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
Copy item into store?
« Reply #4 on: July 30, 2015, 06:56:16 am »


               

Updated and included your example. Thanks!



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Copy item into store?
« Reply #5 on: July 30, 2015, 06:56:32 am »


               

...Anyone wants to update lexicon about this?


 


Done.


 


Possibly "expected behavior" for the game engine, since you can't sell plot items to a store, but since the toolset allows plot items in a store inventory, this nuance is worth recording.


 


Correction : Squatting Monk got there first. I won't split hairs about whether it's a bug.



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Copy item into store?
« Reply #6 on: July 30, 2015, 07:09:48 am »


               

its weird since toolset allows to sell plot items in store (and wasnt there in OC actually a store selling all plot items player lost?)



               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
Copy item into store?
« Reply #7 on: July 30, 2015, 04:54:49 pm »


               


Possibly "expected behavior" for the game engine, since you can't sell plot items to a store, but since the toolset allows plot items in a store inventory, this nuance is worth recording.




 


For sure. I expect if this were pointed out to developers they would have fixed it in a patch. I added this comment as a note to both articles.


               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
Copy item into store?
« Reply #8 on: July 31, 2015, 06:10:00 am »


               

Look into this one... the ideal point for those who are having problems with it!!! Everybody please thanks Shadooow and enjoy the code.