Aller au contenu

Photo

Close a placeable function?


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

#1
El Condoro

El Condoro
  • Members
  • 148 messages
I have a placeable container (chest) that has items in it (randomly created) and I have the OnOpen event firing to check the PC's inventory for the same items and to count them. If the count is over 5 I have a FloatString to say "You have too many" and then I want to close the chest so that it can't be accessed until the PC drops one or more items.

What is the function to close the chest?

I don't want to lock it and I don't want to make it inaccessible, I just want the PC not to be able to access the items until he has dropped one or two others.

Cheers

#2
rjshae

rjshae
  • Members
  • 4 491 messages
It might be to have the chest run ActionPlayAnimation with an ANIMATION_PLACEABLE_* value. But that's just a guess.

#3
Dann-J

Dann-J
  • Members
  • 3 161 messages
Yes - I suspect ActionPlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE) might do the trick. That's what you would use to return a lever to the 'deactivated' state. Unless chest animations operate differently to levers?

#4
MasterChanger

MasterChanger
  • Members
  • 686 messages
I think the issue will be more of closing the opened inventory window than animating the chest closing animation. This might not be right, but I suspect that the relevant GUI would be SCREEN_CONTAINER_CHEST. Ingamegui.ini sets this as defined by container.xml, which doesn't seem to include ScriptLoadable=true, so you may or may not be able to close it.



Anyway, if this does work, you'd probably want to animate the closing as people have said, but also use CloseGUIScreen(oPlayer, sContainerGUI). Maybe someone who knows more about GUIs than I do can help you more.

#5
luna_hawke

luna_hawke
  • Members
  • 88 messages
There has been a big problem in persistent worlds with chest lids getting stuck open.

As far as I know nobody has figured out how to force a chest closed via scripting.



I don't think it can be done.



But if you happen to have any luck, please let us know.


#6
Dann-J

Dann-J
  • Members
  • 3 161 messages
I suppose you could always try using an OnInventoryDisturbed script that counts how many of a certain item is in the player's inventory, and if it excedes a given amount then immediately giving the difference back. If there is only one special item type per chest then you could store the item tag and the amount to check for as local variables on the chest, so different chests could use the same script.

#7
Olblach

Olblach
  • Members
  • 175 messages

El Condoro wrote...

What is the function to close the chest?


Cheers

      ActionPlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE);

However you need to keep track of it. Look at x2_plc_used_act for an example script (it sets the variable X2_L_PLC_ACTIVATED_STATE).

luna_hawke wrote...

There has been a big problem in persistent worlds with chest lids getting stuck open.
As far as I know nobody has figured out how to force a chest closed via scripting.

I don't think it can be done.

But if you happen to have any luck, please let us know.

It works perfectly just place this line in a script OnOpen for a chest. You can add a DelayCommand() if you want a smoother effect.

However that will effectively close the chest but not the trade window. One way to achieve that is to make the player move away from the chest.

Modifié par Olblach, 10 novembre 2010 - 01:39 .