chinagreenelvis
chinagreenelvis

Reputation: 105

Batch file formatting?

Why does this work:

set /a num = %random% %% 5 + 1

if %num% == 1 set map=cs_assault
if %num% == 2 set map=cs_italy
if %num% == 3 set map=cs_office
if %num% == 4 set map=de_aztec
if %num% == 5 set map=de_bank

srcds -game csgo -port 27016 -console +game_type 0 +game_mode 0 +mapgroup mg_casual +map %map%

But this doesn't?

set /a num = %random% %% 5 + 1

if %num% == 1 set map = cs_assault
if %num% == 2 set map = cs_italy
if %num% == 3 set map = cs_office
if %num% == 4 set map = de_aztec
if %num% == 5 set map = de_bank

srcds -game csgo -port 27016 -console +game_type 0 +game_mode 0 +mapgroup mg_casual +map %map%

I can't seem to wrap my brain around this at all.

Upvotes: 0

Views: 84

Answers (1)

Patrick Meinecke
Patrick Meinecke

Reputation: 4173

Because the second example is creating a variable called "map " not "map" and the value
" de_mapname" not "de_mapname"

So if you were to change

srcds -game csgo -port 27016 -console +game_type 0 +game_mode 0 +mapgroup mg_casual +map %map%

to

srcds -game csgo -port 27016 -console +game_type 0 +game_mode 0 +mapgroup mg_casual +map %map %

It would work, otherwise there is no variable map.

Upvotes: 2

Related Questions