mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-02-17 18:39:07 +00:00
CSS 121, languages and more
This commit is contained in:
60
Commands.cs
60
Commands.cs
@@ -1,7 +1,5 @@
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Commands;
|
||||
using CounterStrikeSharp.API.Modules.Entities.Constants;
|
||||
using CounterStrikeSharp.API.Modules.Memory;
|
||||
using CounterStrikeSharp.API.Modules.Menu;
|
||||
|
||||
namespace WeaponPaints
|
||||
@@ -12,7 +10,6 @@ namespace WeaponPaints
|
||||
{
|
||||
if (!Config.Additional.CommandWpEnabled || !Config.Additional.SkinEnabled || !g_bCommandsAllowed) return;
|
||||
if (!Utility.IsPlayerValid(player)) return;
|
||||
string temp = "";
|
||||
if (player == null || player.Index <= 0) return;
|
||||
int playerIndex = (int)player!.Index;
|
||||
|
||||
@@ -37,17 +34,15 @@ namespace WeaponPaints
|
||||
|
||||
RefreshWeapons(player);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(Config.Messages.SuccessRefreshCommand))
|
||||
if (!string.IsNullOrEmpty(Localizer["wp_command_refresh_done"]))
|
||||
{
|
||||
temp = $" {Config.Prefix} {Config.Messages.SuccessRefreshCommand}";
|
||||
player!.PrintToChat(Utility.ReplaceTags(temp));
|
||||
player!.Print(Localizer["wp_command_refresh_done"]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(Config.Messages.CooldownRefreshCommand))
|
||||
if (!string.IsNullOrEmpty(Localizer["wp_command_cooldown"]))
|
||||
{
|
||||
temp = $" {Config.Prefix} {Config.Messages.CooldownRefreshCommand}";
|
||||
player!.PrintToChat(Utility.ReplaceTags(temp));
|
||||
player!.Print(Localizer["wp_command_cooldown"]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,22 +51,18 @@ namespace WeaponPaints
|
||||
if (!Config.Additional.SkinEnabled) return;
|
||||
if (!Utility.IsPlayerValid(player)) return;
|
||||
|
||||
string temp;
|
||||
if (!string.IsNullOrEmpty(Config.Messages.WebsiteMessageCommand))
|
||||
if (!string.IsNullOrEmpty(Localizer["wp_info_website"]))
|
||||
{
|
||||
temp = $" {Config.Prefix} {Config.Messages.WebsiteMessageCommand}";
|
||||
player!.PrintToChat(Utility.ReplaceTags(temp));
|
||||
player!.Print(Localizer["wp_info_website", Config.Website]);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(Config.Messages.SynchronizeMessageCommand))
|
||||
if (!string.IsNullOrEmpty(Localizer["wp_info_refresh"]))
|
||||
{
|
||||
temp = $" {Config.Prefix} {Config.Messages.SynchronizeMessageCommand}";
|
||||
player!.PrintToChat(Utility.ReplaceTags(temp));
|
||||
player!.Print(Localizer["wp_info_refresh"]);
|
||||
}
|
||||
if (!Config.Additional.KnifeEnabled) return;
|
||||
if (!string.IsNullOrEmpty(Config.Messages.KnifeMessageCommand))
|
||||
if (!string.IsNullOrEmpty(Localizer["wp_info_knife"]))
|
||||
{
|
||||
temp = $" {Config.Prefix} {Config.Messages.KnifeMessageCommand}";
|
||||
player!.PrintToChat(Utility.ReplaceTags(temp));
|
||||
player!.Print(Localizer["wp_info_knife"]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +97,7 @@ namespace WeaponPaints
|
||||
.Where(pair => pair.Key.StartsWith("weapon_knife") || pair.Key.StartsWith("weapon_bayonet"))
|
||||
.ToDictionary(pair => pair.Key, pair => pair.Value);
|
||||
|
||||
var giveItemMenu = new ChatMenu(Utility.ReplaceTags($" {Config.Messages.KnifeMenuTitle}"));
|
||||
var giveItemMenu = new ChatMenu(Localizer["wp_knife_menu_title"]);
|
||||
var handleGive = (CCSPlayerController? player, ChatMenuOption option) =>
|
||||
{
|
||||
if (Utility.IsPlayerValid(player))
|
||||
@@ -116,18 +107,14 @@ namespace WeaponPaints
|
||||
var knifeKey = knivesOnly.FirstOrDefault(x => x.Value == knifeName).Key;
|
||||
if (!string.IsNullOrEmpty(knifeKey))
|
||||
{
|
||||
string temp = "";
|
||||
|
||||
if (!string.IsNullOrEmpty(Config.Messages.ChosenKnifeMenu))
|
||||
if (!string.IsNullOrEmpty(Localizer["wp_knife_menu_select"]))
|
||||
{
|
||||
temp = $" {Config.Prefix} {Config.Messages.ChosenKnifeMenu}".Replace("{KNIFE}", knifeName);
|
||||
player!.PrintToChat(Utility.ReplaceTags(temp));
|
||||
player!.Print(Localizer["wp_knife_menu_select", knifeName]);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(Config.Messages.ChosenKnifeMenuKill) && Config.Additional.CommandKillEnabled)
|
||||
if (!string.IsNullOrEmpty(Localizer["wp_knife_menu_kill"]) && Config.Additional.CommandKillEnabled)
|
||||
{
|
||||
temp = $" {Config.Prefix} {Config.Messages.ChosenKnifeMenuKill}";
|
||||
player!.PrintToChat(Utility.ReplaceTags(temp));
|
||||
player!.Print(Localizer["wp_knife_menu_kill"]);
|
||||
}
|
||||
|
||||
PlayerInfo playerInfo = new PlayerInfo
|
||||
@@ -166,10 +153,9 @@ namespace WeaponPaints
|
||||
ChatMenus.OpenMenu(player, giveItemMenu);
|
||||
return;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(Config.Messages.CooldownRefreshCommand))
|
||||
if (!string.IsNullOrEmpty(Localizer["wp_command_cooldown"]))
|
||||
{
|
||||
string temp = $" {Config.Prefix} {Config.Messages.CooldownRefreshCommand}";
|
||||
player.PrintToChat(Utility.ReplaceTags(temp));
|
||||
player!.Print(Localizer["wp_command_cooldown"]);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -177,7 +163,7 @@ namespace WeaponPaints
|
||||
private void SetupSkinsMenu()
|
||||
{
|
||||
var classNamesByWeapon = weaponList.ToDictionary(kvp => kvp.Value, kvp => kvp.Key);
|
||||
var weaponSelectionMenu = new ChatMenu(Utility.ReplaceTags($" {Config.Messages.WeaponMenuTitle}"));
|
||||
var weaponSelectionMenu = new ChatMenu(Localizer["wp_skin_menu_weapon_title"]);
|
||||
|
||||
// Function to handle skin selection for a specific weapon
|
||||
var handleWeaponSelection = (CCSPlayerController? player, ChatMenuOption option) =>
|
||||
@@ -195,7 +181,7 @@ namespace WeaponPaints
|
||||
weaponName?.ToString() == selectedWeaponClassname
|
||||
)?.ToList();
|
||||
|
||||
var skinSubMenu = new ChatMenu(Utility.ReplaceTags($" {Config.Messages.SkinMenuTitle}").Replace("{WEAPON}", selectedWeapon));
|
||||
var skinSubMenu = new ChatMenu(Localizer["wp_skin_menu_skin_title", selectedWeapon]);
|
||||
|
||||
// Function to handle skin selection for the chosen weapon
|
||||
var handleSkinSelection = (CCSPlayerController? p, ChatMenuOption opt) =>
|
||||
@@ -224,8 +210,7 @@ namespace WeaponPaints
|
||||
int.TryParse(weaponDefIndexObj.ToString(), out var weaponDefIndex) &&
|
||||
int.TryParse(selectedPaintID, out var paintID))
|
||||
{
|
||||
string temp = $" {Config.Prefix} {Config.Messages.ChosenSkinMenu}".Replace("{SKIN}", selectedSkin);
|
||||
p.PrintToChat(Utility.ReplaceTags(temp));
|
||||
p!.Print(Localizer["f", selectedSkin]);
|
||||
|
||||
if (!gPlayerWeaponsInfo[playerIndex].ContainsKey(weaponDefIndex))
|
||||
{
|
||||
@@ -294,10 +279,9 @@ namespace WeaponPaints
|
||||
ChatMenus.OpenMenu(player, weaponSelectionMenu);
|
||||
return;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(Config.Messages.CooldownRefreshCommand))
|
||||
if (!string.IsNullOrEmpty(Localizer["wp_command_cooldown"]))
|
||||
{
|
||||
string temp = $"{Config.Prefix} {Config.Messages.CooldownRefreshCommand}";
|
||||
player.PrintToChat(Utility.ReplaceTags(temp));
|
||||
player!.Print(Localizer["wp_command_cooldown"]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
31
Config.cs
31
Config.cs
@@ -3,32 +3,6 @@ using System.Text.Json.Serialization;
|
||||
|
||||
namespace WeaponPaints
|
||||
{
|
||||
public class Messages
|
||||
{
|
||||
[JsonPropertyName("WebsiteMessageCommand")]
|
||||
public string WebsiteMessageCommand { get; set; } = "Visit {WEBSITE} where you can change skins.";
|
||||
[JsonPropertyName("SynchronizeMessageCommand")]
|
||||
public string SynchronizeMessageCommand { get; set; } = "Type !wp to synchronize chosen skins.";
|
||||
[JsonPropertyName("KnifeMessageCommand")]
|
||||
public string KnifeMessageCommand { get; set; } = "Type !knife to open knife menu.";
|
||||
[JsonPropertyName("CooldownRefreshCommand")]
|
||||
public string CooldownRefreshCommand { get; set; } = "You can't refresh weapon paints right now.";
|
||||
[JsonPropertyName("SuccessRefreshCommand")]
|
||||
public string SuccessRefreshCommand { get; set; } = "Refreshing weapon paints.";
|
||||
[JsonPropertyName("ChosenKnifeMenu")]
|
||||
public string ChosenKnifeMenu { get; set; } = "You have chosen {KNIFE} as your knife.";
|
||||
[JsonPropertyName("ChosenSkinMenu")]
|
||||
public string ChosenSkinMenu { get; set; } = "You have chosen {SKIN} as your skin.";
|
||||
[JsonPropertyName("ChosenKnifeMenuKill")]
|
||||
public string ChosenKnifeMenuKill { get; set; } = "To correctly apply skin for knife, you need to type !kill.";
|
||||
[JsonPropertyName("KnifeMenuTitle")]
|
||||
public string KnifeMenuTitle { get; set; } = "Knife Menu.";
|
||||
[JsonPropertyName("WeaponMenuTitle")]
|
||||
public string WeaponMenuTitle { get; set; } = "Weapon Menu.";
|
||||
[JsonPropertyName("SkinMenuTitle")]
|
||||
public string SkinMenuTitle { get; set; } = "Select skin for {WEAPON}";
|
||||
}
|
||||
|
||||
public class Additional
|
||||
{
|
||||
[JsonPropertyName("SkinVisibilityFix")]
|
||||
@@ -66,6 +40,8 @@ namespace WeaponPaints
|
||||
|
||||
[JsonPropertyName("GiveRandomSkin")]
|
||||
public bool GiveRandomSkin { get; set; } = false;
|
||||
[JsonPropertyName("GiveKnifeAfterRemove")]
|
||||
public bool GiveKnifeAfterRemove { get; set; } = false;
|
||||
}
|
||||
|
||||
public class WeaponPaintsConfig : BasePluginConfig
|
||||
@@ -99,9 +75,6 @@ namespace WeaponPaints
|
||||
[JsonPropertyName("Website")]
|
||||
public string Website { get; set; } = "example.com/skins";
|
||||
|
||||
[JsonPropertyName("Messages")]
|
||||
public Messages Messages { get; set; } = new Messages();
|
||||
|
||||
[JsonPropertyName("Additional")]
|
||||
public Additional Additional { get; set; } = new Additional();
|
||||
}
|
||||
|
||||
65
Events.cs
65
Events.cs
@@ -45,7 +45,7 @@ namespace WeaponPaints
|
||||
gPlayerWeaponsInfo.Remove((int)player.Index);
|
||||
}
|
||||
|
||||
private void OnEntitySpawned(CEntityInstance entity)
|
||||
private void OnEntityCreated(CEntityInstance entity)
|
||||
{
|
||||
if (!Config.Additional.SkinEnabled) return;
|
||||
var designerName = entity.DesignerName;
|
||||
@@ -57,6 +57,7 @@ namespace WeaponPaints
|
||||
{
|
||||
isKnife = true;
|
||||
}
|
||||
|
||||
Server.NextFrame(() =>
|
||||
{
|
||||
try
|
||||
@@ -94,22 +95,65 @@ namespace WeaponPaints
|
||||
{
|
||||
if (@event.Defindex == 42 || @event.Defindex == 59)
|
||||
{
|
||||
Server.PrintToChatAll("test1");
|
||||
|
||||
CCSPlayerController? player = @event.Userid;
|
||||
if (!Utility.IsPlayerValid(player) || !player.PawnIsAlive || g_knifePickupCount[(int)player.Index] >= 1) return HookResult.Continue;
|
||||
if (player == null || !player.IsValid || !g_knifePickupCount.ContainsKey((int)player.Index) || player.IsBot || !g_playersKnife.ContainsKey((int)player.Index))
|
||||
return HookResult.Continue;
|
||||
|
||||
Server.PrintToChatAll("test2");
|
||||
|
||||
|
||||
if (g_knifePickupCount[(int)player.Index] >= 2) return HookResult.Continue;
|
||||
Server.PrintToChatAll("test3");
|
||||
|
||||
|
||||
if (g_playersKnife.ContainsKey((int)player.Index)
|
||||
&&
|
||||
g_playersKnife[(int)player.Index] != "weapon_knife")
|
||||
{
|
||||
Server.PrintToChatAll("usuwam noz");
|
||||
g_knifePickupCount[(int)player.Index]++;
|
||||
|
||||
RemovePlayerKnife(player, true);
|
||||
AddTimer(0.3f, () => GiveKnifeToPlayer(player));
|
||||
|
||||
if (!PlayerHasKnife(player) && Config.Additional.GiveKnifeAfterRemove)
|
||||
AddTimer(0.3f, () => GiveKnifeToPlayer(player));
|
||||
}
|
||||
}
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
public HookResult OnPickup(CEntityIOOutput output, string name, CEntityInstance activator, CEntityInstance caller, CVariant value, float delay)
|
||||
{
|
||||
CCSPlayerController? player = Utilities.GetEntityFromIndex<CCSPlayerPawn>((int)activator.Index).OriginalController.Value;
|
||||
|
||||
if (player == null || player.IsBot || player.IsHLTV)
|
||||
return HookResult.Continue;
|
||||
|
||||
if (player == null || !player.IsValid || player.AuthorizedSteamID == null ||
|
||||
!g_knifePickupCount.ContainsKey((int)player.Index) || !g_playersKnife.ContainsKey((int)player.Index))
|
||||
return HookResult.Continue;
|
||||
|
||||
CBasePlayerWeapon weapon = new(caller.Handle);
|
||||
|
||||
if (weapon.AttributeManager.Item.ItemDefinitionIndex != 42 && weapon.AttributeManager.Item.ItemDefinitionIndex != 59)
|
||||
return HookResult.Continue;
|
||||
|
||||
if (g_knifePickupCount[(int)player.Index] >= 2) return HookResult.Continue;
|
||||
|
||||
if (g_playersKnife[(int)player.Index] != "weapon_knife")
|
||||
{
|
||||
g_knifePickupCount[(int)player.Index]++;
|
||||
weapon.Remove();
|
||||
if (!PlayerHasKnife(player) && Config.Additional.GiveKnifeAfterRemove)
|
||||
AddTimer(0.2f, () => GiveKnifeToPlayer(player));
|
||||
}
|
||||
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
|
||||
private void OnMapStart(string mapName)
|
||||
{
|
||||
if (!Config.Additional.KnifeEnabled) return;
|
||||
@@ -117,6 +161,7 @@ namespace WeaponPaints
|
||||
// needed for now
|
||||
AddTimer(2.0f, () =>
|
||||
{
|
||||
|
||||
NativeAPI.IssueServerCommand("mp_t_default_melee \"\"");
|
||||
NativeAPI.IssueServerCommand("mp_ct_default_melee \"\"");
|
||||
NativeAPI.IssueServerCommand("mp_equipment_reset_rounds 0");
|
||||
@@ -133,7 +178,7 @@ namespace WeaponPaints
|
||||
|
||||
foreach (CCSPlayerController player in players)
|
||||
{
|
||||
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV || player.AuthorizedSteamID == null) continue;
|
||||
if (player.IsBot || player.IsHLTV || player.AuthorizedSteamID == null) continue;
|
||||
if (gPlayerWeaponsInfo.ContainsKey((int)player.Index)) continue;
|
||||
|
||||
PlayerInfo playerInfo = new PlayerInfo
|
||||
@@ -151,7 +196,6 @@ namespace WeaponPaints
|
||||
_ = weaponSync.GetKnifeFromDatabase(playerInfo);
|
||||
}
|
||||
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE | CounterStrikeSharp.API.Modules.Timers.TimerFlags.REPEAT);
|
||||
|
||||
}
|
||||
|
||||
private HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventInfo info)
|
||||
@@ -187,7 +231,7 @@ namespace WeaponPaints
|
||||
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
|
||||
{
|
||||
CCSPlayerController? player = @event.Userid;
|
||||
if (player == null || !player.IsValid)
|
||||
if (player == null || !player.IsValid || player.IsBot)
|
||||
{
|
||||
return HookResult.Continue;
|
||||
}
|
||||
@@ -195,8 +239,7 @@ namespace WeaponPaints
|
||||
if (Config.Additional.KnifeEnabled)
|
||||
{
|
||||
g_knifePickupCount[(int)player.Index] = 0;
|
||||
if (!PlayerHasKnife(player))
|
||||
GiveKnifeToPlayer(player);
|
||||
AddTimer(0.1f, () => GiveKnifeToPlayer(player));
|
||||
}
|
||||
|
||||
if (Config.Additional.SkinVisibilityFix)
|
||||
@@ -207,7 +250,6 @@ namespace WeaponPaints
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
|
||||
private HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info)
|
||||
{
|
||||
g_bCommandsAllowed = false;
|
||||
@@ -227,7 +269,7 @@ namespace WeaponPaints
|
||||
|
||||
private void RegisterListeners()
|
||||
{
|
||||
RegisterListener<Listeners.OnEntitySpawned>(OnEntitySpawned);
|
||||
RegisterListener<Listeners.OnEntityCreated>(OnEntityCreated);
|
||||
RegisterListener<Listeners.OnClientAuthorized>(OnClientAuthorized);
|
||||
RegisterListener<Listeners.OnClientDisconnect>(OnClientDisconnect);
|
||||
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
||||
@@ -237,7 +279,8 @@ namespace WeaponPaints
|
||||
RegisterEventHandler<EventRoundStart>(OnRoundStart, HookMode.Pre);
|
||||
RegisterEventHandler<EventRoundEnd>(OnRoundEnd);
|
||||
RegisterEventHandler<EventItemPurchase>(OnEventItemPurchasePost);
|
||||
RegisterEventHandler<EventItemPickup>(OnItemPickup);
|
||||
//RegisterEventHandler<EventItemPickup>(OnItemPickup);
|
||||
HookEntityOutput("weapon_knife", "OnPlayerPickup", OnPickup, HookMode.Pre);
|
||||
}
|
||||
|
||||
/* WORKAROUND FOR CLIENTS WITHOUT STEAMID ON AUTHORIZATION */
|
||||
|
||||
14
PlayerExtensions.cs
Normal file
14
PlayerExtensions.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using System.Text;
|
||||
|
||||
namespace WeaponPaints;
|
||||
|
||||
public static class PlayerExtensions
|
||||
{
|
||||
public static void Print(this CCSPlayerController controller, string message)
|
||||
{
|
||||
StringBuilder _message = new(WeaponPaints._localizer["wp_prefix"]);
|
||||
_message.Append(message);
|
||||
controller.PrintToChat(_message.ToString());
|
||||
}
|
||||
}
|
||||
1
PluginServices.cs
Normal file
1
PluginServices.cs
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
15
Utility.cs
15
Utility.cs
@@ -108,13 +108,13 @@ namespace WeaponPaints
|
||||
return message;
|
||||
}
|
||||
|
||||
internal static async Task CheckVersion(string version)
|
||||
internal static async Task CheckVersion(string version, ILogger logger)
|
||||
{
|
||||
using (HttpClient client = new HttpClient())
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpResponseMessage response = await client.GetAsync("https://github.com/Nereziel/cs2-WeaponPaints/blob/main/VERSION");
|
||||
HttpResponseMessage response = await client.GetAsync("https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/VERSION");
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
@@ -125,24 +125,25 @@ namespace WeaponPaints
|
||||
|
||||
if (comparisonResult < 0)
|
||||
{
|
||||
WeaponPaints.logger!.LogWarning("Plugin is outdated! Check https://github.com/Nereziel/cs2-WeaponPaints");
|
||||
logger.LogWarning("Plugin is outdated! Check https://github.com/Nereziel/cs2-WeaponPaints");
|
||||
}
|
||||
else if (comparisonResult > 0)
|
||||
{
|
||||
WeaponPaints.logger!.LogInformation("Probably dev version detected");
|
||||
logger.LogInformation("Probably dev version detected");
|
||||
}
|
||||
else
|
||||
{
|
||||
WeaponPaints.logger!.LogInformation("Plugin is up to date");
|
||||
logger.LogInformation("Plugin is up to date");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WeaponPaints.logger!.LogWarning("Failed to check version");
|
||||
logger.LogWarning("Failed to check version");
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,11 @@ namespace WeaponPaints
|
||||
|
||||
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
||||
|
||||
if (isKnife)
|
||||
{
|
||||
weapon.AttributeManager.Item.EntityQuality = 3;
|
||||
}
|
||||
|
||||
if (_config.Additional.GiveRandomSkin &&
|
||||
!gPlayerWeaponsInfo[playerIndex].ContainsKey(weaponDefIndex))
|
||||
{
|
||||
@@ -280,10 +285,10 @@ namespace WeaponPaints
|
||||
}
|
||||
private static int GetRandomPaint(int defindex)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
|
||||
if (WeaponPaints.skinsList != null)
|
||||
if (skinsList != null)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
// Filter weapons by the provided defindex
|
||||
var filteredWeapons = skinsList.FindAll(w => w["weapon_defindex"]?.ToString() == defindex.ToString());
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@ using CounterStrikeSharp.API.Core.Attributes;
|
||||
using CounterStrikeSharp.API.Modules.Cvars;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace WeaponPaints;
|
||||
|
||||
[MinimumApiVersion(101)]
|
||||
[MinimumApiVersion(121)]
|
||||
public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
||||
{
|
||||
internal static ILogger? logger;
|
||||
internal static readonly Dictionary<string, string> weaponList = new()
|
||||
{
|
||||
{"weapon_deagle", "Desert Eagle"},
|
||||
@@ -70,6 +70,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
||||
};
|
||||
|
||||
internal static WeaponPaintsConfig _config = new WeaponPaintsConfig();
|
||||
internal static IStringLocalizer? _localizer;
|
||||
internal static Dictionary<int, int> g_knifePickupCount = new Dictionary<int, int>();
|
||||
internal static Dictionary<int, string> g_playersKnife = new();
|
||||
internal static Dictionary<int, Dictionary<int, WeaponInfo>> gPlayerWeaponsInfo = new Dictionary<int, Dictionary<int, WeaponInfo>>();
|
||||
@@ -144,7 +145,8 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
||||
public override string ModuleAuthor => "Nereziel & daffyy";
|
||||
public override string ModuleDescription => "Skin and knife selector, standalone and web-based";
|
||||
public override string ModuleName => "WeaponPaints";
|
||||
public override string ModuleVersion => "1.3f";
|
||||
public override string ModuleVersion => "1.3g";
|
||||
|
||||
public static WeaponPaintsConfig GetWeaponPaintsConfig()
|
||||
{
|
||||
return _config;
|
||||
@@ -182,10 +184,13 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
||||
_ = weaponSync.GetWeaponPaintsFromDatabase(playerInfo);
|
||||
if (Config.Additional.KnifeEnabled && weaponSync != null)
|
||||
_ = weaponSync.GetKnifeFromDatabase(playerInfo);
|
||||
}
|
||||
|
||||
g_knifePickupCount[(int)player!.Index] = 0;
|
||||
}
|
||||
/*
|
||||
RegisterListeners();
|
||||
RegisterCommands();
|
||||
*/
|
||||
}
|
||||
|
||||
if (Config.Additional.KnifeEnabled)
|
||||
@@ -212,9 +217,11 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
||||
|
||||
Config = config;
|
||||
_config = config;
|
||||
_localizer = Localizer;
|
||||
|
||||
Utility.Config = config;
|
||||
Utility.ShowAd(ModuleVersion);
|
||||
Task.Run(async () => await Utility.CheckVersion(ModuleVersion));
|
||||
Task.Run(async () => await Utility.CheckVersion(ModuleVersion, Logger));
|
||||
}
|
||||
|
||||
public override void Unload(bool hotReload)
|
||||
|
||||
@@ -5,12 +5,17 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CounterStrikeSharp.API" Version="*" />
|
||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.121" />
|
||||
<PackageReference Include="Dapper" Version="2.1.24" />
|
||||
<PackageReference Include="MySqlConnector" Version="2.3.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="lang\**\*.*" CopyToOutputDirectory="PreserveNewest" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using Dapper;
|
||||
using Dapper;
|
||||
using MySqlConnector;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
|
||||
14
lang/en.json
Normal file
14
lang/en.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||
"wp_info_website": "Visit {lime}{0}{default} where you can change skins",
|
||||
"wp_info_refresh": "Type {lime}!wp{default} to synchronize chosen skins",
|
||||
"wp_info_knife": "Type {lime}!knife{default} to open knife menu",
|
||||
"wp_command_cooldown": "{lightred}You can't refresh weapon paints right now",
|
||||
"wp_command_refresh_done": "{lime}Refreshing weapon paints",
|
||||
"wp_knife_menu_select": "You have chosen {lime}{0}{default} as your knife",
|
||||
"wp_knife_menu_kill": "To correctly apply skin for knife, you need to type {lime}!kill{default}",
|
||||
"wp_knife_menu_title": "Knife Menu",
|
||||
"wp_skin_menu_weapon_title": "Weapon Menu",
|
||||
"wp_skin_menu_skin_title": "Select skin for {lime}{0}{default}",
|
||||
"wp_skin_menu_select": "You have chosen {lime}{0}{default} as your skin"
|
||||
}
|
||||
14
lang/pl.json
Normal file
14
lang/pl.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||
"wp_info_website": "Odwiedź {lime}{0}{default} gdzie będziesz mógł ustawić skiny",
|
||||
"wp_info_refresh": "Wpisz {lime}!wp{default} aby zsynchronizować swoje skiny",
|
||||
"wp_info_knife": "Wpisz {lime}!knife{default} aby wy<77>wietlić menu no<6E>y",
|
||||
"wp_command_cooldown": "{lightred}Odczekaj chwilę przed wykonaniem tej komendy...",
|
||||
"wp_command_refresh_done": "{lime}Pomyslnie zsynchronizowano twoje skiny",
|
||||
"wp_knife_menu_select": "Wybrałeś {lime}{0}{default} jako swój nóż",
|
||||
"wp_knife_menu_kill": "Do prawidłowego zastosowania noża użyj {lime}!kill{default}",
|
||||
"wp_knife_menu_title": "Menu noży",
|
||||
"wp_skin_menu_weapon_title": "Menu broni",
|
||||
"wp_skin_menu_skin_title": "Wybierz skin dla {lime}{0}{default}",
|
||||
"wp_skin_menu_select": "Wybrałeś {lime}{0}{default} jako swój skin"
|
||||
}
|
||||
14
lang/ru.json
Normal file
14
lang/ru.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"wp_prefix": "{lightblue}[WeaponPaints] {default}",
|
||||
"wp_info_website": "Посетите сайт {lime}{0},{default} чтобы выбрать скин",
|
||||
"wp_info_refresh": "Наберите в чат {lime}!wp{default} для синхронизации выбранных скинов",
|
||||
"wp_info_knife": "Наберите в чат {lime}!knife,{default} чтобы выбрать нож",
|
||||
"wp_command_cooldown": "{lightred}Вы не можете выбрать оружие прямо сейчас",
|
||||
"wp_command_refresh_done": "{lime}Обновление скинов для оружия",
|
||||
"wp_knife_menu_select": "Вы выбрали {lime}{0}{default} скин для ножа",
|
||||
"wp_knife_menu_kill": "Чтобы правильно применить скин для ножа, набери в чат {lime}!kill{default}",
|
||||
"wp_knife_menu_title": "Меню ножей",
|
||||
"wp_skin_menu_weapon_title": "Меню оружия",
|
||||
"wp_skin_menu_skin_title": "Выберите скин для {lime}{0}{default}",
|
||||
"wp_skin_menu_select": "Вы выбрали {lime}{0}{default} скина для оружия"
|
||||
}
|
||||
Reference in New Issue
Block a user