Time + NPC's

I need some help guys. I am using Vlues Advanced Game Time Script and I know how to use it but I am at a lose of what to do for the NPCs. What I am trying to do is set up an event where there is an npc that sells you things at a specific time and when that time is over the npc is gone. For example if a shop npc is in town from 12:00 AM to 5:00 PM I need help setting up an event to tell when 5:00 hits then the npc will be gone until 12:00 the next morning. Any help is appreciated.
Script:
What are the variables that you're using for the time system? What are their values at 12am and 5pm?

You will either set up different event pages/tabs on each event, using variables in the event page conditions, or you will use conditional branches to determine what needs to happen based on those variables.
What are the variables that you're using for the time system? What are their values at 12am and 5pm?

You will either set up different event pages/tabs on each event, using variables in the event page conditions, or you will use conditional branches to determine what needs to happen based on those variables.
I am not using variables for the time. I am having conditional branches check is the time on the players computer is between 12 AM and 5 PM. I was told to make it a Parallel Process, but when I do that and the npc is in town then every time i move the shop comes up.
You need to show HOW you're doing stuff, not just say that you ARE doing stuff. Then we might be able to help you.

I would not make all the NPCs on parallel processes - that's going to cause a whole lot of lag.
You need to show HOW you're doing stuff, not just say that you ARE doing stuff. Then we might be able to help you.

I would not make all the NPCs on parallel processes - that's going to cause a whole lot of lag.
This is what I did to test it out:
Screenshot_2.png

Screenshot_3.png
Please show the entire event page. The parts you have cropped out are just as important (if not more important) than the event commands.

Also clarify what is the GameTime.hour? set to when you're running this, what you expect to happen, and what is actually happening.
Please show the entire event page. The parts you have cropped out are just as important (if not more important) than the event commands.

Also clarify what is the GameTime.hour? set to when you're running this, what you expect to happen, and what is actually happening.
Here are the Whole pages for the event:
Screenshot_2.png

Screenshot_3.png

This happened as soon as I exited the house: and I was not able to move. It was just repeating.
Screenshot_4.png

Screenshot_5.png
I suggest you go back to basics and refresh your understanding of event pages and page triggers. What you have above will never work.

Your first page is set to parallel process, so if the condition is true, it's going to show the shop as soon as the map loads, you will exit the shop, and then it will loop to the start and show the shop again. If the condition isn't true, it will activate page 2. It will only go back to page 1 if the player interacts with the event (action button) which is unlikely because there is no sprite.

The conditions in the conditional branch on both pages are the same. This means if the time is > 5PM the event will disappear, but then you can interact with it and it will appear again, and then disappear again straight away. And if the time is 0, then the time IS less than 18, so your two parts to the conditional branch are also redundant.


I suggest you do the following ... allocate a variable to keep track of the game time. Create a new common event, set it to parallel process, and add the following commands:
Wait 60 Frames
Control Variables: (time variable) = Script: GameTime.hour?

This common event will cause the hour to be put into the variable every second while the game is running. You will need to allocate a switch, and turn on that switch at the start of the game, so it's always active. A parallel common event with a 60 frame (1 second) wait will not affect performance.

Now on your NPC event, create the first page with your NPC sprite and shop processing. Leave its trigger as Action Button.
Create a second event page with no sprite and no event commands. Leave its trigger as Action Button. In the event conditions, put Variable (time variable) >= 18.

So before 5:00 the NPC will be there, and you need to go up and interact with him to see the shop window. And after 5:00 the NPC will not be there. If the NPC happens to be on the screen, visible, when the hour changes from 4:00 to 5:00, the NPC will just disappear. Likewise, if the player is on the screen and near that spot when the hour goes from 11:00 to midnight, the NPC will just appear.

Note - without looking at the time system, wouldn't 5PM be 17 rather than 18? If it's hours since midnight, 18 would be 6PM.
I suggest you go back to basics and refresh your understanding of event pages and page triggers. What you have above will never work.

Your first page is set to parallel process, so if the condition is true, it's going to show the shop as soon as the map loads, you will exit the shop, and then it will loop to the start and show the shop again. If the condition isn't true, it will activate page 2. It will only go back to page 1 if the player interacts with the event (action button) which is unlikely because there is no sprite.

The conditions in the conditional branch on both pages are the same. This means if the time is > 5PM the event will disappear, but then you can interact with it and it will appear again, and then disappear again straight away. And if the time is 0, then the time IS less than 18, so your two parts to the conditional branch are also redundant.


I suggest you do the following ... allocate a variable to keep track of the game time. Create a new common event, set it to parallel process, and add the following commands:
Wait 60 Frames
Control Variables: (time variable) = Script: GameTime.hour?

This common event will cause the hour to be put into the variable every second while the game is running. You will need to allocate a switch, and turn on that switch at the start of the game, so it's always active. A parallel common event with a 60 frame (1 second) wait will not affect performance.

Now on your NPC event, create the first page with your NPC sprite and shop processing. Leave its trigger as Action Button.
Create a second event page with no sprite and no event commands. Leave its trigger as Action Button. In the event conditions, put Variable (time variable) >= 18.

So before 5:00 the NPC will be there, and you need to go up and interact with him to see the shop window. And after 5:00 the NPC will not be there. If the NPC happens to be on the screen, visible, when the hour changes from 4:00 to 5:00, the NPC will just disappear. Likewise, if the player is on the screen and near that spot when the hour goes from 11:00 to midnight, the NPC will just appear.

Note - without looking at the time system, wouldn't 5PM be 17 rather than 18? If it's hours since midnight, 18 would be 6PM.
Do note that I deleted the 2nd page event once before so I forgot to set it to Parallel Process. I understand what your idea for this is though. Thanks for the help. I Have one more question: Is there a way to do it without the common event? (Not saying the idea is bad. Just curious)
You shouldn't do any page of that event as a parallel process, unless you want it to come up automatically, without interacting with the NPC.

Common events are pretty much the same as map events, with a few small differences. The beauty of common events is that you can set up stuff to run over multiple maps. You could do the same thing with a map event set to parallel process (which would then not need a switch to be turned on to activate), but if you have events on a lot of maps that will appear and disappear or do different things based on the time of day, it's really better/easier to have a single common event rather than duplicate events on lots of maps.

And if you had set that second page to parallel process, it would continually be switching back and forth between the two pages prior to 5pm (or 6pm). You wouldn't see anything, but it might affect performance.
You shouldn't do any page of that event as a parallel process, unless you want it to come up automatically, without interacting with the NPC.

Common events are pretty much the same as map events, with a few small differences. The beauty of common events is that you can set up stuff to run over multiple maps. You could do the same thing with a map event set to parallel process (which would then not need a switch to be turned on to activate), but if you have events on a lot of maps that will appear and disappear or do different things based on the time of day, it's really better/easier to have a single common event rather than duplicate events on lots of maps.

And if you had set that second page to parallel process, it would continually be switching back and forth between the two pages prior to 5pm (or 6pm). You wouldn't see anything, but it might affect performance.
Ok, That makes since. I know this sounds like a stupid question, but would you be able to make the event and send me some pics of how to set it up. I do better seeing pics of how to set it up. (More of a visual learner, Sorry)
Sorry - not into that sort of thing (plus my cat pulled my hard drive off the desk and broke it and I can't even run RPG Maker right now). I think I explained it pretty well, so go back over my previous instructions, try it, and see how you go. If you get confused after trying, or it doesn't work, take a screenshot of the event and post it here and we'll take a look at it. To do a screenshot, use Alt+PrintScreen and don't crop anything away. This will provide the event in the best format, with all of the necessary information and nothing extra, which will save us a heap of time.
Sorry - not into that sort of thing (plus my cat pulled my hard drive off the desk and broke it and I can't even run RPG Maker right now). I think I explained it pretty well, so go back over my previous instructions, try it, and see how you go. If you get confused after trying, or it doesn't work, take a screenshot of the event and post it here and we'll take a look at it. To do a screenshot, use Alt+PrintScreen and don't crop anything away. This will provide the event in the best format, with all of the necessary information and nothing extra, which will save us a heap of time.
Ok, but the way I take screenshots is I use lightshot to take screenshots. I will try it out and see how it works.
Sure. Just make sure you capture the entire event window, including all the tabs and conditions and stuff. Don't crop it to just the event commands. Otherwise we'll have to ask you to do it again because some of that other stuff is really important too. But don't get the entire desktop background, because then that makes it too small to see the good stuff and we have to squint 🙂
Sure. Just make sure you capture the entire event window, including all the tabs and conditions and stuff. Don't crop it to just the event commands. Otherwise we'll have to ask you to do it again because some of that other stuff is really important too. But don't get the entire desktop background, because then that makes it too small to see the good stuff and we have to squint 🙂
IT WORKED
Thread closed

Original thread: https://forums.rpgmakerweb.com/threads/time-npcs.116852/