Chris
Chris

Reputation: 33

Use BAT input later in script

I apologize if this is a) in the wrong section or b) a stupid question, but I've had little-to-no experience writing BAT files. I'm trying to make a simple startup script for a game (specifically TF2). The way it runs is it takes a bunch of parameters in the startup, but the one I care about it the map. I want it to start with "What map do you want?", then wait for an input, then simply put that input in place of where a map would go in the startup. I haven't been able to find this simple answer online so far, so here I am. Here's the current script.

tf2\srcds.exe -console -game tf +sv_pure 1 +map MAP_HERE +maxplayers 24

How should I go about writing something like this?

Upvotes: 2

Views: 254

Answers (1)

famousgarkin
famousgarkin

Reputation: 14116

Using SET:

SET /P map=What map do you want?
tf2\srcds.exe -console -game tf +sv_pure 1 +map %map% +maxplayers 24

SET /P variable=[promptString]

The /P switch allows you to set the value of a variable to a line of input entered by the user. Displays the specified promptString before reading the line of input. The promptString can be empty.

See cmd> set /? for more on SET.

Upvotes: 1

Related Questions