Jump to content

Running Scripts at an Interval


AltarofScience

Recommended Posts

I dug around, and I did find a function under advanced settings to run programs at minute periods. I didn't see advanced settings the first time. Not sure why.

If I want the program to run a php script on my server, how do I configure that? Do I just browse and have that program in the bar? Will it run the php like that?

Link to comment
Share on other sites

final question. econ code and possibly garbage collection are the only 2 things i need to run repeatedly. but for one off delays, what is my best bet? Basically ships have to fly through space to other planets. Although it would be nice to have them move across a coordinate plane over time, that is only necessary for the war and combat system, for the beta test colony system really all I need is to put a fleet on a timer, and then teleport it to the new location. this is not a problem, i just change the planet or colony location to make them accessible in the new area and not in the old.

But how do i put them on a timer? basically, when i click on the fleet page i have an element that says remaining travel time, and it needs to have a timer that counts down from the travel time in minutes, and when it reaches 0, activate the query to change the fleet location. i can't use schedule task for that, even a once off, as far as i'm aware, since the command comes from the player across the internet and not me from my computer.

Link to comment
Share on other sites

how would i be able to control the test of when its arrived? like, say i write a code,

 

//choose target location code

//find distance from current location code

//calculate flight time code

//create arrival time stamp code

 

//call time code

//call arrival timestamps

//whatever timestamps are <= current time then

//change planet location in database to target location

 

i doubt i can have it check every second whether anything has arrived. would it be a large server load if say i had 1000 fleets moving, so 1000 timestamps.

i could use windows task scheduler to compare stamps to current time every minute, or 5 minutes, or 10 minutes. would that require a larger amount of processing power than say, a 2 gigs of ram?

Link to comment
Share on other sites

You have an odd way of approaching these problems from an http perspective.

 

Next time you need to check which ships are at a given destination, also check which ships are on route to that destination. You can then check if that stamp is less than the current stamp.

-or-

Next time you check on that ship's status, check the stamp.

 

You don't need this information updated in real time. The only time you need to update the information is when a user checks it. At that point, you need to update any stale events that have happened since it was last checked.

Link to comment
Share on other sites

well, i do need to update this in real time. i blame myself for not communication the end goal though.

 

ships sent on a colony mission can land themselves, whether or not the player is online. and when the combat code is made, players fleets can interact whether either of the players or even any player at all, is online. combat is initiated by fleets being within a certain distance of another fleet. if i send a colony ship on a transfer mission, as long as i am not implementing combat, then yes i wouldn't have to check it until the player logged in, and went to it. and then i could run the check.

 

but if i want colony ships to colonize a planet as soon as they arrive at a planet, i need to be able to have the ship arrive within a small amount of time after it is supposed to.

 

if by http perspective you mean that for this kind of function i might want to run another kind of language, that is possible, but i'm trying to avoid it.

would it cause server load problems to run a query at an interval to see if a ship had arrived? aka, compare time stamps and current time.

Link to comment
Share on other sites

If you want to update in real time, you want a standalone game.

 

You are approaching this the wrong way. I'm saying it can 'appear' to update in real time without doing so.

 

I'll put this into basics.

 

14:00 - UserA sends ship to attack PlanetC owned by UserC. This process takes until 18:00

14:01 - UserA logs off

15:00 - UserB checks the status of PlanetC. The script checks for any ships en route to PlanetC. Since UserA's ship won't get there until 18:00, the script only shows UserC's ships at PlanetC

15:05 - UserB sends his ships to attack PlanetC. Will arrive at 18:30.

15:06 - UserB logs off

18:25 - UserC logs on, checks PlanetC. The script checks any ships en route to PlanetC. It finds UserA's ships arrived there 25 minutes ago, and UserB's will be there in 5 minutes. It then uses the battle algorithm to calculate the 25 minute battle that has been happening, and updates the script. It didn't matter WHAT user checked PlanetC, the same calculations would have been done.

18:26 - UserC logs out in anger.

18:35 - UserB logs in and checks on PlanetC. The script detects that UserB's ships arrived 5 minutes ago, and the planet has been under attack with a last update performed at 18:25. It then uses the battle algorithm again to determine what happened in the 5 minutes before UserB's ship arrived, then calculates the next 5 minutes including the 3rd ship...

 

Do you see what I mean? Things don't have to happen in real time if no one is there to see the changes. All you need to be sure of is that the information is current WHEN it's needed.

 

Object travels 200m at 2m/s. We don't need to update it's path in real time to know that 45 seconds after we start this event the object should be 90 meters along the path.

Link to comment
Share on other sites

okay that makes sense for the battle logic. sort of. but for the colony ship, on the colony mission, that arrives when no one is online, it needs to be affected by the econ system. if it doesn't exist how does that happen? when the player logs on does it just check that it has arrived and then run the econ script just on that colony multiple times related to how long its been since it landed and then display that?

Link to comment
Share on other sites

Why doesn't the economy script check to see if any new colony ships have landed BEFORE it calculates the increase?

 

I think you need to start over. You keep thinking about this as some sort of clock ticking rather than looking at it as a bunch of requests to a web server.

 

Program to the protocol, or you're going to be fighting it all the way.

Link to comment
Share on other sites

no i know that. but what i mean is, i need to be able to land a colony ship at any time from the last econ tick to the one coming up.

say there is a 24 minute interval. i want to be able to land the colony at 23-1 minutes as a player as well. so yes if the player is offline, letting the script land the colony before it ticks is fine. i guess i can just have a button that lands the colony manually, and let the script land the colonies otherwise.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.