Author Topic: A way to close a store after buying an item?  (Read 643 times)

Legacy_doomie22

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
A way to close a store after buying an item?
« on: June 16, 2011, 11:57:40 pm »


               Hi all,

Just wondering if there is a way of after buying an item off a merchant that within the OnAquireItem proc to close the merchant window?

Thanks,

Doomie 
               
               

               
            

Legacy_the.gray.fox

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
A way to close a store after buying an item?
« Reply #1 on: June 17, 2011, 12:41:30 am »


               Interesting.

A number of options come to mind.
But I think the cleanest one (and one that will leave no trace what-so-ever) is to destroy the very Store object.
That will cause the immediate cessation of shopping activity -- for sure.
But it will also do it for any other PC shopping at the same Store in that moment (multiplayer).

When you destroy a Store, you lose any customization made to it after its spawning. That includes you also lose any and all items that were sold _to_ the Store.
Recreating the Store (that is, spawning it anew from its blueprint) would not bring the sold items back. Makes perfect sense.

So... To solve this problem, just CopyObject() the original Store somewhere (you clone it).
You can spawn it at the same Location of the original Store currently open for shopping -- the game will not care.
Then you simply destroy the original Store object.

That should do the trick nicely.
And because you have copied (cloned) the original Store, you have also preserved all items that were sold to it.

Please let me know if it works -- I can not make tests from here at the moment.


-fox



[edit]
Let us steppify it:

1) Query the Location of the currently opened Store.
2) CopyObject() the currently opened Store at the Location from point 1.
3) Destroy the currently opened Store.
4) Send fox a bunny.


-fox
               
               

               


                     Modifié par the.gray.fox, 16 juin 2011 - 11:48 .
                     
                  


            

Legacy_doomie22

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
A way to close a store after buying an item?
« Reply #2 on: June 18, 2011, 01:23:20 am »


               I am not liking the idea of that especially if someone else is using it.

Has anyone got a script out there that a PC is able to buy a key off a merchant but if they try to buy another then it stops them?

Thanks
               
               

               
            

Legacy_the.gray.fox

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
A way to close a store after buying an item?
« Reply #3 on: June 18, 2011, 02:31:07 pm »


               

doomie22 wrote...

I am not liking the idea of that especially if someone else is using it.

You can always cycle through the other shop users and issue (for them alone) an OpenStore() command.
Their Store interface would just blink for a moment. No big deal -- really.
But if you do not like it, who am I to insist?



doomie22 wrote...

Has anyone got a script out there that a PC is able to buy a key off a merchant but if they try to buy another then it stops them?

Thanks

When you buy an item from a Store, the OnAcquireItem module event fires for you.
At that point you can query the call for more details... starting with seeing who is the _former_ Possessor of the newly acquired item.
If such possesor is the Store... you just give the item back to it (to the Store, I mean).
Have care to refund any GP worth the item to give back, of course -- for this kind of giving back is not a regular transaction.

Does this help better?


-fox
               
               

               


                     Modifié par the.gray.fox, 18 juin 2011 - 01:37 .
                     
                  


            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
A way to close a store after buying an item?
« Reply #4 on: June 18, 2011, 03:21:36 pm »


               Thinking along the lines of Fox there have the merchant in the conversation prior to opening the store check the pc for an int(more on this in a moment), if the pc has the int marking dont open the store, just say "Hope that key did you some good.". The int would be marked on the pc when they originally purchase the key, you can have the onacquire of the mod close the store, I think, I will open the toolset and make sure in a bit. So any subsequent attempts by the pc to get another key will be thwarted.
               
               

               


                     Modifié par Baragg, 18 juin 2011 - 02:23 .
                     
                  


            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
A way to close a store after buying an item?
« Reply #5 on: June 18, 2011, 03:23:11 pm »


               Did not immediately see a CloseStore, but mayhap you could add an action to the pc action que such as move back 2 steps and thereby have the store close?
               
               

               
            

Legacy_doomie22

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
A way to close a store after buying an item?
« Reply #6 on: June 20, 2011, 04:47:22 pm »


               I have got a concept on how I can sort it, but I am having trouble with a small thing.

I am in the module on acquire item script.  I am trying to link back to the shop that is currently open.

What my plan is that if it finds that within the database that there is an int set against the player that it will take the item and either give it back to the shop or create the item on shop and destroy the item from the player, but I have no idea how I can get the shop info from within the acquire script.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
A way to close a store after buying an item?
« Reply #7 on: June 20, 2011, 09:59:35 pm »


                 object oStore = GetModuleItemAcquiredFrom();
  if{GetObjectType( oStore) == OBJECT_TYPE_STORE)
  {
    // then the  store that the item came from is oStore.
  }