Skip to content

Commit 06968e6

Browse files
authored
Plugin Files
1 parent 20010e2 commit 06968e6

28 files changed

Lines changed: 1193 additions & 0 deletions

CommandAllFobs.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using Rocket.API;
2+
using Rocket.Unturned.Chat;
3+
using Rocket.Unturned.Player;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
using UnityEngine;
10+
11+
namespace Ekin.EACFOB
12+
{
13+
internal class CommandAllFobs : IRocketCommand
14+
{
15+
public AllowedCaller AllowedCaller => AllowedCaller.Player;
16+
17+
public string Name => "afobs";
18+
19+
public string Help => "";
20+
21+
public string Syntax => "";
22+
23+
public List<string> Aliases => new List<string>();
24+
25+
public List<string> Permissions => new List<string>();
26+
27+
public void Execute(IRocketPlayer caller, string[] command)
28+
{
29+
UnturnedPlayer val = (UnturnedPlayer)caller;
30+
if (EACFOBPlugin.Instance.Fobs.Count == 0)
31+
{
32+
UnturnedChat.Say(caller, "There is no active fob", Color.yellow);
33+
return;
34+
}
35+
UnturnedChat.Say(caller, "=== FOB LIST ===", Color.yellow);
36+
int num = 0;
37+
foreach (var fob in EACFOBPlugin.Instance.Fobs)
38+
{
39+
UnturnedChat.Say(caller, "* " + fob.Value.Name + " Team: " + fob.Value.Type + " ID: " + fob.Value.InstanceID, Color.white);
40+
num++;
41+
42+
}
43+
UnturnedChat.Say(caller, num + " Fobs Listed", Color.blue);
44+
}
45+
}
46+
}

CommandClearFobandBarricades.cs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
using Rocket.API;
2+
using Rocket.Unturned.Chat;
3+
using SDG.Unturned;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
using UnityEngine;
10+
11+
namespace Ekin.EACFOB
12+
{
13+
internal class CommandClearFobandBarricades : IRocketCommand
14+
{
15+
public AllowedCaller AllowedCaller => AllowedCaller.Player;
16+
17+
public string Name => "FobCleanAll";
18+
19+
public string Help => "";
20+
21+
public string Syntax => "";
22+
23+
public List<string> Aliases => new List<string>();
24+
25+
public List<string> Permissions => new List<string>();
26+
27+
public void Execute(IRocketPlayer caller, string[] command)
28+
{
29+
30+
var INST = EACFOBPlugin.Instance;
31+
UnturnedChat.Say(caller,"Fob cleaning started.", Color.magenta);
32+
33+
int deleted = 0;
34+
35+
foreach (var region in BarricadeManager.regions)
36+
{
37+
for (int i = region.drops.Count - 1; i >= 0; i--)
38+
{
39+
var drop = region.drops[i];
40+
41+
ushort id = drop.asset.id;
42+
if (id == INST.Configuration.Instance.fobobjectid ||
43+
id == INST.Configuration.Instance.team1fobobjectid ||
44+
id == INST.Configuration.Instance.team2fobobjectid)
45+
{
46+
if (BarricadeManager.tryGetRegion(drop.model.transform, out byte x, out byte y, out ushort plant, out BarricadeRegion correctRegion))
47+
{
48+
int index = correctRegion.drops.FindIndex(d => d.instanceID == drop.instanceID);
49+
if (index != -1)
50+
{
51+
BarricadeManager.destroyBarricade(correctRegion, x, y, plant, (ushort)index);
52+
deleted++;
53+
}
54+
}
55+
}
56+
}
57+
}
58+
59+
UnturnedChat.Say($"Fob cleaning complated, {deleted} Fob/OldBarricade deleted.", Color.cyan);
60+
}
61+
}
62+
}

CommandDisableFobDeploy.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using Rocket.API;
2+
using Rocket.Unturned.Chat;
3+
using Rocket.Unturned.Player;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
using UnityEngine;
10+
11+
namespace Ekin.EACFOB
12+
{
13+
internal class CommandDisableFobDeploy : IRocketCommand
14+
{
15+
public AllowedCaller AllowedCaller => AllowedCaller.Both;
16+
17+
public string Name => "fobdisable";
18+
19+
public string Help => "";
20+
21+
public string Syntax => "";
22+
23+
public List<string> Aliases => new List<string>();
24+
25+
public List<string> Permissions => new List<string>();
26+
27+
public void Execute(IRocketPlayer caller, string[] command)
28+
{
29+
UnturnedPlayer player = (UnturnedPlayer)caller;
30+
bool isdeployfobenable = EACFOBPlugin.Instance.CanDeployFob;
31+
if (isdeployfobenable)
32+
{
33+
UnturnedChat.Say( "Deploying fob is now deactive", Color.red);
34+
EACFOBPlugin.Instance.CanDeployFob = false;
35+
}
36+
else
37+
{
38+
UnturnedChat.Say( "Deploying fob is now active", Color.blue);
39+
EACFOBPlugin.Instance.CanDeployFob = true;
40+
}
41+
}
42+
}
43+
}

CommandFob.cs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using Rocket.API;
2+
using Rocket.Unturned.Chat;
3+
using Rocket.Unturned.Player;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
10+
namespace Ekin.EACFOB
11+
{
12+
public class CommandFob : IRocketCommand
13+
{
14+
public AllowedCaller AllowedCaller => AllowedCaller.Player;
15+
16+
public string Name => "fob";
17+
18+
public string Help => "";
19+
20+
public string Syntax => "";
21+
22+
public List<string> Aliases => new List<string>();
23+
24+
public List<string> Permissions => new List<string>();
25+
26+
public void Execute(IRocketPlayer caller, string[] command)
27+
{
28+
UnturnedPlayer val = (UnturnedPlayer)caller;
29+
if(command.Length == 0)
30+
{
31+
UnturnedChat.Say(caller, "How to use: /fob <name>");
32+
return;
33+
}
34+
string key = command[0].ToLower();
35+
var INST = EACFOBPlugin.Instance;
36+
if (!INST.Fobs.ContainsKey(key))
37+
{
38+
UnturnedChat.Say(caller, command[0] + " FOB not found");
39+
return;
40+
}
41+
FobData fobdata = INST.Fobs[key];
42+
bool flag = IRocketPlayerExtension.HasPermission(caller, INST.Configuration.Instance.team1permission);
43+
bool flag2 = IRocketPlayerExtension.HasPermission(caller, INST.Configuration.Instance.team2permission);
44+
bool flag3 = false;
45+
if(fobdata.Type == INST.Configuration.Instance.team1type.ToUpper() && flag)
46+
{
47+
flag3 = true;
48+
}
49+
else if (fobdata.Type == INST.Configuration.Instance.team2type.ToUpper() && flag2)
50+
{
51+
flag3 = true;
52+
}
53+
if (!flag3)
54+
{
55+
UnturnedChat.Say(caller, "You dont have permission to access " + fobdata.Type + " fob");
56+
return;
57+
}
58+
if(INST.TeleportRequests.ContainsKey(val))
59+
{
60+
UnturnedChat.Say(caller, "You already teleporting to another FOB!");
61+
return;
62+
}
63+
TeleportRequest value = new TeleportRequest(val, fobdata);
64+
INST.TeleportRequests[val] = value;
65+
UnturnedChat.Say(caller, "Teleporting to " + fobdata.Name + ", wait for " + INST.Configuration.Instance.teleportcooldown + " seconds.");
66+
67+
}
68+
}
69+
}

CommandFobDeploy.cs

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
using Rocket.API;
2+
using Rocket.Unturned.Chat;
3+
using Rocket.Unturned.Player;
4+
using SDG.Unturned;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
using UnityEngine;
11+
12+
namespace Ekin.EACFOB
13+
{
14+
public class CommandFobDeploy : IRocketCommand
15+
{
16+
public AllowedCaller AllowedCaller => AllowedCaller.Player;
17+
18+
public string Name => "fobcreate";
19+
20+
public string Help => "";
21+
22+
public string Syntax => "";
23+
24+
public List<string> Aliases => new List<string>();
25+
26+
public List<string> Permissions => new List<string>();
27+
28+
public void Execute(IRocketPlayer caller, string[] command)
29+
{
30+
UnturnedPlayer uplayer = (UnturnedPlayer)caller;
31+
float time = Time.time;
32+
var INST = EACFOBPlugin.Instance;
33+
if(INST.CanDeployFob)
34+
{if (INST.LastFobKurTime.ContainsKey(uplayer))
35+
{
36+
float num = INST.LastFobKurTime[uplayer];
37+
if (time - num < (float)INST.Configuration.Instance.createfobcooldown && !uplayer.IsAdmin)// COOLDOWN CONFIGE ATILACAK
38+
{
39+
int num2 = (int)(EACFOBPlugin.Instance.Configuration.Instance.createfobcooldown - (time - num));
40+
UnturnedChat.Say(caller, string.Format("You have to wait {0} seconds for establishing next fob.", num2));
41+
return;
42+
}
43+
}
44+
if (command.Length < 1)
45+
{
46+
UnturnedChat.Say(caller, "How to use: /fobcreate <team> <name>");
47+
UnturnedChat.Say(caller, "Teams: " + INST.Configuration.Instance.team1type + ", " + INST.Configuration.Instance.team2type );
48+
return;
49+
}
50+
string text = command[0].ToLower();
51+
string key = command[1].ToLower();
52+
if (text != INST.Configuration.Instance.team1type.ToLower() && text != INST.Configuration.Instance.team2type.ToLower())
53+
{
54+
UnturnedChat.Say(caller, "Invalid Team");
55+
UnturnedChat.Say(caller, "Teams: " + INST.Configuration.Instance.team1type + ", " + INST.Configuration.Instance.team2type);
56+
return;
57+
}
58+
if (!IRocketPlayerExtension.HasPermission(uplayer, text)) // AND A2 TEAM
59+
{
60+
UnturnedChat.Say(caller, "You dont have " + text + " Permission.");
61+
return;
62+
}
63+
if (INST.Fobs.ContainsKey(key))
64+
{
65+
UnturnedChat.Say(caller, "There is a FOB with this name.");
66+
return;
67+
}
68+
Vector3 position = uplayer.Position;
69+
Quaternion rotation = uplayer.Player.transform.rotation;
70+
71+
ItemBarricadeAsset bar1 = (ItemBarricadeAsset)Assets.find((EAssetType)1, INST.Configuration.Instance.fobobjectid);
72+
if (!INST.Configuration.Instance.samefob)
73+
{
74+
if(text == INST.Configuration.Instance.team1type) bar1 = (ItemBarricadeAsset)Assets.find((EAssetType)1, INST.Configuration.Instance.team1fobobjectid);
75+
if(text == INST.Configuration.Instance.team2type) bar1 = (ItemBarricadeAsset)Assets.find((EAssetType)1, INST.Configuration.Instance.team2fobobjectid);
76+
77+
78+
}
79+
if (bar1 == null)
80+
{
81+
UnturnedChat.Say(caller, "Failed to find Flag Asset, check configuration.");
82+
return;
83+
}
84+
Barricade bar2 = new Barricade(bar1);
85+
Vector3 pos = new Vector3(position.x, position.y + INST.Configuration.Instance.fobobjectYadjust, position.z);
86+
Transform tran = BarricadeManager.dropBarricade(bar2, null, pos, 0f, 0f, 0f, uplayer.CSteamID.m_SteamID, 99);
87+
BarricadeDrop barD = null;
88+
float inf = float.MaxValue;
89+
BarricadeRegion[,] regions = BarricadeManager.regions;
90+
foreach (BarricadeRegion uplayer7 in regions)
91+
{
92+
foreach (BarricadeDrop drop in uplayer7.drops)
93+
{
94+
float dis = Vector3.Distance(drop.model.position, position);
95+
if (dis < inf)
96+
{
97+
inf = dis;
98+
barD = drop;
99+
}
100+
}
101+
}
102+
if (barD != null && inf < 2f + INST.Configuration.Instance.fobobjectYadjust)
103+
{
104+
INST.Fobs[key] = new FobData(position, (ushort)barD.instanceID, command[1], uplayer.CharacterName, text.ToUpper());
105+
INST.LastFobKurTime[uplayer] = time;
106+
UnturnedChat.Say(caller, text.ToUpper() + " FOB " + command[1] + " succsefully established!");
107+
}
108+
else
109+
{
110+
UnturnedChat.Say(caller, text.ToUpper() + " FOB " + command[1] + " failed to established!");
111+
}
112+
}
113+
else
114+
{
115+
UnturnedChat.Say(caller, "Deploying fob is not active");
116+
}
117+
}
118+
}
119+
}

0 commit comments

Comments
 (0)