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.Core;
|
||||||
using CounterStrikeSharp.API.Modules.Commands;
|
using CounterStrikeSharp.API.Modules.Commands;
|
||||||
using CounterStrikeSharp.API.Modules.Entities.Constants;
|
|
||||||
using CounterStrikeSharp.API.Modules.Memory;
|
|
||||||
using CounterStrikeSharp.API.Modules.Menu;
|
using CounterStrikeSharp.API.Modules.Menu;
|
||||||
|
|
||||||
namespace WeaponPaints
|
namespace WeaponPaints
|
||||||
@@ -12,7 +10,6 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
if (!Config.Additional.CommandWpEnabled || !Config.Additional.SkinEnabled || !g_bCommandsAllowed) return;
|
if (!Config.Additional.CommandWpEnabled || !Config.Additional.SkinEnabled || !g_bCommandsAllowed) return;
|
||||||
if (!Utility.IsPlayerValid(player)) return;
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
string temp = "";
|
|
||||||
if (player == null || player.Index <= 0) return;
|
if (player == null || player.Index <= 0) return;
|
||||||
int playerIndex = (int)player!.Index;
|
int playerIndex = (int)player!.Index;
|
||||||
|
|
||||||
@@ -37,17 +34,15 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
RefreshWeapons(player);
|
RefreshWeapons(player);
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(Config.Messages.SuccessRefreshCommand))
|
if (!string.IsNullOrEmpty(Localizer["wp_command_refresh_done"]))
|
||||||
{
|
{
|
||||||
temp = $" {Config.Prefix} {Config.Messages.SuccessRefreshCommand}";
|
player!.Print(Localizer["wp_command_refresh_done"]);
|
||||||
player!.PrintToChat(Utility.ReplaceTags(temp));
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(Config.Messages.CooldownRefreshCommand))
|
if (!string.IsNullOrEmpty(Localizer["wp_command_cooldown"]))
|
||||||
{
|
{
|
||||||
temp = $" {Config.Prefix} {Config.Messages.CooldownRefreshCommand}";
|
player!.Print(Localizer["wp_command_cooldown"]);
|
||||||
player!.PrintToChat(Utility.ReplaceTags(temp));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,22 +51,18 @@ namespace WeaponPaints
|
|||||||
if (!Config.Additional.SkinEnabled) return;
|
if (!Config.Additional.SkinEnabled) return;
|
||||||
if (!Utility.IsPlayerValid(player)) return;
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
|
|
||||||
string temp;
|
if (!string.IsNullOrEmpty(Localizer["wp_info_website"]))
|
||||||
if (!string.IsNullOrEmpty(Config.Messages.WebsiteMessageCommand))
|
|
||||||
{
|
{
|
||||||
temp = $" {Config.Prefix} {Config.Messages.WebsiteMessageCommand}";
|
player!.Print(Localizer["wp_info_website", Config.Website]);
|
||||||
player!.PrintToChat(Utility.ReplaceTags(temp));
|
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(Config.Messages.SynchronizeMessageCommand))
|
if (!string.IsNullOrEmpty(Localizer["wp_info_refresh"]))
|
||||||
{
|
{
|
||||||
temp = $" {Config.Prefix} {Config.Messages.SynchronizeMessageCommand}";
|
player!.Print(Localizer["wp_info_refresh"]);
|
||||||
player!.PrintToChat(Utility.ReplaceTags(temp));
|
|
||||||
}
|
}
|
||||||
if (!Config.Additional.KnifeEnabled) return;
|
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!.Print(Localizer["wp_info_knife"]);
|
||||||
player!.PrintToChat(Utility.ReplaceTags(temp));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +97,7 @@ namespace WeaponPaints
|
|||||||
.Where(pair => pair.Key.StartsWith("weapon_knife") || pair.Key.StartsWith("weapon_bayonet"))
|
.Where(pair => pair.Key.StartsWith("weapon_knife") || pair.Key.StartsWith("weapon_bayonet"))
|
||||||
.ToDictionary(pair => pair.Key, pair => pair.Value);
|
.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) =>
|
var handleGive = (CCSPlayerController? player, ChatMenuOption option) =>
|
||||||
{
|
{
|
||||||
if (Utility.IsPlayerValid(player))
|
if (Utility.IsPlayerValid(player))
|
||||||
@@ -116,18 +107,14 @@ namespace WeaponPaints
|
|||||||
var knifeKey = knivesOnly.FirstOrDefault(x => x.Value == knifeName).Key;
|
var knifeKey = knivesOnly.FirstOrDefault(x => x.Value == knifeName).Key;
|
||||||
if (!string.IsNullOrEmpty(knifeKey))
|
if (!string.IsNullOrEmpty(knifeKey))
|
||||||
{
|
{
|
||||||
string temp = "";
|
if (!string.IsNullOrEmpty(Localizer["wp_knife_menu_select"]))
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Config.Messages.ChosenKnifeMenu))
|
|
||||||
{
|
{
|
||||||
temp = $" {Config.Prefix} {Config.Messages.ChosenKnifeMenu}".Replace("{KNIFE}", knifeName);
|
player!.Print(Localizer["wp_knife_menu_select", knifeName]);
|
||||||
player!.PrintToChat(Utility.ReplaceTags(temp));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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!.Print(Localizer["wp_knife_menu_kill"]);
|
||||||
player!.PrintToChat(Utility.ReplaceTags(temp));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
@@ -166,10 +153,9 @@ namespace WeaponPaints
|
|||||||
ChatMenus.OpenMenu(player, giveItemMenu);
|
ChatMenus.OpenMenu(player, giveItemMenu);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(Config.Messages.CooldownRefreshCommand))
|
if (!string.IsNullOrEmpty(Localizer["wp_command_cooldown"]))
|
||||||
{
|
{
|
||||||
string temp = $" {Config.Prefix} {Config.Messages.CooldownRefreshCommand}";
|
player!.Print(Localizer["wp_command_cooldown"]);
|
||||||
player.PrintToChat(Utility.ReplaceTags(temp));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -177,7 +163,7 @@ namespace WeaponPaints
|
|||||||
private void SetupSkinsMenu()
|
private void SetupSkinsMenu()
|
||||||
{
|
{
|
||||||
var classNamesByWeapon = weaponList.ToDictionary(kvp => kvp.Value, kvp => kvp.Key);
|
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
|
// Function to handle skin selection for a specific weapon
|
||||||
var handleWeaponSelection = (CCSPlayerController? player, ChatMenuOption option) =>
|
var handleWeaponSelection = (CCSPlayerController? player, ChatMenuOption option) =>
|
||||||
@@ -195,7 +181,7 @@ namespace WeaponPaints
|
|||||||
weaponName?.ToString() == selectedWeaponClassname
|
weaponName?.ToString() == selectedWeaponClassname
|
||||||
)?.ToList();
|
)?.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
|
// Function to handle skin selection for the chosen weapon
|
||||||
var handleSkinSelection = (CCSPlayerController? p, ChatMenuOption opt) =>
|
var handleSkinSelection = (CCSPlayerController? p, ChatMenuOption opt) =>
|
||||||
@@ -224,8 +210,7 @@ namespace WeaponPaints
|
|||||||
int.TryParse(weaponDefIndexObj.ToString(), out var weaponDefIndex) &&
|
int.TryParse(weaponDefIndexObj.ToString(), out var weaponDefIndex) &&
|
||||||
int.TryParse(selectedPaintID, out var paintID))
|
int.TryParse(selectedPaintID, out var paintID))
|
||||||
{
|
{
|
||||||
string temp = $" {Config.Prefix} {Config.Messages.ChosenSkinMenu}".Replace("{SKIN}", selectedSkin);
|
p!.Print(Localizer["f", selectedSkin]);
|
||||||
p.PrintToChat(Utility.ReplaceTags(temp));
|
|
||||||
|
|
||||||
if (!gPlayerWeaponsInfo[playerIndex].ContainsKey(weaponDefIndex))
|
if (!gPlayerWeaponsInfo[playerIndex].ContainsKey(weaponDefIndex))
|
||||||
{
|
{
|
||||||
@@ -294,10 +279,9 @@ namespace WeaponPaints
|
|||||||
ChatMenus.OpenMenu(player, weaponSelectionMenu);
|
ChatMenus.OpenMenu(player, weaponSelectionMenu);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(Config.Messages.CooldownRefreshCommand))
|
if (!string.IsNullOrEmpty(Localizer["wp_command_cooldown"]))
|
||||||
{
|
{
|
||||||
string temp = $"{Config.Prefix} {Config.Messages.CooldownRefreshCommand}";
|
player!.Print(Localizer["wp_command_cooldown"]);
|
||||||
player.PrintToChat(Utility.ReplaceTags(temp));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
31
Config.cs
31
Config.cs
@@ -3,32 +3,6 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace WeaponPaints
|
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
|
public class Additional
|
||||||
{
|
{
|
||||||
[JsonPropertyName("SkinVisibilityFix")]
|
[JsonPropertyName("SkinVisibilityFix")]
|
||||||
@@ -66,6 +40,8 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
[JsonPropertyName("GiveRandomSkin")]
|
[JsonPropertyName("GiveRandomSkin")]
|
||||||
public bool GiveRandomSkin { get; set; } = false;
|
public bool GiveRandomSkin { get; set; } = false;
|
||||||
|
[JsonPropertyName("GiveKnifeAfterRemove")]
|
||||||
|
public bool GiveKnifeAfterRemove { get; set; } = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WeaponPaintsConfig : BasePluginConfig
|
public class WeaponPaintsConfig : BasePluginConfig
|
||||||
@@ -99,9 +75,6 @@ namespace WeaponPaints
|
|||||||
[JsonPropertyName("Website")]
|
[JsonPropertyName("Website")]
|
||||||
public string Website { get; set; } = "example.com/skins";
|
public string Website { get; set; } = "example.com/skins";
|
||||||
|
|
||||||
[JsonPropertyName("Messages")]
|
|
||||||
public Messages Messages { get; set; } = new Messages();
|
|
||||||
|
|
||||||
[JsonPropertyName("Additional")]
|
[JsonPropertyName("Additional")]
|
||||||
public Additional Additional { get; set; } = new 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);
|
gPlayerWeaponsInfo.Remove((int)player.Index);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnEntitySpawned(CEntityInstance entity)
|
private void OnEntityCreated(CEntityInstance entity)
|
||||||
{
|
{
|
||||||
if (!Config.Additional.SkinEnabled) return;
|
if (!Config.Additional.SkinEnabled) return;
|
||||||
var designerName = entity.DesignerName;
|
var designerName = entity.DesignerName;
|
||||||
@@ -57,6 +57,7 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
isKnife = true;
|
isKnife = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Server.NextFrame(() =>
|
Server.NextFrame(() =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -94,22 +95,65 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
if (@event.Defindex == 42 || @event.Defindex == 59)
|
if (@event.Defindex == 42 || @event.Defindex == 59)
|
||||||
{
|
{
|
||||||
|
Server.PrintToChatAll("test1");
|
||||||
|
|
||||||
CCSPlayerController? player = @event.Userid;
|
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)
|
if (g_playersKnife.ContainsKey((int)player.Index)
|
||||||
&&
|
&&
|
||||||
g_playersKnife[(int)player.Index] != "weapon_knife")
|
g_playersKnife[(int)player.Index] != "weapon_knife")
|
||||||
{
|
{
|
||||||
|
Server.PrintToChatAll("usuwam noz");
|
||||||
g_knifePickupCount[(int)player.Index]++;
|
g_knifePickupCount[(int)player.Index]++;
|
||||||
|
|
||||||
RemovePlayerKnife(player, true);
|
RemovePlayerKnife(player, true);
|
||||||
AddTimer(0.3f, () => GiveKnifeToPlayer(player));
|
|
||||||
|
if (!PlayerHasKnife(player) && Config.Additional.GiveKnifeAfterRemove)
|
||||||
|
AddTimer(0.3f, () => GiveKnifeToPlayer(player));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return HookResult.Continue;
|
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)
|
private void OnMapStart(string mapName)
|
||||||
{
|
{
|
||||||
if (!Config.Additional.KnifeEnabled) return;
|
if (!Config.Additional.KnifeEnabled) return;
|
||||||
@@ -117,6 +161,7 @@ namespace WeaponPaints
|
|||||||
// needed for now
|
// needed for now
|
||||||
AddTimer(2.0f, () =>
|
AddTimer(2.0f, () =>
|
||||||
{
|
{
|
||||||
|
|
||||||
NativeAPI.IssueServerCommand("mp_t_default_melee \"\"");
|
NativeAPI.IssueServerCommand("mp_t_default_melee \"\"");
|
||||||
NativeAPI.IssueServerCommand("mp_ct_default_melee \"\"");
|
NativeAPI.IssueServerCommand("mp_ct_default_melee \"\"");
|
||||||
NativeAPI.IssueServerCommand("mp_equipment_reset_rounds 0");
|
NativeAPI.IssueServerCommand("mp_equipment_reset_rounds 0");
|
||||||
@@ -133,7 +178,7 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
foreach (CCSPlayerController player in players)
|
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;
|
if (gPlayerWeaponsInfo.ContainsKey((int)player.Index)) continue;
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
@@ -151,7 +196,6 @@ namespace WeaponPaints
|
|||||||
_ = weaponSync.GetKnifeFromDatabase(playerInfo);
|
_ = weaponSync.GetKnifeFromDatabase(playerInfo);
|
||||||
}
|
}
|
||||||
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE | CounterStrikeSharp.API.Modules.Timers.TimerFlags.REPEAT);
|
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE | CounterStrikeSharp.API.Modules.Timers.TimerFlags.REPEAT);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventInfo info)
|
private HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventInfo info)
|
||||||
@@ -187,7 +231,7 @@ namespace WeaponPaints
|
|||||||
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
|
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
|
||||||
{
|
{
|
||||||
CCSPlayerController? player = @event.Userid;
|
CCSPlayerController? player = @event.Userid;
|
||||||
if (player == null || !player.IsValid)
|
if (player == null || !player.IsValid || player.IsBot)
|
||||||
{
|
{
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
@@ -195,8 +239,7 @@ namespace WeaponPaints
|
|||||||
if (Config.Additional.KnifeEnabled)
|
if (Config.Additional.KnifeEnabled)
|
||||||
{
|
{
|
||||||
g_knifePickupCount[(int)player.Index] = 0;
|
g_knifePickupCount[(int)player.Index] = 0;
|
||||||
if (!PlayerHasKnife(player))
|
AddTimer(0.1f, () => GiveKnifeToPlayer(player));
|
||||||
GiveKnifeToPlayer(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.Additional.SkinVisibilityFix)
|
if (Config.Additional.SkinVisibilityFix)
|
||||||
@@ -207,7 +250,6 @@ namespace WeaponPaints
|
|||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info)
|
private HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info)
|
||||||
{
|
{
|
||||||
g_bCommandsAllowed = false;
|
g_bCommandsAllowed = false;
|
||||||
@@ -227,7 +269,7 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
private void RegisterListeners()
|
private void RegisterListeners()
|
||||||
{
|
{
|
||||||
RegisterListener<Listeners.OnEntitySpawned>(OnEntitySpawned);
|
RegisterListener<Listeners.OnEntityCreated>(OnEntityCreated);
|
||||||
RegisterListener<Listeners.OnClientAuthorized>(OnClientAuthorized);
|
RegisterListener<Listeners.OnClientAuthorized>(OnClientAuthorized);
|
||||||
RegisterListener<Listeners.OnClientDisconnect>(OnClientDisconnect);
|
RegisterListener<Listeners.OnClientDisconnect>(OnClientDisconnect);
|
||||||
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
||||||
@@ -237,7 +279,8 @@ namespace WeaponPaints
|
|||||||
RegisterEventHandler<EventRoundStart>(OnRoundStart, HookMode.Pre);
|
RegisterEventHandler<EventRoundStart>(OnRoundStart, HookMode.Pre);
|
||||||
RegisterEventHandler<EventRoundEnd>(OnRoundEnd);
|
RegisterEventHandler<EventRoundEnd>(OnRoundEnd);
|
||||||
RegisterEventHandler<EventItemPurchase>(OnEventItemPurchasePost);
|
RegisterEventHandler<EventItemPurchase>(OnEventItemPurchasePost);
|
||||||
RegisterEventHandler<EventItemPickup>(OnItemPickup);
|
//RegisterEventHandler<EventItemPickup>(OnItemPickup);
|
||||||
|
HookEntityOutput("weapon_knife", "OnPlayerPickup", OnPickup, HookMode.Pre);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* WORKAROUND FOR CLIENTS WITHOUT STEAMID ON AUTHORIZATION */
|
/* 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;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static async Task CheckVersion(string version)
|
internal static async Task CheckVersion(string version, ILogger logger)
|
||||||
{
|
{
|
||||||
using (HttpClient client = new HttpClient())
|
using (HttpClient client = new HttpClient())
|
||||||
{
|
{
|
||||||
try
|
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)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
@@ -125,24 +125,25 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
if (comparisonResult < 0)
|
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)
|
else if (comparisonResult > 0)
|
||||||
{
|
{
|
||||||
WeaponPaints.logger!.LogInformation("Probably dev version detected");
|
logger.LogInformation("Probably dev version detected");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WeaponPaints.logger!.LogInformation("Plugin is up to date");
|
logger.LogInformation("Plugin is up to date");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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;
|
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
||||||
|
|
||||||
|
if (isKnife)
|
||||||
|
{
|
||||||
|
weapon.AttributeManager.Item.EntityQuality = 3;
|
||||||
|
}
|
||||||
|
|
||||||
if (_config.Additional.GiveRandomSkin &&
|
if (_config.Additional.GiveRandomSkin &&
|
||||||
!gPlayerWeaponsInfo[playerIndex].ContainsKey(weaponDefIndex))
|
!gPlayerWeaponsInfo[playerIndex].ContainsKey(weaponDefIndex))
|
||||||
{
|
{
|
||||||
@@ -280,10 +285,10 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
private static int GetRandomPaint(int defindex)
|
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
|
// Filter weapons by the provided defindex
|
||||||
var filteredWeapons = skinsList.FindAll(w => w["weapon_defindex"]?.ToString() == defindex.ToString());
|
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 CounterStrikeSharp.API.Modules.Cvars;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.Localization;
|
||||||
|
|
||||||
namespace WeaponPaints;
|
namespace WeaponPaints;
|
||||||
|
|
||||||
[MinimumApiVersion(101)]
|
[MinimumApiVersion(121)]
|
||||||
public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
||||||
{
|
{
|
||||||
internal static ILogger? logger;
|
|
||||||
internal static readonly Dictionary<string, string> weaponList = new()
|
internal static readonly Dictionary<string, string> weaponList = new()
|
||||||
{
|
{
|
||||||
{"weapon_deagle", "Desert Eagle"},
|
{"weapon_deagle", "Desert Eagle"},
|
||||||
@@ -70,6 +70,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
};
|
};
|
||||||
|
|
||||||
internal static WeaponPaintsConfig _config = new 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, int> g_knifePickupCount = new Dictionary<int, int>();
|
||||||
internal static Dictionary<int, string> g_playersKnife = new();
|
internal static Dictionary<int, string> g_playersKnife = new();
|
||||||
internal static Dictionary<int, Dictionary<int, WeaponInfo>> gPlayerWeaponsInfo = new Dictionary<int, Dictionary<int, WeaponInfo>>();
|
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 ModuleAuthor => "Nereziel & daffyy";
|
||||||
public override string ModuleDescription => "Skin and knife selector, standalone and web-based";
|
public override string ModuleDescription => "Skin and knife selector, standalone and web-based";
|
||||||
public override string ModuleName => "WeaponPaints";
|
public override string ModuleName => "WeaponPaints";
|
||||||
public override string ModuleVersion => "1.3f";
|
public override string ModuleVersion => "1.3g";
|
||||||
|
|
||||||
public static WeaponPaintsConfig GetWeaponPaintsConfig()
|
public static WeaponPaintsConfig GetWeaponPaintsConfig()
|
||||||
{
|
{
|
||||||
return _config;
|
return _config;
|
||||||
@@ -182,10 +184,13 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
_ = weaponSync.GetWeaponPaintsFromDatabase(playerInfo);
|
_ = weaponSync.GetWeaponPaintsFromDatabase(playerInfo);
|
||||||
if (Config.Additional.KnifeEnabled && weaponSync != null)
|
if (Config.Additional.KnifeEnabled && weaponSync != null)
|
||||||
_ = weaponSync.GetKnifeFromDatabase(playerInfo);
|
_ = weaponSync.GetKnifeFromDatabase(playerInfo);
|
||||||
}
|
|
||||||
|
|
||||||
|
g_knifePickupCount[(int)player!.Index] = 0;
|
||||||
|
}
|
||||||
|
/*
|
||||||
RegisterListeners();
|
RegisterListeners();
|
||||||
RegisterCommands();
|
RegisterCommands();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.Additional.KnifeEnabled)
|
if (Config.Additional.KnifeEnabled)
|
||||||
@@ -212,9 +217,11 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
|
|
||||||
Config = config;
|
Config = config;
|
||||||
_config = config;
|
_config = config;
|
||||||
|
_localizer = Localizer;
|
||||||
|
|
||||||
Utility.Config = config;
|
Utility.Config = config;
|
||||||
Utility.ShowAd(ModuleVersion);
|
Utility.ShowAd(ModuleVersion);
|
||||||
Task.Run(async () => await Utility.CheckVersion(ModuleVersion));
|
Task.Run(async () => await Utility.CheckVersion(ModuleVersion, Logger));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Unload(bool hotReload)
|
public override void Unload(bool hotReload)
|
||||||
|
|||||||
@@ -5,12 +5,17 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CounterStrikeSharp.API" Version="*" />
|
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.121" />
|
||||||
<PackageReference Include="Dapper" Version="2.1.24" />
|
<PackageReference Include="Dapper" Version="2.1.24" />
|
||||||
<PackageReference Include="MySqlConnector" Version="2.3.1" />
|
<PackageReference Include="MySqlConnector" Version="2.3.1" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="lang\**\*.*" CopyToOutputDirectory="PreserveNewest" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using CounterStrikeSharp.API;
|
using Dapper;
|
||||||
using CounterStrikeSharp.API.Core;
|
|
||||||
using Dapper;
|
|
||||||
using MySqlConnector;
|
using MySqlConnector;
|
||||||
using Newtonsoft.Json.Linq;
|
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