Examples/Saving_data_with_a_HashTable

stats <- HashTable("stats");

function onPlayerJoin(player)
{
    local kills = stats.Get(player.Name + ".kills");
    if (kills == null) kills = 0;
    MessagePlayer("Welcome back! Lifetime kills: " + kills, player);
}

function onPlayerKill(killer, victim, weapon, bodypart)
{
    stats.Inc(killer.Name + ".kills");
    stats.Save("stats.txt");
}
Categories: Worked examples