-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandFobDeploy.cs
More file actions
119 lines (109 loc) · 5.11 KB
/
CommandFobDeploy.cs
File metadata and controls
119 lines (109 loc) · 5.11 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
using Rocket.API;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Player;
using SDG.Unturned;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace Ekin.EACFOB
{
public class CommandFobDeploy : IRocketCommand
{
public AllowedCaller AllowedCaller => AllowedCaller.Player;
public string Name => "fobcreate";
public string Help => "";
public string Syntax => "";
public List<string> Aliases => new List<string>();
public List<string> Permissions => new List<string>();
public void Execute(IRocketPlayer caller, string[] command)
{
UnturnedPlayer uplayer = (UnturnedPlayer)caller;
float time = Time.time;
var INST = EACFOBPlugin.Instance;
if(INST.CanDeployFob)
{if (INST.LastFobKurTime.ContainsKey(uplayer))
{
float num = INST.LastFobKurTime[uplayer];
if (time - num < (float)INST.Configuration.Instance.createfobcooldown && !uplayer.IsAdmin)// COOLDOWN CONFIGE ATILACAK
{
int num2 = (int)(EACFOBPlugin.Instance.Configuration.Instance.createfobcooldown - (time - num));
UnturnedChat.Say(caller, string.Format("You have to wait {0} seconds for establishing next fob.", num2));
return;
}
}
if (command.Length < 1)
{
UnturnedChat.Say(caller, "How to use: /fobcreate <team> <name>");
UnturnedChat.Say(caller, "Teams: " + INST.Configuration.Instance.team1type + ", " + INST.Configuration.Instance.team2type );
return;
}
string text = command[0].ToLower();
string key = command[1].ToLower();
if (text != INST.Configuration.Instance.team1type.ToLower() && text != INST.Configuration.Instance.team2type.ToLower())
{
UnturnedChat.Say(caller, "Invalid Team");
UnturnedChat.Say(caller, "Teams: " + INST.Configuration.Instance.team1type + ", " + INST.Configuration.Instance.team2type);
return;
}
if (!IRocketPlayerExtension.HasPermission(uplayer, text)) // AND A2 TEAM
{
UnturnedChat.Say(caller, "You dont have " + text + " Permission.");
return;
}
if (INST.Fobs.ContainsKey(key))
{
UnturnedChat.Say(caller, "There is a FOB with this name.");
return;
}
Vector3 position = uplayer.Position;
Quaternion rotation = uplayer.Player.transform.rotation;
ItemBarricadeAsset bar1 = (ItemBarricadeAsset)Assets.find((EAssetType)1, INST.Configuration.Instance.fobobjectid);
if (!INST.Configuration.Instance.samefob)
{
if(text == INST.Configuration.Instance.team1type) bar1 = (ItemBarricadeAsset)Assets.find((EAssetType)1, INST.Configuration.Instance.team1fobobjectid);
if(text == INST.Configuration.Instance.team2type) bar1 = (ItemBarricadeAsset)Assets.find((EAssetType)1, INST.Configuration.Instance.team2fobobjectid);
}
if (bar1 == null)
{
UnturnedChat.Say(caller, "Failed to find Flag Asset, check configuration.");
return;
}
Barricade bar2 = new Barricade(bar1);
Vector3 pos = new Vector3(position.x, position.y + INST.Configuration.Instance.fobobjectYadjust, position.z);
Transform tran = BarricadeManager.dropBarricade(bar2, null, pos, 0f, 0f, 0f, uplayer.CSteamID.m_SteamID, 99);
BarricadeDrop barD = null;
float inf = float.MaxValue;
BarricadeRegion[,] regions = BarricadeManager.regions;
foreach (BarricadeRegion uplayer7 in regions)
{
foreach (BarricadeDrop drop in uplayer7.drops)
{
float dis = Vector3.Distance(drop.model.position, position);
if (dis < inf)
{
inf = dis;
barD = drop;
}
}
}
if (barD != null && inf < 2f + INST.Configuration.Instance.fobobjectYadjust)
{
INST.Fobs[key] = new FobData(position, (ushort)barD.instanceID, command[1], uplayer.CharacterName, text.ToUpper());
INST.LastFobKurTime[uplayer] = time;
UnturnedChat.Say(caller, text.ToUpper() + " FOB " + command[1] + " succsefully established!");
}
else
{
UnturnedChat.Say(caller, text.ToUpper() + " FOB " + command[1] + " failed to established!");
}
}
else
{
UnturnedChat.Say(caller, "Deploying fob is not active");
}
}
}
}