Jump to content
  • 0

Create a timer?


trollface

Question

I'm trying to create a global timer that items can check. But I'm having issues.

 

Has anyone done something like this before? I'm sure it's pretty simple, but I just can't get it to work. I'm probably using the wrong trigger commands or variables?

 

I want a common event with a constant taking variable that items and other entities can check.

 

Any ideas?

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 1

An alternative method (assuming you don't want to clog up your server with auto run events, which frankly you really should use as sparingly as possible!) is to use the API to check for time elapsed and flip some switches from there. 

 

It's a bit more complex but likely performs better long term.

Link to comment
Share on other sites

  • 0

You can create a common event "Time of the Server" on autorun that do : Change variable "Global Variable"  set on : "server time".

Here's a tutorial also :

 

Do not forget that the time used by the server is "'special", read carefully the tutorial, especially "How to add the date and time"

 

 

At last that's how i've done it, if there is better i'm interested too.

Link to comment
Share on other sites

  • 0

Not sure if what you posted can help me, but thank you for that tutorial! I will most def. look into that for future uses :)

Here is an example of what I need;

Player puts down an Item, a counter starts, and after 1 hour the item changes into another item. 

In other words;

I'm looking for a global timer that ticks constantly, and when a player places an event item on the ground, the event item starts counting those global ticks, and after one hour, the item turns itself into another item.

I've tried many different things, but I can't seem to get the timers to work.

Link to comment
Share on other sites

  • 0
39 minutes ago, trollface said:

Not sure if what you posted can help me, but thank you for that tutorial! I will most def. look into that for future uses :)

Here is an example of what I need;

Player puts down an Item, a counter starts, and after 1 hour the item changes into another item. 

In other words;

I'm looking for a global timer that ticks constantly, and when a player places an event item on the ground, the event item starts counting those global ticks, and after one hour, the item turns itself into another item.

I've tried many different things, but I can't seem to get the timers to work.

My referenced post can help you.
you will need 2 int variables, or 3

Creating a global variable to be the server time (machine), and creating a variable to be the time the player must wait to obtain the different item you can do that way.

commom event - global time - autorun
int "global time" set system time
wait Xms (x = some value for not overloading the server i believe)

event on the map - page 1
condition: int "change item" = 0

show option --- want to change the item?
yea
----- remove item
----- set int "change item" to = int global time
----- set int "change item" add = "1 hour in ms something like = 3600000 more or less"

no
exit process event

 

event on the map - page 2
condition: int "change item" != 0, int "change item" > int "global time"

show text - the item is not ready

 

event on the map - page 3
condition: int "change item" != 0, int "change item" < int "global time"

show text - your item is ready

give item

int "change item" = 0

 

if you intend to do this with many items, create a variable id, and check the id to find out which item to deliver to the player. My quoted tutorial is just a "core" you should analyze and create the function as I mentioned above. If you do exactly as I said above it still won't work, because of the page changes and page conditions, the logic is right, making it work on the intersect is another history, but it is possible

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...