-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
b942cd6
commit 72806c8
Showing
12 changed files
with
316 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 15 | ||
VisualStudioVersion = 15.0.26730.16 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SuperBroadcaster", "SuperBroadcaster\SuperBroadcaster.csproj", "{5387ED54-9EBD-4BC6-9FA0-FB6C7F1083EC}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{5387ED54-9EBD-4BC6-9FA0-FB6C7F1083EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{5387ED54-9EBD-4BC6-9FA0-FB6C7F1083EC}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{5387ED54-9EBD-4BC6-9FA0-FB6C7F1083EC}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{5387ED54-9EBD-4BC6-9FA0-FB6C7F1083EC}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {607E517A-901E-408B-A201-81E1E81324EC} | ||
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,69 @@ | ||
using System.Collections.Generic; | ||
using Rocket.API; | ||
using Rocket.Unturned.Chat; | ||
using Rocket.Unturned.Player; | ||
using Steamworks; | ||
using UnityEngine; | ||
using SDG.Unturned; | ||
using System; | ||
|
||
namespace ExtraConcentratedJuice.SuperBroadcaster | ||
{ | ||
public class CommandSuperBroadcast : IRocketCommand | ||
{ | ||
#region Properties | ||
|
||
public AllowedCaller AllowedCaller => AllowedCaller.Player; | ||
|
||
public string Name => "superbroadcast"; | ||
|
||
public string Help => "Broadcasts via a UI effect."; | ||
|
||
public string Syntax => "/superbroadcast \"your text here\" <time>"; | ||
|
||
public List<string> Aliases => new List<string> { "sbroadcast", "sb" }; | ||
|
||
public List<string> Permissions => new List<string> { "superbroadcast.broadcast" }; | ||
|
||
#endregion | ||
|
||
public void Execute(IRocketPlayer caller, string[] args) | ||
{ | ||
if (args.Length < 1 || args.Length > 2) | ||
{ | ||
UnturnedChat.Say(caller, Syntax, Color.red); | ||
return; | ||
} | ||
|
||
if (SuperBroadcaster.instance.isActive) | ||
{ | ||
UnturnedChat.Say(caller, SuperBroadcaster.instance.Translate("is_active"), Color.red); | ||
return; | ||
} | ||
|
||
if (args.Length == 1) | ||
{ | ||
SuperBroadcaster.instance.StartBroadcast(SuperBroadcaster.instance.Configuration.Instance.defaultBroadcastDuration, args[0]); | ||
} | ||
|
||
if (args.Length == 2) | ||
{ | ||
if (!float.TryParse(args[1], out float time)) | ||
{ | ||
UnturnedChat.Say(caller, Syntax, Color.red); | ||
return; | ||
} | ||
float limit = SuperBroadcaster.instance.Configuration.Instance.broadcastTimeLimit; | ||
|
||
if (limit > 0 && time > limit) | ||
{ | ||
UnturnedChat.Say(caller, SuperBroadcaster.instance.Translate("too_long"), Color.red); | ||
return; | ||
} | ||
|
||
UnturnedChat.Say(caller, SuperBroadcaster.instance.Translate("success")); | ||
SuperBroadcaster.instance.StartBroadcast(time, args[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,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("SuperBroadcaster")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("Microsoft")] | ||
[assembly: AssemblyProduct("SuperBroadcaster")] | ||
[assembly: AssemblyCopyright("Copyright © Microsoft 2018")] | ||
[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("5387ed54-9ebd-4bc6-9fa0-fb6c7f1083ec")] | ||
|
||
// 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,90 @@ | ||
using Rocket.Core.Plugins; | ||
using System; | ||
using System.Collections; | ||
using System.Linq; | ||
using System.Text; | ||
using UnityEngine; | ||
using SDG.Unturned; | ||
using Rocket.API.Collections; | ||
|
||
namespace ExtraConcentratedJuice.SuperBroadcaster | ||
{ | ||
public class SuperBroadcaster : RocketPlugin<SuperBroadcasterConfiguration> | ||
{ | ||
public static SuperBroadcaster instance; | ||
public bool isActive; | ||
private int broadcastIndex; | ||
|
||
protected override void Load() | ||
{ | ||
instance = this; | ||
isActive = false; | ||
broadcastIndex = 0; | ||
|
||
if (Configuration.Instance.repeatingBroadcastInterval > 0) | ||
StartCoroutine(BroadcastCoroutine(Configuration.Instance.repeatingBroadcastInterval)); | ||
} | ||
|
||
protected override void Unload() | ||
{ | ||
StopAllCoroutines(); | ||
|
||
foreach(SteamPlayer x in Provider.clients) | ||
if (x != null) | ||
EffectManager.askEffectClearByID(Configuration.Instance.effectId, x.playerID.steamID); | ||
|
||
isActive = false; | ||
} | ||
|
||
private IEnumerator BroadcastCoroutine(float time) | ||
{ | ||
while (true) | ||
{ | ||
yield return new WaitForSeconds(time); | ||
|
||
if (isActive) | ||
yield return new WaitForSeconds(time); | ||
|
||
string message = Configuration.Instance.broadcastMessages[broadcastIndex]; | ||
|
||
StartBroadcast(Configuration.Instance.repeatingBroadcastStayTime, message); | ||
|
||
if (++broadcastIndex >= Configuration.Instance.broadcastMessages.Count) | ||
broadcastIndex = 0; | ||
} | ||
} | ||
|
||
public void StartBroadcast(float time, string message) | ||
{ | ||
foreach (SteamPlayer x in Provider.clients) | ||
if (x != null) | ||
EffectManager.sendUIEffect(Configuration.Instance.effectId, 4205, x.playerID.steamID, true, message); | ||
|
||
isActive = true; | ||
|
||
StartCoroutine(DelayedInvoke(time, () => | ||
{ | ||
foreach (SteamPlayer x in Provider.clients) | ||
if (x != null) | ||
EffectManager.askEffectClearByID(Configuration.Instance.effectId, x.playerID.steamID); | ||
|
||
isActive = false; | ||
})); | ||
} | ||
|
||
private IEnumerator DelayedInvoke(float time, System.Action action) | ||
{ | ||
yield return new WaitForSeconds(time); | ||
action(); | ||
} | ||
|
||
public override TranslationList DefaultTranslations => | ||
new TranslationList | ||
{ | ||
{ "is_active", "There is an active broadcast. Please wait for it to end before creating another one." }, | ||
{ "broadcast_sent", "You have successfully sent your broadcast!" }, | ||
{ "too_long", "The duration that you specified on your broadcast is above this server's max broadcast time limit." }, | ||
{ "success", "You have successfully created a superbroadcast." } | ||
}; | ||
} | ||
} |
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 @@ | ||
<?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>{5387ED54-9EBD-4BC6-9FA0-FB6C7F1083EC}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>ExtraConcentratedJuice.SuperBroadcaster</RootNamespace> | ||
<AssemblyName>SuperBroadcaster</AssemblyName> | ||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</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>..\Libraries\Assembly-CSharp.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Assembly-CSharp-firstpass"> | ||
<HintPath>..\Libraries\Assembly-CSharp-firstpass.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Rocket.API"> | ||
<HintPath>..\Libraries\Rocket.API.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Rocket.Core"> | ||
<HintPath>..\Libraries\Rocket.Core.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Rocket.Unturned"> | ||
<HintPath>..\Libraries\Rocket.Unturned.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="UnityEngine"> | ||
<HintPath>..\Libraries\UnityEngine.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="CommandSuperBroadcast.cs" /> | ||
<Compile Include="SuperBroadcaster.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="SuperBroadcasterConfiguration.cs" /> | ||
</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,31 @@ | ||
using Rocket.API; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Xml.Serialization; | ||
|
||
namespace ExtraConcentratedJuice.SuperBroadcaster | ||
{ | ||
public class SuperBroadcasterConfiguration : IRocketPluginConfiguration | ||
{ | ||
public int defaultBroadcastDuration; | ||
public int broadcastTimeLimit; | ||
public ushort effectId; | ||
public float repeatingBroadcastInterval; | ||
public float repeatingBroadcastStayTime; | ||
|
||
[XmlArray(ElementName = "message")] | ||
public List<string> broadcastMessages; | ||
|
||
public void LoadDefaults() | ||
{ | ||
effectId = 42069; | ||
defaultBroadcastDuration = 5; | ||
broadcastTimeLimit = 25; | ||
repeatingBroadcastInterval = 300; | ||
repeatingBroadcastStayTime = 6; | ||
broadcastMessages = new List<string> { "SupahBroadcasto!!!!", "This is a SUPER broadcast!", "set repeatingBroadcastInterval to -1 to disable this!"}; | ||
} | ||
} | ||
} |