nd4spd

KFRandom.bat

Oct 13th, 2025 (edited)
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.75 KB | Software | 0 0
  1. @echo off & setlocal
  2. set "workDir=D:\Apache24\htdocs"
  3. @set /a "rdm=%random%"
  4. set /a "rdm=%random%"
  5. ::Push to your path.
  6. pushd "%workDir%"
  7. echo current directory is:
  8. cd
  9. pause
  10. ::Count all files in your path. (dir with /b shows only the filenames)
  11. echo Counting files in your path...
  12. set /a "counter=0"
  13. for /f "delims=" %%i in ('dir /a:-D /b ^|find "."') do (
  14.     if "%%~xi"==".rom" call :sub1 &echo Rom found! That's number %counter%
  15. )
  16. ::This function gives a value from 1 to upper bound of files
  17. set /a "rdNum=(%rdm%*%counter%/32767)+1"
  18. set /a "counter=0"
  19. echo Finding random file...
  20. :: for /f "delims=" %%i in ('dir /a:-D /s /b ^|find "."') do set "fileName=%%i" &call :sub2
  21. :: for /f "delims=" %%i in ('dir /a:-D /b ^|find "kf-*.rom"') do set "fileName=%%i" &echo something like a string or something
  22. for /f "delims=" %%i in ('dir /a:-D /b ^|find "."') do (
  23.     if "%%~xi"==".rom" set "fileName=%%i" &call :sub2
  24. )
  25. ::Pop back from your path.
  26. echo popd workDir
  27. popd "%workDir%"
  28. echo current directory is:
  29. cd
  30. pause
  31. echo not calling sub2 :(
  32. pause
  33. goto :eof
  34. :: end of main
  35. :: start of sub1
  36. :sub1
  37. ::For each found file set counter + 1.
  38. echo calling sub 1
  39. set /a "counter+=1"
  40. goto :eof
  41. :: end of sub1
  42. :: start of sub2
  43. :sub2
  44. echo calling sub2...
  45. ::1st: count again,
  46. ::2nd: if counted number equals random number then start the file.
  47. set /a "counter+=1"
  48. if %counter%==%rdNum% (
  49. echo File "%fileName%" found!
  50. echo "%fileName%" >> KFRandom.txt
  51. pause
  52. popd "%workDir%"
  53. echo Starting server with random map file...
  54. pause
  55. :: ucc server %fileName%?Mutator=MML.ML04?game=KFmod.KFGameType?VACSecured=true?MaxPlayers=12?MinPlayers=12?AdminName=nd2spd?AdminPassword=adminpasswordhere -log=server.log
  56. echo server starts here
  57. pause
  58. )
  59. goto :eof
  60. :: end of sub2
Advertisement
Add Comment
Please, Sign In to add comment