SetPlrExtraData

Category: Player
Since engine version: 1.0 OC (extended in 2.0 OC)

Description

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.

Syntax

any SetPlrExtraData(int player, string data_name, any Data);

Parameters

player:
Player for whom additional data is saved.
data_name:
Name for the data.
Data:
Data to be saved.

Remarks

No objects or arrays may be saved.
Because all scenarios use the same storage, the name for the data should be prefixed with the scenario name or your developer id.

Example

func SaveWealth()
{
  for(var i=0; i<GetPlayerCount(); i++)
    SetPlrExtraData(i, "MySzen_Wealth", GetWealth(i));
}

func Initialize()
{
  for(var i=0; i<GetPlayerCount(); i++)
    SetWealth(i, GetPlrExtraData(i, "MySzen_Wealth"));
}
  
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.
See also: GetPlrExtraData, SetCrewExtraData
PeterW, 2002-01