forked from Mirrors/openclonk
Added GetStartupPlayerCount script function
parent
c64afb8626
commit
9e9e05f492
|
@ -26,6 +26,7 @@
|
|||
</example>
|
||||
</examples>
|
||||
<related>
|
||||
<funclink>GetStartupPlayerCount</funclink>
|
||||
<funclink>GetPlayerName</funclink>
|
||||
<funclink>GetPlayerByIndex</funclink>
|
||||
<funclink>EliminatePlayer</funclink>
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<!DOCTYPE funcs
|
||||
SYSTEM '../../../clonk.dtd'>
|
||||
<?xml-stylesheet type="text/xsl" href="../../../clonk.xsl"?>
|
||||
<funcs>
|
||||
<func>
|
||||
<title>GetStartupPlayerCount</title>
|
||||
<category>Player</category>
|
||||
<version>5.4 OC</version>
|
||||
<syntax>
|
||||
<rtype>int</rtype>
|
||||
</syntax>
|
||||
<desc>Returns the number of players scheduled to join the game when it intiially started. This value is determined before game start, so it can be used in early scenario initialization functions such as Initialize or InitializeMap.</desc>
|
||||
<remark>The startup player count is not updated when a savegame is resumed with a different number of players.</remark>
|
||||
<remark>The number of players actually joining the game might be lower due to clients disconnecting at game start or players trying to join with invalid player files. To get a reliable number of players, handle player joins and leaves directly in InitializePlayer and RemovePlayer callbacks or call <funclink>GetPlayerByCount</funclink> shortly after game start.</remark>
|
||||
<related>
|
||||
<funclink>GetPlayerCount</funclink>
|
||||
</related>
|
||||
</func>
|
||||
<author>Sven2</author><date>2013-03</date>
|
||||
</funcs>
|
|
@ -2262,6 +2262,12 @@ static C4String *FnGetPlayerControlAssignment(C4PropList * _this, long player, l
|
|||
return String(assignment->GetKeysAsString(human_readable, short_name).getData());
|
||||
}
|
||||
|
||||
static int32_t FnGetStartupPlayerCount(C4PropList * _this)
|
||||
{
|
||||
// returns number of players when game was initially started
|
||||
return ::Game.StartupPlayerCount;
|
||||
}
|
||||
|
||||
extern C4ScriptConstDef C4ScriptGameConstMap[];
|
||||
extern C4ScriptFnDef C4ScriptGameFnMap[];
|
||||
|
||||
|
@ -2424,6 +2430,7 @@ void InitGameFunctionMap(C4AulScriptEngine *pEngine)
|
|||
AddFunc(pEngine, "SetPlayerControlEnabled", FnSetPlayerControlEnabled);
|
||||
AddFunc(pEngine, "GetPlayerControlEnabled", FnGetPlayerControlEnabled);
|
||||
AddFunc(pEngine, "GetPlayerControlAssignment", FnGetPlayerControlAssignment);
|
||||
AddFunc(pEngine, "GetStartupPlayerCount", FnGetStartupPlayerCount);
|
||||
AddFunc(pEngine, "PlayerObjectCommand", FnPlayerObjectCommand);
|
||||
AddFunc(pEngine, "EditCursor", FnEditCursor);
|
||||
|
||||
|
|
Loading…
Reference in New Issue