You are here

how do you make an on enter script only happen once

7 posts / 0 new
Last post
Bootlebat
how do you make an on enter script only happen once

To be specific I want to have an undead encounter where when the player enters it says "the tormented dead rise". It works but the text shows up every time I enter even after I killed all the undead. How do I stop this from happening?

  • up
    50%
  • down
    50%
Vanya Mia
Vanya Mia's picture

Assuming you have a script to make the player say it, use the same script to check for a variable on the area, if it is "zero" then make the player say the comment and then set the variable to "one". That way the next time the script is run it should stop when it finds the variable is no longer zero.

"I took Skill Focus: Craft Disturbing Mental Image as my feat last level." Belkar, OOTS

  • up
    50%
  • down
    50%
Proleric
Proleric's picture

...or you can set the local flag on the player. An advantage of setting local variables on clickable objects is that you can debug them with dm_dumplocals etc.

NWN and DAO adventures at http://proleric.com/

  • up
    50%
  • down
    50%
Vanya Mia
Vanya Mia's picture

Agreed, but logging in and out can remove variables stored on players, and there may be more than one player active in the module - leading to the question as to whether the text should be said for other players. It's not clear if this is for a PW or a single story module, hence my suggesting the area. If it's the later then I'd go player too.

  • up
    50%
  • down
    50%
KMdS

I've never noticed a local set on a player ever be lost, except over server resets. Is there something I don't know about this? Please elucidate?

 The NWServers and Forum at http://www.orlanthia.net 

NWServer ports: Orlanthia (FR/GH) port 5122, Sam's Server - Menzoberranzan port 5124, The Lands of Acheron port 5123.

 

  • up
    50%
  • down
    50%
Vanya Mia
Vanya Mia's picture

If you are talking PWs then it's less of an issue, but I play DMed campaigns which means the server does not stay up permanently and therefore loss of local variables happens every session. But it can also happen if the server or client crashes in a way which means the character is not saved. I've seen this happen and characters even lose inventory items and gold.

The knock on effect is that if you never want a player to see a message again, or be able to complete a quest again, or repeat any action which you intend to be a one off, then you need to store a flag to prevent it happening somewhere other than on the PC. There's no way to be 100% sure but the most frequent choice without the use of a database is to store it on an undroppable item held by the PC.

 

  • up
    50%
  • down
    50%
ffbj
ffbj's picture

You want to use an undropable object on PC's to set many variables. This way over server resets they are not lost.

For instance in my world you go back to the last place you logged from, in the condition you logged out. I also use it for stamina, notoriety, curses, or hits ordered. 

If you dl Orilion Nights I use DB object on PC. So you can see how it's done. 

  • up
    50%
  • down
    50%