Skip to content

Commit 0faba13

Browse files
authored
v 0.8.1
1 parent c708f03 commit 0faba13

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

PlayerSettings/CPlayerSettings.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,20 @@ internal class CPlayerSettings
1717
public CPlayerSettings(CCSPlayerController _player)
1818
{
1919
player = _player;
20+
userid = -1;
2021
Storage.GetUserIdAsync(player, (userid) => this.userid = userid);
2122
cached_values = new Dictionary<string, string>();
2223
}
2324

2425
public string GetValue(string param, string default_value)
2526
{
2627
string value;
27-
if(!cached_values.TryGetValue(param, out value))
28-
{
29-
value = Storage.GetUserSettingValue(userid, param, default_value);
28+
if(!cached_values.TryGetValue(param, out value) || value == null)
29+
{
30+
value = default_value;
3031
cached_values[param] = value;
3132
}
32-
33+
3334
return value;
3435
}
3536

PlayerSettings/Main.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void OnConfigParsed(PluginConfig config)
2929
}
3030

3131
public override string ModuleName => "PlayerSettings [Core]";
32-
public override string ModuleVersion => "0.8";
32+
public override string ModuleVersion => "0.8.1";
3333
public override string ModuleAuthor => "Nick Fox";
3434
public override string ModuleDescription => "One storage for player's settings (aka ClientCookies)";
3535

@@ -39,8 +39,11 @@ public override void Load(bool hotReload)
3939
{
4040
_api = new SettingsApi();
4141
Capabilities.RegisterPluginCapability(_pluginCapability, () => _api);
42+
RegisterListener<Listeners.OnClientAuthorized>(OnClientAuthorized);
4243

43-
RegisterListener<Listeners.OnClientAuthorized>(OnClientAuthorized);
44+
if (hotReload)
45+
foreach (var player in Utilities.GetPlayers())
46+
OnClientAuthorized(player.Slot, player.AuthorizedSteamID);
4447
}
4548

4649
public override void Unload(bool hotReload)

PlayerSettings/SettingsApi.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ internal void LoadOnConnect(CCSPlayerController player)
6666
{
6767
var user = FindUser(player);
6868

69-
Storage.LoadSettings(user.UserId(), (vars) => user.ParseLoadedSettings(vars, actions));
69+
Task.Run(() => { while (user.UserId() == -1) Thread.Sleep(50); }).ContinueWith((_) =>
70+
Storage.LoadSettings(user.UserId(), (vars) => user.ParseLoadedSettings(vars, actions))
71+
);
7072
}
7173

7274
public void RegisterTogglableSetting(string name, string viewName)

PlayerSettings/Storage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ internal static void LoadSettings(int userid, Action<List<List<string>>> action)
7474
}
7575

7676

77-
77+
/*
7878
public static string GetUserSettingValue(int userid, string param, string default_value)
7979
{
8080
var res = db.Query("SELECT `value` FROM `settings_values` WHERE `user_id` = {ARG} AND `param` = '{ARG}'", new List<string>([userid.ToString(), param]));
@@ -84,7 +84,7 @@ public static string GetUserSettingValue(int userid, string param, string defaul
8484
return default_value;
8585
}
8686
return res[0][0];
87-
}
87+
}*/
8888

8989
public static void SetUserSettingValue(int userid, string param, string value)
9090
{

0 commit comments

Comments
 (0)