1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
<?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>SetPlrExtraData</title>
<category>Player</category>
<version>5.1 OC<extversion>5.2 OC</extversion></version>
<syntax>
<rtype>any</rtype>
<params>
<param>
<type>int</type>
<name>player</name>
<desc>Player for whom additional data is saved.</desc>
</param>
<param>
<type>string</type>
<name>data_name</name>
<desc>Name for the data.</desc>
</param>
<param>
<type>any</type>
<name>Data</name>
<desc>Data to be saved.</desc>
</param>
</params>
</syntax>
<desc>With this function additional data can be saved in player's file. This can be used to preserve values across scenarios, for example for RPGs or highscores. If successful, the saved value is returned.</desc>
<remark>No objects or arrays may be saved.</remark>
<remark>Because all scenarios use the same storage, the name for the data should be prefixed with the scenario name or your developer id.</remark>
<examples>
<example>
<code>func SaveWealth()
{
for(var i=0; i<<funclink>GetPlayerCount</funclink>(); i++)
SetPlrExtraData(i, "MySzen_Wealth", <funclink>GetWealth</funclink>(i));
}
func Initialize()
{
for(var i=0; i<<funclink>GetPlayerCount</funclink>(); i++)
<funclink>SetWealth</funclink>(i, <funclink>GetPlrExtraData</funclink>(i, "MySzen_Wealth"));
}
</code>
<text>The first function saves the wealth with the name "MySzen_Wealth" into the player's file. It should be called on periodically or on the end of the round. If the round is restarted, the wealth is restored in Initialize.</text>
</example>
</examples>
<related>
<funclink>GetPlrExtraData</funclink>
<funclink>SetCrewExtraData</funclink>
</related>
</func>
<author>PeterW</author><date>2002-01</date>
</funcs>
|