-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathModels.cs
More file actions
78 lines (72 loc) · 2.79 KB
/
Models.cs
File metadata and controls
78 lines (72 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes.Registration;
using CounterStrikeSharp.API.Modules.Admin;
using CounterStrikeSharp.API.Modules.Commands;
using CounterStrikeSharp.API.Modules.Menu;
using CounterStrikeSharp.API.Modules.Timers;
using CounterStrikeSharp.API.Modules.Utils;
using Newtonsoft.Json.Linq;
using Nexd.MySQL;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Xml.Linq;
using CS2MenuManager;
namespace CustomPlugin
{
public partial class CustomPlugin
{
public void SetModel(CCSPlayerController? player, string path, string name)
{
if (player == null) return;
if (path == null) return;
if (name == null) return;
var pawn = player?.Pawn.Value!;
var originalRender = pawn?.Render;
uint index = player!.Index;
if (SelectedModel[index] == 0)
{
return;
}
AddTimer(1.0f, () =>
{
if (path != null || SelectedModel[player.Index] >= 1)
{
pawn?.SetModel(path!);
//pawn.Render = Color.FromArgb(255, originalRender.Value.R, originalRender.Value.G, originalRender.Value.B);
//Utilities.SetStateChanged(pawn, "CBaseModelEntity", "m_clrRender");
//Utilities.SetStateChanged(pawn, "CBaseEntity", "m_CBodyComponent");
player.PrintToChat($" {Config.Prefix} {Localizer["LoadedModel", name]}");
}
});
}
public void PrecacheResource(ResourceManifest mainfest)
{
if (!Config.ModelsEnabled) return;
if (!Config.Precache) return;
List<string> Resource = new List<string>();
MySqlDb MySql = new MySqlDb(Config.DBHost, Config.DBUser, Config.DBPassword, Config.DBDatabase);
MySqlQueryResult result = MySql!
.Table("deadswim_models")
.Select();
for (int i = 0; i < result.Rows; i++)
{
var row = result[i];
if (row == null) return;
string path = Convert.ToString(row["path"]) ?? string.Empty;
Resource.Add(path);
mainfest.AddResource(path);
Server.PrecacheModel(path);
}
Resource.Add(Config.NadeModel);
foreach (string data in Resource)
{
mainfest.AddResource(data);
Server.PrintToConsole($"--->>>Loading Resource<<<--- PATH: {data}");
}
}
}
}