# CreateScriptPlayer

Player
5.1 OC
bool
string name Name for the script player. Required.
int color Player color
int team Team-Id. If 0, a team is automatically chosen according to the rules also applied to normal joining players.
int flags Bit mask composed of the following values:

Bit
Constant
Description
0
CSPF_FixedAttributes
If set, the player is guaranteed to join with the name and color specified in the parameters. Otherwise those preferences might be ignored in case of conflicts with other players' preferences.
1
CSPF_NoScenarioInit
If true, the scenario initialization (i.e. placement of home base material, clonks, setting of build knowledge, etc.) is not performed for this player. Also, the global callbacks PreInitializePlayer and InitializePlayer to the scenario script and to goal, rule, and environment objects are not performed. Instead, the callback InitializeScriptPlayer(Player number, Team) is made to the object definition specified in extra_data. Using this parameter you can create script-controlled AI players which do not receive the same standard treatment as user-controlled players.
2
CSPF_NoEliminationCheck
If set, the player will not be eliminated automatically if its crew is empty.
3
CSPF_Invisible
If set, the player will not show up in player lists such as in the lobby or hostility menu.

id extra_data Id which is passed to the InitializePlayer call. Using this id, it is quite simple to create different types of script players. E.g. a scenario could feature AI players with different types of crew members.
Initializes a joining script player. Script players appear as regular players from the scripting point of view. They have a crew, wealth, build knowledge, home base material, hostility, teams, etc. However, script players do not have a game view port and they can not be controlled by human users.
Script players can be used to create AI controlled opponent teams in special scenarios.
As do normal players, script player join with a slight delay in network games. This means that following the call to CreateScriptPlayer the player will not be immediately available.
That means, actual initialization of that player should happen in the InitializePlayer callback which can use GetPlayerType() to check whether this is a script player.
If the script player really needs to be available even before normal player initialization - e.g. as opponent in a single player mission - you could create the player via the SavePlayerInfos.txt component.
For examples see Script Players.
Script Player
GetPlayerType
Sven2
2007-12