Aller au contenu

Photo

A way to close a store after buying an item?


  • Veuillez vous connecter pour répondre
7 réponses à ce sujet

#1
doomie22

doomie22
  • Members
  • 9 messages
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 

#2
the.gray.fox

the.gray.fox
  • Members
  • 127 messages
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 .


#3
doomie22

doomie22
  • Members
  • 9 messages
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

#4
the.gray.fox

the.gray.fox
  • Members
  • 127 messages

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 .


#5
Baragg

Baragg
  • Members
  • 271 messages
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 .


#6
Baragg

Baragg
  • Members
  • 271 messages
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?

#7
doomie22

doomie22
  • Members
  • 9 messages
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.

#8
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
  object oStore = GetModuleItemAcquiredFrom();
  if{GetObjectType( oStore) == OBJECT_TYPE_STORE)
  {
    // then the  store that the item came from is oStore.
  }