-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e31a9a8
Showing
24 changed files
with
566 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.git | ||
.vs | ||
bin | ||
packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using System.Text.RegularExpressions; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Reflection; | ||
using System.Net; | ||
using Rocket.API; | ||
using Rocket.Unturned.Chat; | ||
using Rocket.Unturned.Player; | ||
using SDG.Unturned; | ||
using Steamworks; | ||
using UnityEngine; | ||
|
||
namespace NLREnforcer | ||
{ | ||
public static class ChatSystem | ||
{ | ||
public static CSteamID GetCSteamID(this string id) | ||
{ | ||
return new CSteamID(ulong.Parse(id)); | ||
} | ||
|
||
public static void sendMessage(this IRocketPlayer caller, String message) | ||
{ | ||
Regex filter = new Regex(@"<[^>]*>"); | ||
String formatlessMessage = filter.Replace(message, string.Empty); | ||
|
||
if (caller.DisplayName == "Console") | ||
{ | ||
UnturnedChat.Say(caller, formatlessMessage); | ||
} | ||
else | ||
{ | ||
ChatManager.serverSendMessage(message, UnityEngine.Color.white, null, UnturnedPlayer.FromCSteamID(caller.Id.GetCSteamID()).SteamPlayer(), EChatMode.SAY, null, true); | ||
} | ||
} | ||
|
||
public static void sendMessage(this IRocketPlayer caller, String message, String icon) | ||
{ | ||
Regex filter = new Regex(@"<[^>]*>"); | ||
String formatlessMessage = filter.Replace(message, string.Empty); | ||
|
||
if (caller.DisplayName == "Console") | ||
{ | ||
UnturnedChat.Say(caller, formatlessMessage); | ||
} | ||
else | ||
{ | ||
ChatManager.serverSendMessage(message, UnityEngine.Color.white, null, UnturnedPlayer.FromCSteamID(caller.Id.GetCSteamID()).SteamPlayer(), EChatMode.SAY, icon, true); | ||
} | ||
} | ||
|
||
public static void sendGlobalMessage(String message) | ||
{ | ||
ChatManager.serverSendMessage(message, UnityEngine.Color.white, null, null, EChatMode.GLOBAL, null, true); | ||
} | ||
|
||
public static void sendGlobalMessage(String message, String icon) | ||
{ | ||
ChatManager.serverSendMessage(message, UnityEngine.Color.white, null, null, EChatMode.GLOBAL, icon, true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Rocket.API; | ||
using Rocket.Core.Assets; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Xml.Serialization; | ||
using Rocket.Unturned.Items; | ||
using SDG.Unturned; | ||
|
||
namespace NLREnforcer | ||
{ | ||
public class Configuration : IRocketPluginConfiguration | ||
{ | ||
public int RestrictedRadiusFromDeathPosition; | ||
public int ClearDeathAfterSeconds; | ||
public bool MessageWhenAttemptToEnterRestrictedZone; | ||
public string MessageViolation; | ||
|
||
public void LoadDefaults() | ||
{ | ||
RestrictedRadiusFromDeathPosition = 50; | ||
ClearDeathAfterSeconds = 900; | ||
MessageWhenAttemptToEnterRestrictedZone = true; | ||
MessageViolation = "[<color=red> NLREnforcer </color>] You recently died here, you cannot come closer."; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{9E99BF38-30AF-464A-B33A-97560CCF7D35}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>NLREnforcer</RootNamespace> | ||
<AssemblyName>NLREnforcer</AssemblyName> | ||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Assembly-CSharp"> | ||
<HintPath>..\..\Taser Plugin\polioce\Police\bin\Debug\Assembly-CSharp.dll</HintPath> | ||
</Reference> | ||
<Reference Include="com.rlabrecque.steamworks.net"> | ||
<HintPath>..\..\Taser Plugin\polioce\Police\bin\Debug\com.rlabrecque.steamworks.net.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Rocket.API"> | ||
<HintPath>..\..\Taser Plugin\polioce\Police\bin\Debug\Rocket.API.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Rocket.Core"> | ||
<HintPath>..\..\Taser Plugin\polioce\Police\bin\Debug\Rocket.Core.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Rocket.Unturned"> | ||
<HintPath>..\..\Taser Plugin\polioce\Police\bin\Debug\Rocket.Unturned.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="UnityEngine"> | ||
<HintPath>..\..\Taser Plugin\polioce\Police\bin\Debug\UnityEngine.dll</HintPath> | ||
</Reference> | ||
<Reference Include="UnityEngine.CoreModule"> | ||
<HintPath>..\..\Taser Plugin\polioce\Police\bin\Debug\UnityEngine.CoreModule.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="ChatSystem.cs" /> | ||
<Compile Include="Plugin.cs" /> | ||
<Compile Include="Configuration.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Folder Include="Commands\" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.30517.126 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLREnforcer", "NLREnforcer.csproj", "{9E99BF38-30AF-464A-B33A-97560CCF7D35}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{9E99BF38-30AF-464A-B33A-97560CCF7D35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{9E99BF38-30AF-464A-B33A-97560CCF7D35}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{9E99BF38-30AF-464A-B33A-97560CCF7D35}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{9E99BF38-30AF-464A-B33A-97560CCF7D35}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {A93E9265-0A70-4158-846D-83F7D7BFF3A7} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
using System; | ||
using System.Timers; | ||
using System.Collections.Generic; | ||
using System.Collections; | ||
using System.Linq; | ||
using System.IO; | ||
using System.Net; | ||
using System.Xml; | ||
using System.Xml.Linq; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using System.Reflection; | ||
using System.Globalization; | ||
using Rocket.API; | ||
using Rocket.Core; | ||
using Rocket.Unturned; | ||
using Rocket.Unturned.Events; | ||
using Rocket.Unturned.Items; | ||
using Rocket.Unturned.Player; | ||
using Rocket.Unturned.Enumerations; | ||
using Rocket.Unturned.Plugins; | ||
using Rocket.Core.Logging; | ||
using Rocket.API.Collections; | ||
using Rocket.Core.Plugins; | ||
using SDG.Unturned; | ||
using Steamworks; | ||
using SDG; | ||
using UnityEngine; | ||
using UnityEngine.Events; | ||
using UP = Rocket.Unturned.Player.UnturnedPlayer; | ||
using Rocket.API.Serialisation; | ||
using Rocket.Unturned.Chat; | ||
using SDG.Provider; | ||
using Logger = Rocket.Core.Logging.Logger; | ||
|
||
namespace NLREnforcer | ||
{ | ||
public class EnforcerPlugin : RocketPlugin<Configuration> | ||
{ | ||
public static EnforcerPlugin Instance; | ||
public string Creator = "XXFOGS"; | ||
public string PluginName = "NLREnforcer"; | ||
public string Version = "1.0.0"; | ||
|
||
public static IDictionary<CSteamID, PlayerDeath> DeathDictionary = new Dictionary<CSteamID, PlayerDeath>(); | ||
public static IDictionary<CSteamID, Vector3> LastPosDictionary = new Dictionary<CSteamID, Vector3>(); | ||
|
||
protected override void Load() | ||
{ | ||
Instance = this; | ||
|
||
Logger.Log($"{PluginName} by {Creator} has been loaded! Version: {Version}"); | ||
UnturnedPlayerEvents.OnPlayerUpdatePosition += onPositionUpdate; | ||
UnturnedPlayerEvents.OnPlayerDeath += onPlayerDeath; | ||
UnturnedPlayerEvents.OnPlayerRevive += onPlayerRespawn; | ||
|
||
} | ||
|
||
protected override void Unload() | ||
{ | ||
Logger.Log($"{PluginName} has been unloaded"); | ||
UnturnedPlayerEvents.OnPlayerUpdatePosition -= onPositionUpdate; | ||
UnturnedPlayerEvents.OnPlayerDeath -= onPlayerDeath; | ||
UnturnedPlayerEvents.OnPlayerRevive -= onPlayerRespawn; | ||
} | ||
|
||
void FixedUpdate() | ||
{ | ||
foreach (var death in DeathDictionary.ToList()) | ||
{ | ||
if ((DateTimeOffset.Now.ToUnixTimeSeconds() - death.Value.DeathTime) > Configuration.Instance.ClearDeathAfterSeconds) | ||
{ | ||
DeathDictionary.Remove(death.Key); | ||
} | ||
} | ||
} | ||
|
||
private void onPositionUpdate(UnturnedPlayer player, Vector3 newPos) | ||
{ | ||
if (!DeathDictionary.ContainsKey(player.CSteamID)) return; | ||
|
||
if (Vector3.Distance(DeathDictionary[player.CSteamID].DeathPosition, newPos) < Configuration.Instance.RestrictedRadiusFromDeathPosition || (player.IsInVehicle && (Vector3.Distance(DeathDictionary[player.CSteamID].DeathPosition, newPos) < (Configuration.Instance.RestrictedRadiusFromDeathPosition + 5)))) | ||
{ | ||
if (player.IsInVehicle) VehicleManager.forceRemovePlayer(player.CSteamID); | ||
player.Teleport(LastPosDictionary[player.CSteamID], (player.Rotation > 180) ? player.Rotation - 180 : player.Rotation + 180); | ||
if (Configuration.Instance.MessageWhenAttemptToEnterRestrictedZone) player.sendMessage(Configuration.Instance.MessageViolation); | ||
} | ||
|
||
LastPosDictionary[player.CSteamID] = newPos; | ||
} | ||
|
||
private void onPlayerDeath(UnturnedPlayer player, EDeathCause cause, ELimb lim, CSteamID murderer) | ||
{ | ||
if (player.HasPermission("nlrenforcer.bypass")) return; | ||
|
||
if (DeathDictionary.ContainsKey(player.CSteamID)) DeathDictionary.Remove(player.CSteamID); | ||
|
||
DeathDictionary.Add(player.CSteamID, new PlayerDeath(player.CSteamID, player.Position, DateTimeOffset.Now.ToUnixTimeSeconds())); | ||
} | ||
|
||
private void onPlayerRespawn(UnturnedPlayer player, Vector3 position, byte angle) | ||
{ | ||
if (!DeathDictionary.ContainsKey(player.CSteamID)) return; | ||
|
||
if (Vector3.Distance(DeathDictionary[player.CSteamID].DeathPosition, position) < Configuration.Instance.RestrictedRadiusFromDeathPosition) DeathDictionary.Remove(player.CSteamID); | ||
} | ||
|
||
} | ||
|
||
public class PlayerDeath | ||
{ | ||
public CSteamID SteamID { get; set; } | ||
public Vector3 DeathPosition { get; set; } | ||
public long DeathTime { get; set; } | ||
|
||
public PlayerDeath(CSteamID steamid, Vector3 deathpos, long deathtime) | ||
{ | ||
SteamID = steamid; | ||
DeathPosition = deathpos; | ||
DeathTime = deathtime; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("Gaming")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("Gaming")] | ||
[assembly: AssemblyCopyright("Copyright © 2022")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("9e99bf38-30af-464a-b33a-97560ccf7d35")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
**Description:** | ||
|
||
Custom NLR rule enforcement plugin preventing players from entering zone they got killed in | ||
|
||
**Features:** | ||
|
||
- Prevents players from entering zone in which they got killed in | ||
- Ability to change radius of the kill zone | ||
- Ability to change NLR clear time | ||
- Ability to customize entry attempt message | ||
- Ability to turn off message sending on kill zone entry | ||
|
||
**Permissions:** | ||
|
||
- nlrenforcer.bypass - Permission to bypass restriction on zone entry | ||
|
||
**Configuration:** | ||
|
||
1. Plugin must be added to the server | ||
2. According to ones preference all fields can be changed | ||
3. Done | ||
|
||
Feel free to download this plugin and edit it as you please. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// <autogenerated /> | ||
using System; | ||
using System.Reflection; | ||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.6.1", FrameworkDisplayName = ".NET Framework 4.6.1")] |
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
b9a5309f338b11cdf4c6e2255e84c880955bfc3c |
Oops, something went wrong.