Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off & setlocal
- set "workDir=D:\Apache24\htdocs"
- @set /a "rdm=%random%"
- set /a "rdm=%random%"
- ::Push to your path.
- pushd "%workDir%"
- echo current directory is:
- cd
- pause
- ::Count all files in your path. (dir with /b shows only the filenames)
- echo Counting files in your path...
- set /a "counter=0"
- for /f "delims=" %%i in ('dir /a:-D /b ^|find "."') do (
- if "%%~xi"==".rom" call :sub1 &echo Rom found! That's number %counter%
- )
- ::This function gives a value from 1 to upper bound of files
- set /a "rdNum=(%rdm%*%counter%/32767)+1"
- set /a "counter=0"
- echo Finding random file...
- :: for /f "delims=" %%i in ('dir /a:-D /s /b ^|find "."') do set "fileName=%%i" &call :sub2
- :: for /f "delims=" %%i in ('dir /a:-D /b ^|find "kf-*.rom"') do set "fileName=%%i" &echo something like a string or something
- for /f "delims=" %%i in ('dir /a:-D /b ^|find "."') do (
- if "%%~xi"==".rom" set "fileName=%%i" &call :sub2
- )
- ::Pop back from your path.
- echo popd workDir
- popd "%workDir%"
- echo current directory is:
- cd
- pause
- echo not calling sub2 :(
- pause
- goto :eof
- :: end of main
- :: start of sub1
- :sub1
- ::For each found file set counter + 1.
- echo calling sub 1
- set /a "counter+=1"
- goto :eof
- :: end of sub1
- :: start of sub2
- :sub2
- echo calling sub2...
- ::1st: count again,
- ::2nd: if counted number equals random number then start the file.
- set /a "counter+=1"
- if %counter%==%rdNum% (
- echo File "%fileName%" found!
- echo "%fileName%" >> KFRandom.txt
- pause
- popd "%workDir%"
- echo Starting server with random map file...
- pause
- :: ucc server %fileName%?Mutator=MML.ML04?game=KFmod.KFGameType?VACSecured=true?MaxPlayers=12?MinPlayers=12?AdminName=nd2spd?AdminPassword=adminpasswordhere -log=server.log
- echo server starts here
- pause
- )
- goto :eof
- :: end of sub2
Advertisement
Add Comment
Please, Sign In to add comment