First mapscript

You always need a script_multiplayer in your map in order to make your mapscript
work. Then, of course, you also need a mapscript.

So, i show you how to do this in this tutorial. A prefab for this tutorial is
available here: prefab_first_map

First: preparations in Radiant. This requires a working map (sealed off, you
know, all that stuff). Then you need one script_multiplayer in it. Put it in,
then assign a scriptname called “game_manager” to it. This should sound familiar
to you if have read the tuto “how most stuff works”. Following shows that
scriptname assignment and how it should look like:

1405267652_5_FT1663_02_script_multiplayer_s600

Second: the actual scripting part. Copy the following in a normal text file and
rename that text file to mapname.script.

game_manager
{
spawn
{
// basic wait command - add this in every spawn event
// (more on this later)
wait 200
// respawn times
wm_allied_respawntime 1
wm_axis_respawntime 1// timelimit
wm_set_round_timelimit 20// Winner on expiration of round timer (0=Axis, 1=Allies)
wm_setwinner 0
}
}

Remember to replace by your actual mapname. Example: your map is named
coolmap.bsp. Then your script file needs to be named coolmap.script. Now place
that script file in the same folder as your .bsp mapfile (that is the
maps-folder).

Look at the code now: you should already know that the game_manager section
embraced by the two curly brackets { and } is belonging to your
script_multiplayer entity. After all, you assigned a scriptname called
game_manager to it.

Now check out the section called “spawn” inside game_manager. As you might
recall with the death event from the previous tutorial “how most stuff works”,
spawn is also an event. And this one gets triggered when the entity first spawns
into the world (so that is when the map starts).

So the map loads and your map starts. The script_multiplayer entity then
triggers its spawn event and voila: we are inside the script. Here is what this
script will do. Most of this is self-explanatory, but i add an explanation
anyway. Something here and there might not be so clear at first.

– wait command: the first command you see is a “wait 200”. This one makes your
script wait for 200 milliseconds until it keeps executing the next line of code.
This is needed for a specific reason: it has todo with initialization time of
the entity. The entity is simply not yet ready to have code executed, because
it is too early. So we set a wait 200 there to make the script wait a bit.

– respawn times: here we have two commands for the two teams:
“wm_allied_respawntime 1” and “wm_axis_respawntime 1”. It means the respawn
time of the said team will be 1 second.

– timelimit: here you set a round timelimit of 20 seconds.
200 milliseconds

– winner: if the round time expires, “wm_setwinner 0” says this map will have
the winner to be axis.

Remember the wait command. Set it on every entities spawn event.

When you now look above, you will realize, that the script_multiplayer and its
game_manager section inside the script are responsible for game settings. This
is just a convention you should follow. I think there are some details to it,
but not worth to spend time on it.

Note that this is a very basic script. If you are brave, you might already
now take a look at some mapscripts of the vanilla maps to see how it will
probably look like with your own map in the future.