diff --git a/src/Warden/JailPlayer.cs b/src/Warden/JailPlayer.cs index ec9391c..a8e23a9 100644 --- a/src/Warden/JailPlayer.cs +++ b/src/Warden/JailPlayer.cs @@ -35,6 +35,7 @@ public static void setup_db() { "ALTER TABLE config ADD COLUMN laser_colour varchar(64) DEFAULT 'Cyan'", "ALTER TABLE config ADD COLUMN marker_colour varchar(64) DEFAULT 'Cyan'", + "ALTER TABLE config ADD COLUMN ct_gun varchar(64) DEFAULT 'M4'", }; @@ -124,13 +125,14 @@ async Task load_player_db(String steam_id) query_steam_id.CommandText = "SELECT * FROM config WHERE steam_id = @steam_id"; query_steam_id.Parameters.AddWithValue("@steam_id",steam_id); - using var reader = await query_steam_id.ExecuteReaderAsync(); + using var reader = await query_steam_id.ExecuteReaderAsync(); if(reader.Read()) { // just override this laser_colour = Lib.LASER_CONFIG_MAP[(String)reader["laser_colour"]]; marker_colour = Lib.LASER_CONFIG_MAP[(String)reader["marker_colour"]]; + ct_gun = (String)reader["ct_gun"]; // don't try reloading the player cached = true; @@ -159,6 +161,8 @@ public void load_player(CCSPlayerController? player) return; } + // The database has allready been read before + // there is not need to do it again if(cached) { return; @@ -229,6 +233,7 @@ public void reset() // TODO: reset client specific settings laser_colour = Lib.CYAN; marker_colour = Lib.CYAN; + ct_gun = "M4"; } public void set_rebel(CCSPlayerController? player) @@ -239,14 +244,11 @@ public void set_rebel(CCSPlayerController? player) } // ignore if they are in lr - if(JailPlugin.global_ctx != null) + if(JailPlugin.lr.in_lr(player)) { - if(JailPlugin.lr.in_lr(player)) - { - return; - } + return; } - + // dont care if player is invalid if(!player.is_valid() || player == null) { @@ -327,5 +329,7 @@ public void player_hurt(CCSPlayerController? player, CCSPlayerController? attack public Color marker_colour { get; private set; } = Lib.CYAN; bool cached = false; + public String ct_gun = "M4"; + public bool is_rebel = false; }; diff --git a/src/Warden/Warden.cs b/src/Warden/Warden.cs index 0762088..be0c529 100644 --- a/src/Warden/Warden.cs +++ b/src/Warden/Warden.cs @@ -433,8 +433,14 @@ public void setup_player_guns(CCSPlayerController? player) { if(config.ct_guns) { + var jail_player = jail_player_from_player(player); + player.GiveNamedItem("weapon_deagle"); - player.GiveNamedItem("weapon_m4a1"); + + if(jail_player != null) + { + player.GiveNamedItem("weapon_" + Lib.gun_give_name(jail_player.ct_gun)); + } } if(config.ct_armour) @@ -526,6 +532,14 @@ public void ct_guns(CCSPlayerController player, ChatMenuOption option) player.strip_weapons(); + + var jail_player = jail_player_from_player(player); + + if(jail_player != null) + { + jail_player.update_player(player, "ct_gun", option.Text); + jail_player.ct_gun = option.Text; + } player.GiveNamedItem("weapon_" + Lib.gun_give_name(option.Text)); player.GiveNamedItem("weapon_deagle");