Sign in to follow this  
Followers 0
rayv

help with while processexists

4 posts in this topic

hi all

this script was made by someone on the game forum im a member of to start and run a game changing maps at regular intervals

the script itself seems to work fine its just the game itself is a bit buggy, so sometimes it crashes

the script below works fine but when the game has crashed continues to run the while process exists loop rather than starting from the beginning- which would restart the game

any ideas why?

; <COMPILER: v3.0.101.0>
$maxPlayers = IniRead("ServerTool.ini","vars","maxPlayers",8 )
$serverName = IniRead("ServerTool.ini","vars","serverName","Airfix_Dogfighter" )
$playerName = IniRead("ServerTool.ini","vars","playerName","Server" )
$setupWindowname = IniRead("ServerTool.ini","vars","setupWindowname","Airfix Dogfighter setup" )
$firstTime = IniRead("ServerTool.ini","vars","firstTime",1 )
$rootPath = IniRead("ServerTool.ini","path","dogfighterRoot","./" )
$timeLimit = IniRead("ServerTool.ini","maps","timeLimit",600 )
$levelName1 = IniRead("ServerTool.ini","maps","levelName1","the_flood" )
$levelName2 = IniRead("ServerTool.ini","maps","levelName2","" )
$levelName3 = IniRead("ServerTool.ini","maps","levelName3","" )
$levelName4 = IniRead("ServerTool.ini","maps","levelName4","" )
$levelName5 = IniRead("ServerTool.ini","maps","levelName5","" )
$setsettings=1

if ProcessExists("dogfighter.exe")<1 then
$step1 = FileOpen ( $rootPath & "ServerTool.cfg" , 2)
$st1 = "sets userlevel " & $levelName1 & @CRLF
$st2 = "sets maxplayers " & $maxPlayers & @CRLF
$st3 = "sets dogfight_timelimit 0" & @CRLF
$st4 = "sets fraglimit 0" & @CRLF
$st5 = "sets network true" & @CRLF
$st6 = "sets gamename " & $serverName & @CRLF
$st7 = "sets playername " & $playerName & @CRLF
$st8 = "sets mission Multiplayer" & @CRLF
$st9 = "server" & @CRLF
$st10 = "mode Dogfight" & @CRLF
$st11 = "sets show_debug 1" & @CRLF
$full_st = $st1 & $st2 & $st3 & $st4 & $st5 & $st6 & $st7 & $st8 & $st9 & $st10 & $st11
FileWrite ( $step1 , $full_st )
FileClose ( $step1 )
Run ( $rootPath & "Dogfighter.exe" ,$rootPath )
WinWaitActive( $setupWindowname )
WinActivate ( $setupWindowname )
ControlClick ( $setupWindowname, "&OK", "Button1" )
WinWaitActive( "Airfix Dogfighter" )
sleep(3000)
Send("{ENTER}")
Send("hacker")
Send("{BS 2}")
send("exec ServerTool.cfg{ENTER}")
sleep(50000)
$map2=1
$map3=1
$map4=1
$map5=1
If $levelName2="" then
$map2=0
endIf
If $levelName3="" then
$map3=0
endIf
If $levelName4="" then
$map4=0
endIf
If $levelName5="" then
$map5=0
endIf
While ProcessExists ("dogfighter.exe")
If $map2=1 then
$step1 = FileOpen ( $rootPath & "ServerTool.cfg" , 2)
$st1 = "sets userlevel " & $levelName2 & @CRLF
$st2 = "server" & @CRLF
$st3 = "mode Dogfight" & @CRLF
$full_st = $st1 & $st2 & $st3
FileWrite ( $step1 , $full_st )
FileClose ( $step1 )
sleep($timeLimit * 1000)
Send("{ENTER}")
Send("{F2}")
Send("MAP IS CHANGING TO " & $levelName2 & " AFTER 10 SECONDS!{ENTER}")
sleep(10000)
Send("hacker")
sleep(1000)
Send("{ENTER}")
send("exec ServerTool.cfg{ENTER}")
sleep(60000)
endIf
If $map3=1 then
$step1 = FileOpen ( $rootPath & "ServerTool.cfg" , 2)
$st1 = "sets userlevel " & $levelName3 & @CRLF
$st2 = "server" & @CRLF
$st3 = "mode Dogfight" & @CRLF
$full_st = $st1 & $st2 & $st3
FileWrite ( $step1 , $full_st )
FileClose ( $step1 )
sleep($timeLimit * 1000)
Send("{ENTER}")
Send("{F2}")
Send("MAP IS CHANGING TO " & $levelName3 & " AFTER 10 SECONDS!{ENTER}")
sleep(10000)
Send("hacker")
sleep(1000)
Send("{ENTER}")
send("exec ServerTool.cfg{ENTER}")
sleep(60000)
endIf
If $map4=1 then
$step1 = FileOpen ( $rootPath & "ServerTool.cfg" , 2)
$st1 = "sets userlevel " & $levelName4 & @CRLF
$st2 = "server" & @CRLF
$st3 = "mode Dogfight" & @CRLF
$full_st = $st1 & $st2 & $st3
FileWrite ( $step1 , $full_st )
FileClose ( $step1 )
sleep($timeLimit * 1000)
Send("{ENTER}")
Send("{F2}")
Send("MAP IS CHANGING TO " & $levelName4 & " AFTER 10 SECONDS!{ENTER}")
sleep(10000)
Send("hacker")
sleep(1000)
Send("{ENTER}")
send("exec ServerTool.cfg{ENTER}")
sleep(60000)
endIf
If $map5=1 then
$step1 = FileOpen ( $rootPath & "ServerTool.cfg" , 2)
$st1 = "sets userlevel " & $levelName5 & @CRLF
$st2 = "server" & @CRLF
$st3 = "mode Dogfight" & @CRLF
$full_st = $st1 & $st2 & $st3
FileWrite ( $step1 , $full_st )
FileClose ( $step1 )
sleep($timeLimit * 1000)
Send("{ENTER}")
Send("{F2}")
Send("MAP IS CHANGING TO " & $levelName5 & " AFTER 10 SECONDS!{ENTER}")
sleep(10000)
Send("hacker")
sleep(1000)
Send("{ENTER}")
send("exec ServerTool.cfg{ENTER}")
sleep(60000)
endIf
$step1 = FileOpen ( $rootPath & "ServerTool.cfg" , 2)
$st1 = "sets userlevel " & $levelName1 & @CRLF
$st2 = "server" & @CRLF
$st3 = "mode Dogfight" & @CRLF
$full_st = $st1 & $st2 & $st3
FileWrite ( $step1 , $full_st )
FileClose ( $step1 )
sleep($timeLimit * 1000)
Send("{ENTER}")
Send("{F2}")
Send("MAP IS CHANGING TO " & $levelName1 & " AFTER 10 SECONDS!{ENTER}")
sleep(10000)
Send("hacker")
sleep(1000)
Send("{ENTER}")
send("exec ServerTool.cfg{ENTER}")
sleep(60000)
WEnd
endif

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

sorry for double posting but i found an updated version of this script and cant delete or edit my previous post

again this works fine until the game is ended but then (at map change time) exits when it finds airfix dogfighter not running

if anyone is a genius and has a simple bit of code to add to it , which would make the script start from the beginning you would be :blink:

; ----------------------------------------------------------------------------
; Load Settings
; ----------------------------------------------------------------------------

; get the startup vars from the ini file
$maxPlayers = IniRead("ServerTool.ini","vars","maxPlayers",8)
$serverName = IniRead("ServerTool.ini","vars","serverName","Airfix_Dogfighter")
$playerName = IniRead("ServerTool.ini","vars","playerName","Server")
$setupWindowname = IniRead("ServerTool.ini","vars","setupWindowname","Airfix Dogfighter setup")
$loadingTime = IniRead("ServerTool.ini","vars","loadingTime",60)

; get the path from the ini file
$rootPath = IniRead("ServerTool.ini","path","dogfighterRoot","C:\Program Files\Paradox Entertainment\Airfix Dogfighter\")

; get maps from the ini file
$timeLimit = IniRead("ServerTool.ini","maps","timeLimit",600)
$levelName1 = IniRead("ServerTool.ini","maps","levelName1","Fight_Masters_2")
$levelName2 = IniRead("ServerTool.ini","maps","levelName2","")
$levelName3 = IniRead("ServerTool.ini","maps","levelName3","")
$levelName4 = IniRead("ServerTool.ini","maps","levelName4","")
$levelName5 = IniRead("ServerTool.ini","maps","levelName5","")
$levelName6 = IniRead("ServerTool.ini","maps","levelName6","")
$levelName7 = IniRead("ServerTool.ini","maps","levelName7","")
$levelName8 = IniRead("ServerTool.ini","maps","levelName8","")
$levelName9 = IniRead("ServerTool.ini","maps","levelName9","")
$levelName10 = IniRead("ServerTool.ini","maps","levelName10","")



; ----------------------------------------------------------------------------
; Start Script
; ----------------------------------------------------------------------------
If ProcessExists("Dogfighter.exe")<1 then

   ; First we have to write a file in the airfix dogfighter directory.....
   ; -- OPEN --
   ; The '2' means that we overwrite the file if it already exists.
   $step1 = FileOpen($rootPath&"ServerTool.cfg",2)

   $st0 = "log server_log.txt" & @CRLF
   $st1 = "sets userlevel " & $levelName1 & @CRLF
   $st2 = "sets maxplayers " & $maxPlayers & @CRLF
   $st3 = "sets dogfight_timelimit 0" & @CRLF
   $st4 = "sets fraglimit 0" & @CRLF
   $st5 = "sets network true" & @CRLF
   $st6 = "sets gamename " & $serverName & @CRLF
   $st7 = "sets playername " & $playerName & @CRLF
   $st8 = "sets mission Multiplayer" & @CRLF
   $st9 = "server" & @CRLF
   $st10 = "mode Dogfight" & @CRLF
   $st11 = "sets show_debug 1" & @CRLF
   $full_st = $st0 & $st1 & $st2 & $st3 & $st4 & $st5 & $st6 & $st7 & $st8 & $st9 & $st10 & $st11

   ; -- Write
   FileWrite($step1,$full_st)

   ; -- CLOSE
   FileClose($step1)

   ; END of the file operations

   ; now we run airfix dogfighter
   Run($rootPath&"Dogfighter.exe",$rootPath)

   ; and then we click on the OK button
   WinWaitActive($setupWindowname)
   WinActivate($setupWindowname)

   ControlClick($setupWindowname,"&OK","Button1")

   WinWaitActive("Airfix Dogfighter")

   ; Login
   sleep(3000)
   Send("{ENTER}")
   Send("hacker")
   Send("{BS 2}")
   send("exec ServerTool.cfg{ENTER}")

   ; Map rotation
   $map=1
   $running=1

   While $running=1
      If ProcessExists("Dogfighter.exe")>0 then
   
         If $map=1 Then
            $levelName = $levelName1
            If $levelName2="" then
               $map=1
            Else
               $map=2
            Endif
         ElseIf $map=2 then
            $levelName = $levelName2
            If $levelName3="" then
               $map=1
            Else
               $map=3
            Endif
         ElseIf $map=3 then
            $levelName = $levelName3
            If $levelName4="" then
               $map=1
            Else
               $map=4
            Endif
         ElseIf $map=4 then
            $levelName = $levelName4
            If $levelName5="" then
               $map=1
            Else
               $map=5
            Endif
         ElseIf $map=5 then
            $levelName = $levelName5
            If $levelName6="" then
               $map=1
            Else
               $map=6
            Endif
         ElseIf $map=6 then
            $levelName = $levelName6
            If $levelName7="" then
               $map=1
            Else
               $map=7
            Endif
         ElseIf $map=7 then
            $levelName = $levelName7
            If $levelName8="" then
               $map=1
            Else
               $map=8
            Endif
         ElseIf $map=8 then
            $levelName = $levelName8
            If $levelName9="" then
               $map=1
            Else
               $map=9
            Endif
         ElseIf $map=9 then
            $levelName = $levelName9
            If $levelName10="" then
               $map=1
            Else
               $map=10
            Endif
         ElseIf $map=10 then
            $levelName = $levelName10
            $map=1
         Endif
   
         $step1 = FileOpen($rootPath&"ServerTool.cfg",2)
         $st1 = "sets userlevel " & $levelName & @CRLF
         $st2 = "server" & @CRLF
         $st3 = "mode Dogfight" & @CRLF
         $full_st = $st1 & $st2 & $st3
         FileWrite($step1,$full_st)
         FileClose($step1)
         sleep($loadingTime * 1000)
         Send("{TAB 2}")
         Send("hacker")
         Send("{BS 2}")
         sleep($timeLimit * 1000)
         Send("message nextmap:" & $levelName & "{ENTER}")
         sleep(10000)
         send("exec ServerTool.cfg{ENTER}")
      Else
         $running=0
      Endif
   WEnd
   Exit
endif
Exit
Edited by rayv

Share this post


Link to post
Share on other sites

Exit

;):blink:

Share this post


Link to post
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
Sign in to follow this  
Followers 0