This repository has been archived by the owner on May 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLockProgression.cs
100 lines (86 loc) · 3.37 KB
/
LockProgression.cs
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
using Oxide.Core;
using System;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using System.Linq;
using System.Collections.Generic;
namespace Oxide.Plugins
{
[Info("LockProgression", "Auro", "1.0.0")]
[Description("Locks certain monuments and events until a certain time")]
public class LockProgression : RustPlugin
{
[PluginReference]
Plugin MonumentFinder;
private const string usePerm = "lockprogression.use";
bool lockProgression = false;
bool lockAttackHeli = false;
float time = 3600f;
DateTime startTime;
void Init()
{
permission.RegisterPermission(usePerm, this);
}
[ChatCommand("starttimer")]
void StartTimer(BasePlayer player, string command, string[] args)
{
if (!permission.UserHasPermission(player.UserIDString, usePerm))
{
SendReply(player, "You don't have permission to use this command");
return;
}
startTime = DateTime.UtcNow;
lockProgression = true;
timer.Once(time, () => { lockProgression = false; Server.Broadcast("The Oilrigs crates are now hackable!"); });
}
[ChatCommand("lockheli")]
void LockHeli(BasePlayer player, string command, string[] args)
{
if (!permission.UserHasPermission(player.UserIDString, usePerm))
{
SendReply(player, "You don't have permission to use this command");
return;
}
lockAttackHeli = true;
}
[ChatCommand("unlockheli")]
void UnlockHeli(BasePlayer player, string command, string[] args)
{
if (!permission.UserHasPermission(player.UserIDString, usePerm))
{
SendReply(player, "You don't have permission to use this command");
return;
}
lockAttackHeli = false;
}
void OnEntitySpawned(BaseNetworkable entity)
{
if (entity.ShortPrefabName.Contains("cargoship") && lockProgression)
{
Puts(entity.ShortPrefabName);
entity.Kill();
}
if (entity.ShortPrefabName == "patrolhelicopter" && lockAttackHeli)
{
Puts(entity.ShortPrefabName);
entity.Kill();
}
if (entity.ShortPrefabName == "patrolhelicopter" && lockProgression)
{
Puts(entity.ShortPrefabName);
entity.Kill();
}
}
private object CanHackCrate(BasePlayer player, HackableLockedCrate crate)
{
if (crate.PrefabName == "assets/prefabs/deployable/chinooklockedcrate/codelockedhackablecrate_oilrig.prefab" && lockProgression)
{
int secondsRemaining = (int)(time - (DateTime.UtcNow - startTime).TotalSeconds);
string humanizedTime = TimeSpan.FromSeconds(secondsRemaining).Minutes + " minute" + (TimeSpan.FromSeconds(secondsRemaining).Minutes == 1 ? "" : "s") + " and " + TimeSpan.FromSeconds(secondsRemaining).Seconds + " second" + (TimeSpan.FromSeconds(secondsRemaining).Seconds == 1 ? "" : "s");
player.ChatMessage($"You can't hack this crate for {humanizedTime}");
return true;
}
return null;
}
}
}