-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathAntiRaid.cs
More file actions
68 lines (51 loc) · 2.35 KB
/
Copy pathAntiRaid.cs
File metadata and controls
68 lines (51 loc) · 2.35 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
using Newtonsoft.Json;
namespace Oxide.Plugins
{
[Info("AntiRaid", "walkinrey", "1.0.8")]
public class AntiRaid : RustPlugin
{
private const string _permission = "antiraid.use";
#region Конфиг
private Configuration _config;
private class Configuration
{
[JsonProperty("Сообщение если у игрока есть антирейд")]
public string msgAntiRaid = "У этого игрока активен антирейд, его невозможно зарейдить.";
[JsonProperty("Белый список объектов, на которые будет действовать антирейд")]
public string[] whiteList = {"wall.frame.cell", "wall.window.glass.reinforced", "wall.window.bars.toptier", "floor.grill", "floor.triangle.grill", "gates.external.high.stone", "wall.external.high.stone", "gates.external.high.wood", "wall.external.high"};
[JsonProperty("Черный список объектов, на которые не будет действовать антирейд")]
public string[] blackList = {"wall.frame.cell.gate"};
}
protected override void LoadConfig()
{
base.LoadConfig();
try
{
_config = Config.ReadObject<Configuration>();
}
catch
{
LoadDefaultConfig();
}
Config.WriteObject(_config, true);
}
protected override void LoadDefaultConfig() => _config = new Configuration();
#endregion
#region Хуки
private void Loaded() => permission.RegisterPermission(_permission, this);
private object OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
{
if(entity == null || info == null || _config.blackList.Contains(entity?.ShortPrefabName) || info?.InitiatorPlayer == null) return null;
if(entity is BuildingBlock || entity is Door || _config.whiteList.Contains(entity.ShortPrefabName))
{
if(entity.OwnerID != info.InitiatorPlayer.userID && permission.UserHasPermission(entity.OwnerID.ToString(), _permission))
{
info.InitiatorPlayer.ChatMessage(_config.msgAntiRaid);
return false;
}
}
return null;
}
#endregion
}
}