mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-02-18 02:41:54 +00:00
fixxx
This commit is contained in:
25
Events.cs
25
Events.cs
@@ -1,14 +1,5 @@
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Entities;
|
||||
using CounterStrikeSharp.API.Core.Attributes;
|
||||
using CounterStrikeSharp.API.Core.Attributes.Registration;
|
||||
using CounterStrikeSharp.API.Modules.Utils;
|
||||
using CounterStrikeSharp.API.Modules.Admin;
|
||||
using CounterStrikeSharp.API.Modules.Commands;
|
||||
using CounterStrikeSharp.API.Modules.Cvars;
|
||||
using CounterStrikeSharp.API.Modules.Memory;
|
||||
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
|
||||
|
||||
namespace WeaponPaints
|
||||
{
|
||||
@@ -25,7 +16,6 @@ namespace WeaponPaints
|
||||
RegisterEventHandler<EventRoundStart>(OnRoundStart, HookMode.Pre);
|
||||
RegisterEventHandler<EventItemPurchase>(OnEventItemPurchasePost);
|
||||
RegisterEventHandler<EventItemPickup>(OnItemPickup);
|
||||
|
||||
}
|
||||
|
||||
private HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventInfo info)
|
||||
@@ -59,8 +49,10 @@ namespace WeaponPaints
|
||||
{
|
||||
NativeAPI.IssueServerCommand("mp_t_default_melee \"\"");
|
||||
NativeAPI.IssueServerCommand("mp_ct_default_melee \"\"");
|
||||
NativeAPI.IssueServerCommand("mp_equipment_reset_rounds 0");
|
||||
});
|
||||
}
|
||||
/*
|
||||
private void OnClientAuthorized(int playerSlot, SteamID steamID)
|
||||
{
|
||||
int playerIndex = playerSlot + 1;
|
||||
@@ -72,6 +64,7 @@ namespace WeaponPaints
|
||||
await weaponSync.GetKnifeFromDatabase(playerIndex);
|
||||
});
|
||||
}
|
||||
*/
|
||||
private void OnClientDisconnect(int playerSlot)
|
||||
{
|
||||
CCSPlayerController player = Utilities.GetPlayerFromSlot(playerSlot);
|
||||
@@ -110,6 +103,7 @@ namespace WeaponPaints
|
||||
{
|
||||
NativeAPI.IssueServerCommand("mp_t_default_melee \"\"");
|
||||
NativeAPI.IssueServerCommand("mp_ct_default_melee \"\"");
|
||||
NativeAPI.IssueServerCommand("mp_equipment_reset_rounds 0");
|
||||
|
||||
return HookResult.Continue;
|
||||
}
|
||||
@@ -118,22 +112,27 @@ namespace WeaponPaints
|
||||
if (@event.Defindex == 42 || @event.Defindex == 59)
|
||||
{
|
||||
CCSPlayerController? player = @event.Userid;
|
||||
if (!Utility.IsPlayerValid(player) || !player.PawnIsAlive || g_knifePickupCount[(int)player.EntityIndex!.Value.Value] >= 1) return HookResult.Continue;
|
||||
if (!Utility.IsPlayerValid(player) || !player.PawnIsAlive || g_knifePickupCount[(int)player.EntityIndex!.Value.Value] >= 2) return HookResult.Continue;
|
||||
|
||||
if (g_playersKnife.ContainsKey((int)player.EntityIndex!.Value.Value)
|
||||
&&
|
||||
g_playersKnife[(int)player.EntityIndex!.Value.Value] != "weapon_knife")
|
||||
{
|
||||
g_knifePickupCount[(int)player.EntityIndex!.Value.Value]++;
|
||||
RefreshPlayerKnife(player);
|
||||
|
||||
RemovePlayerKnife(player, true);
|
||||
AddTimer(0.3f, ()=> GiveKnifeToPlayer(player));
|
||||
|
||||
//RefreshPlayerKnife(player);
|
||||
/*
|
||||
if (!PlayerHasKnife(player))
|
||||
GiveKnifeToPlayer(player);
|
||||
*/
|
||||
|
||||
if (Config.Additional.SkinVisibilityFix)
|
||||
{
|
||||
AddTimer(0.25f, () => RefreshSkins(player));
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
return HookResult.Continue;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Entities;
|
||||
using CounterStrikeSharp.API.Modules.Utils;
|
||||
using Dapper;
|
||||
using MySqlConnector;
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace WeaponPaints
|
||||
player.GiveNamedItem(defaultKnife);
|
||||
}
|
||||
}
|
||||
internal void RemovePlayerKnife(CCSPlayerController? player)
|
||||
internal void RemovePlayerKnife(CCSPlayerController? player, bool force = false)
|
||||
{
|
||||
if (player == null || !player.IsValid || !player.PawnIsAlive) return;
|
||||
if (player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null) return;
|
||||
@@ -93,19 +93,26 @@ namespace WeaponPaints
|
||||
//if (weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 42 || weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 59)
|
||||
if (weapon.Value.DesignerName.Contains("knife") || weapon.Value.DesignerName.Contains("bayonet"))
|
||||
{
|
||||
if (!weapon.Value.EntityIndex.HasValue) return;
|
||||
int weaponEntityIndex = (int)weapon.Value.EntityIndex!.Value.Value;
|
||||
NativeAPI.IssueClientCommand((int)player.EntityIndex!.Value.Value - 1, "slot3");
|
||||
AddTimer(0.35f, () => service.DropActivePlayerWeapon(weapon.Value));
|
||||
|
||||
AddTimer(1.0f, () =>
|
||||
if (!force)
|
||||
{
|
||||
CEntityInstance? knife = Utilities.GetEntityFromIndex<CEntityInstance>(weaponEntityIndex);
|
||||
if (knife != null && knife.IsValid)
|
||||
if (!weapon.Value.EntityIndex.HasValue) return;
|
||||
int weaponEntityIndex = (int)weapon.Value.EntityIndex!.Value.Value;
|
||||
NativeAPI.IssueClientCommand((int)player.EntityIndex!.Value.Value - 1, "slot3");
|
||||
AddTimer(0.35f, () => service.DropActivePlayerWeapon(weapon.Value));
|
||||
|
||||
AddTimer(1.0f, () =>
|
||||
{
|
||||
knife.Remove();
|
||||
}
|
||||
});
|
||||
CEntityInstance? knife = Utilities.GetEntityFromIndex<CEntityInstance>(weaponEntityIndex);
|
||||
if (knife != null && knife.IsValid)
|
||||
{
|
||||
knife.Remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
weapon.Value.Remove();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -151,13 +158,18 @@ namespace WeaponPaints
|
||||
}
|
||||
});
|
||||
|
||||
AddTimer(2.5f, () =>
|
||||
Task.Delay(TimeSpan.FromSeconds(3.5)).ContinueWith(_ =>
|
||||
{
|
||||
CEntityInstance? knife = Utilities.GetEntityFromIndex<CEntityInstance>(weaponEntityIndex);
|
||||
if (knife != null && knife.IsValid && knife.EntityIndex.HasValue)
|
||||
try
|
||||
{
|
||||
knife.Remove();
|
||||
CEntityInstance? knife = Utilities.GetEntityFromIndex<CEntityInstance>(weaponEntityIndex);
|
||||
|
||||
if (knife != null && knife.IsValid && knife.Handle != -1 && knife.EntityIndex.HasValue)
|
||||
{
|
||||
knife.Remove();
|
||||
}
|
||||
}
|
||||
catch (Exception) { }
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WeaponPaints
|
||||
namespace WeaponPaints
|
||||
{
|
||||
public class WeaponInfo
|
||||
{
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Core.Attributes;
|
||||
using CounterStrikeSharp.API.Modules.Memory;
|
||||
using CounterStrikeSharp.API.Modules.Utils;
|
||||
using CounterStrikeSharp.API.Modules.Cvars;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace WeaponPaints;
|
||||
[MinimumApiVersion(61)]
|
||||
[MinimumApiVersion(71)]
|
||||
public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
||||
{
|
||||
public override string ModuleName => "WeaponPaints";
|
||||
|
||||
Reference in New Issue
Block a user