-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathCCSPlayerControllerExtensions.cs
More file actions
103 lines (92 loc) · 4.39 KB
/
Copy pathCCSPlayerControllerExtensions.cs
File metadata and controls
103 lines (92 loc) · 4.39 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Admin;
using CounterStrikeSharp.API.Modules.Entities;
using CounterStrikeSharp.API.Modules.Utils;
using CSPracc.DataModules;
using CSPracc.DataModules.Constants;
using CSPracc.Extensions;
using CSPracc.Managers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CSPracc
{
public static class CCSPlayerControllerExtensions
{
public static bool IsAdmin(this CCSPlayerController playerController)
{
if(!CSPraccPlugin.Instance!.Config!.AdminRequirement)
{
return true;
}
// check if they have permission (starting with least privileged)
return AdminManager.PlayerHasPermissions(playerController, AdminFlags.Standard)
|| AdminManager.PlayerHasPermissions(playerController, AdminFlags.Root);
}
public static CsTeam GetCsTeam(this CCSPlayerController playerController)
{
if (playerController == null) { return CsTeam.None; }
if (!playerController.IsValid) { return CsTeam.None; }
return (CsTeam)playerController.TeamNum;
}
public static Position? GetCurrentPosition(this CCSPlayerController playerController)
{
if (playerController == null) { return null; }
if (!playerController.IsValid) { return null; }
return new Position(playerController.PlayerPawn.Value!.CBodyComponent!.SceneNode!.AbsOrigin, playerController.PlayerPawn.Value.EyeAngles);
}
public static JsonSpawnPoint? GetCurrentPositionAsJsonSpawnPoint(this CCSPlayerController playerController)
{
if (playerController == null) { return null; }
if (!playerController.IsValid) { return null; }
return new JsonSpawnPoint(playerController.PlayerPawn.Value!.CBodyComponent!.SceneNode!.AbsOrigin.ToVector3(), playerController.PlayerPawn.Value!.EyeAngles.ToVector3(),"");
}
public static void TeleportToJsonSpawnPoint(this CCSPlayerController playerController,JsonSpawnPoint? jsonSpawnPoint)
{
if (playerController == null) { return; }
if (!playerController.IsValid) { return; }
if (jsonSpawnPoint == null)
{
return;
}
playerController.PlayerPawn.Value!.Teleport(jsonSpawnPoint.Position.ToCSVector(), jsonSpawnPoint.QAngle.ToCSQAngle(), new Vector(0, 0, 0));
}
public static void TeleportToPosition(this CCSPlayerController playerController, Position? position)
{
if (playerController == null) { return; }
if (!playerController.IsValid) { return; }
if (position == null)
{
return;
}
playerController.PlayerPawn.Value!.Teleport(position.PlayerPosition,position.PlayerAngle, new Vector(0, 0, 0));
}
public static void HtmlMessage(this CCSPlayerController playerController,string message,int timetodisplay = 5)
{
if(playerController == null) { return; }
if(!playerController.IsValid) { return; }
if(message == null) { return; }
HtmlMessage htmlMessage = new HtmlMessage(message, timetodisplay);
GuiManager.Instance!.ShowHtmlMessage(htmlMessage, playerController);
}
public static bool GetValueOfCookie(this CCSPlayerController playerController,string Cookie,out string? value)
{
value = null;
if (playerController == null || !playerController.IsValid) { return false; }
return CookieManager.GetValueOfCookie(playerController, Cookie, out value);
}
public static bool SetOrAddValueOfCookie(this CCSPlayerController playerController, string Cookie, string value)
{
if (playerController == null || !playerController.IsValid) { return false; }
return CookieManager.AddOrSetValueOfCookie(playerController, Cookie, value);
}
public static void ChatMessage(this CCSPlayerController playerController, string message)
{
if (playerController == null || !playerController.IsValid) { return; }
playerController.PrintToChat($"{CSPraccPlugin.Instance!.Config!.ChatPrefix} {message}");
}
}
}