Jump to content
Skoven

How can my script only work sometimes?

Recommended Posts

Skoven

Hello!

Im new to autoit. I have been trying to make a small script for saving and backing up a small minecraft server im hosting. I've tried making this Work for several days now, without luck. The thing is, i have more or less made a working script now. But sometimes the script only does some of the Things its supposed to, and other times it runs the Whole thing without issue. I have no idea what the cause of this is, since nothing is changing on my server.

 

My code is as follows:

#RequireAdmin

Global $variabel = 0


While 1
   if WinExists("C:\Windows\system32\cmd.exe") Then
   WinClose("C:\Windows\system32\cmd.exe")
EndIf
   Sleep(2000)
   Run("F:\FTB\ServerStart.bat")
   Sleep(180000)
   While $variabel < 7
   WinActivate("C:\Windows\system32\cmd.exe")
   Send("say Server is saving, please standby..")
   Send("{ENTER}")
   Sleep(1000)
   Send("save-off")
   Send("{ENTER}")
   Sleep(1000)
   Send("save-all")
   Send("{ENTER}")
   Sleep(5000)
   Run("F:\FTB\ServerBackup.bat")
   Sleep(20000)
   Send("save-on")
   Send("{ENTER}")
   Sleep(500)
   Send("say Done saving..")
   Send("{ENTER}")
   $variabel += 1
   Sleep(900000)
   WEnd
   If $variabel = 7 Then
   WinActivate("C:\Windows\system32\cmd.exe")
   Send("say Server is restarting in 15 minutes. Please log out before that time")
   Send("{ENTER}")
   Sleep(300000)
   WinActivate("C:\Windows\system32\cmd.exe")
   Send("say Server is restarting in 10 minutes. Please log out before that time")
   Send("{ENTER}")
   Sleep(300000)
   WinActivate("C:\Windows\system32\cmd.exe")
   Send("say Server is restarting in 5 minutes. Please log out before that time")
   Send("{ENTER}")
   Sleep(60000)
   WinActivate("C:\Windows\system32\cmd.exe")
   Send("say Server is restarting in 4 minutes. Please log out before that time")
   Send("{ENTER}")
   Sleep(60000)
   WinActivate("C:\Windows\system32\cmd.exe")
   Send("say Server is restarting in 3 minutes. Please log out before that time")
   Send("{ENTER}")
   Sleep(60000)
   WinActivate("C:\Windows\system32\cmd.exe")
   Send("say Server is restarting in 2 minutes. Please log out now")
   Send("{ENTER}")
   Sleep(60000)
   WinActivate("C:\Windows\system32\cmd.exe")
   Send("say Server is restarting in 1 minutes. Please log out now")
   Send("{ENTER}")
   Sleep(60000)
   WinActivate("C:\Windows\system32\cmd.exe")
   Send("say RESTARTING NOW!")
   Send("{ENTER}")
   Sleep(5000)
   Send("save-off")
   Send("{ENTER}")
   Sleep(5000)
   Send("save-all")
   Send("{ENTER}")
   Sleep(10000)
   Send("stop")
   Send("{ENTER}")
   Sleep(10000)
   Send("{ENTER}")
   Sleep(1000)
   Run("F:\FTB\ServerBackup.bat")
   Sleep(10000)
   EndIf
WEnd

 

It is a shitty code i know. The reason im caling Winactivate on each input, is because i thought that might the cause of my problems. But it seems i doesnt.

 

Im basically trying to start my server from the script, then save an backup a few times, and then end it with restarting server by closing it. Its run through console, hence the use of "Send" commands.

 

I've tried solving this by myself without luck, and now i hope for someone to enligthen me, as im sure the fault lies between my chair and my keyboard.

 

Hope to hear from you, Cheers.

Edited by Melba23
Added code tags

Share this post


Link to post
Share on other sites
TheDcoder

Please read the forum rules, Game Automation is not allowed

 

TD :)


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) mean to do that to anybody!!!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites
water

I'm not sure this is against the forum rules. He just does a backup of a game server.
Let's see what the Mods say.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
TheDcoder

Remember, when my topic was locked by smoke_n? ;)

Edited by TheDcoder
correction

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) mean to do that to anybody!!!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites
czardas

I concur with Water. It is not so easy to view this as game automation.

Edited by czardas

Share this post


Link to post
Share on other sites
czardas

Remember, when my topic was locked by smoke_n? ;)

​He is entitled to do that.

Share this post


Link to post
Share on other sites
Skoven

Im sorry i didnt think it would go under these rules, as im just trying to maintain my server. I'll just have to sort it myself then.

Im sorry for any inconvenience.

Share this post


Link to post
Share on other sites
water

Skoven,

let's see what a Moderator says. I've reported this thread and I'm sure soon a Mod will post his opinion :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Juvigy

The problem is your winactivate and send - you shouldnt use them.

As i can see you are only starting cmd commands . For example Runwait or Run:

RunWait(@comspec & " /c say RESTARTING NOW! ",@sw_hide)

Share this post


Link to post
Share on other sites
TheDcoder

@Jos So, is it a Green Signal?


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) mean to do that to anybody!!!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites
Jos

@Jos So, is it a Green Signal?

​Not sure which part of my post was unclear to you, but you are slowly getting on my nerves with your posting style lately, so please back off and only post in a thread when you have actually something substantial to contribute. This is a statement and does not require response in this thread and when you want to discuss anything you can do it in PM with me.

Jos

Edited by Jos
  • Like 1

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Skoven

The problem is your winactivate and send - you shouldnt use them.

As i can see you are only starting cmd commands . For example Runwait or Run:

RunWait(@comspec & " /c say RESTARTING NOW! ",@sw_hide)

​I'll admit i don't know what you are talking about. As i just said, i've just started using autoit, and as such the programming language is still very foreign to me.

 

Problem is, the minecraft server runs as a command console, therefore im forced to "Send" the commands to the console, because the minecraft server runs within. I'm not sure if that helped anything or not.

 

Appreciate the help though.

Share this post


Link to post
Share on other sites
232showtime

I concur with Water. It is not so easy to view this as game automation.

I'll let it go for the moment but please make sure we stay without the scope of our forum rules!

Jos

​so what about this???

FORUM RULES:

  • Launching, automation or script interaction with games or game servers, regardless of the game.
Edited by 232showtime

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Share this post


Link to post
Share on other sites
czardas

​​so what about this???

FORUM RULES:

  • Launching, automation or script interaction with games or game servers, regardless of the game.

​Ah! Not game automation, but interaction with a game server. I don't know enough about the subject, but I fail to see any game-play advantage gained by a backup script. Strictly speaking you are right though.

Edited by czardas

Share this post


Link to post
Share on other sites
Skoven

All right, it seems people find it more entertaining punching rules, than helping in here, event though everyone knows im just trying to communicate with a command promt. Will an admin please delete this thread..

Edited by Skoven

Share this post


Link to post
Share on other sites
Melba23

232showtime,

When a Mod has already said only a few posts above yours that the thread is legal, why on earth do you feel the need to jump in and start the discussion all over again?

Skoven,

As you may have noticed, gaming is a very touchy subject here and some wannabee-Mods get all excited about any hint of  it.  You have both active Mods saying that the thread is permissible so, given that this one is now so polluted, I suggest you start a new one and link to this one to show that the question is allowed. I will lock this one to prevent any more silliness.

BEWARE: anyone who starts off questioning the legality of the new thread is going to get very short shrift indeed.

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Jos

​so what about this???

FORUM RULES:

  • Launching, automation or script interaction with games or game servers, regardless of the game.

​Sending me a PM saying you sorry for " quoting me" and "Just asking"  doesn't mean much since you did more than that. You are actually questioning me!

I will be the first one to admit that I make mistakes on a regular basis, but in case anyone feels that has happened it would be nice when a nice constructive PM is send on that in stead of a reply like this.

Next time I am questioned like this, that member will get a short vacation from these forum as I seriously don't think anybody of the team has to account for these type of decisions to you or anybody else other than the other teammembers.

Jos

 


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×