<?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&lt;<funclink>GetPlayerCount</funclink>(); i++)
    SetPlrExtraData(i, &quot;MySzen_Wealth&quot;, <funclink>GetWealth</funclink>(i));
}

func Initialize()
{
  for(var i=0; i&lt;<funclink>GetPlayerCount</funclink>(); i++)
    <funclink>SetWealth</funclink>(i, <funclink>GetPlrExtraData</funclink>(i, &quot;MySzen_Wealth&quot;));
}
  </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>
