Skip to content

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
KSean12 committed Oct 18, 2016
1 parent d24b01a commit 5402929
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 8 deletions.
Binary file modified .vs/DeathManager/v14/.suo
Binary file not shown.
4 changes: 4 additions & 0 deletions DeathManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,17 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="Uconomy">
<HintPath>..\..\Uconomy_15\Uconomy.dll</HintPath>
</Reference>
<Reference Include="UnityEngine">
<HintPath>lib\UnityEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="DeathManager\Configuration.cs" />
<Compile Include="DeathManager\Plugin.cs" />
<Compile Include="DeathManager\DeathNote.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
8 changes: 6 additions & 2 deletions DeathManager/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ public class Configuration : IRocketPluginConfiguration
public bool Enabled;
public bool Debug;
public string DeathMessagesColor;
public bool ShowSuicideMessages;
public bool ShowHeadshotMessages;
public bool ShowSuicideMessages, ShowHeadshotMessages, EffectOnDeath, BackEnabled;
public decimal KillerReward, EffectOnDeathId;
public double TimeLimit;

public void LoadDefaults()
{
Expand All @@ -17,6 +18,9 @@ public void LoadDefaults()
ShowSuicideMessages = true;
ShowHeadshotMessages = true;
DeathMessagesColor = "Red";
EffectOnDeath = true;
EffectOnDeathId = 45;
KillerReward = 500;
}
}
}
15 changes: 15 additions & 0 deletions DeathManager/DeathNote.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using UnityEngine;

namespace DeathManager
{
internal class DeathNote
{
public DeathNote()
{
}

public Vector3 Position { get; set; }
public DateTime TimeOfDeath { get; set; }
}
}
71 changes: 65 additions & 6 deletions DeathManager/Plugin.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using Rocket.API.Collections;
using fr34kyn01535.Uconomy;
using Rocket.API;
using Rocket.API.Collections;
using Rocket.Core.Commands;
using Rocket.Core.Logging;
using Rocket.Core.Plugins;
using Rocket.Unturned.Chat;
Expand All @@ -7,6 +10,7 @@
using SDG.Unturned;
using Steamworks;
using System;
using System.Collections.Generic;
using UnityEngine;

namespace DeathManager
Expand All @@ -15,13 +19,16 @@ public class DeathManager : RocketPlugin<Configuration>
{
public static UnturnedPlayer killer;
public static DeathManager Instance;
private IDictionary<string, DeathNote> deathNotes;


protected override void Load()
{
Instance = this;

if (Instance.Configuration.Instance.Enabled)
{
deathNotes = new Dictionary<string, DeathNote>();
UnturnedPlayerEvents.OnPlayerDeath += UnturnedPlayerEvents_OnPlayerDeath;

Logger.Log("[DeathManager] The Plugin Has Been loaded!");
Expand Down Expand Up @@ -69,14 +76,18 @@ public override TranslationList DefaultTranslations
}
}




private void UnturnedPlayerEvents_OnPlayerDeath(UnturnedPlayer player, EDeathCause cause, ELimb limb, CSteamID murderer)
private void UnturnedPlayerEvents_OnPlayerDeath(UnturnedPlayer player, EDeathCause cause, ELimb limb, CSteamID murderer )
{
deathNotes[player.SteamName] = new DeathNote() { Position = player.Position, TimeOfDeath = DateTime.Now };
killer = UnturnedPlayer.FromCSteamID(murderer);
string death = cause.ToString();
string headshot = string.Empty;
string Received = Configuration.Instance.KillerReward + Uconomy.Instance.Configuration.Instance.MoneyName;
string TotalMoney = Uconomy.Instance.Database.IncreaseBalance(killer.Id, Configuration.Instance.KillerReward) + Uconomy.Instance.Configuration.Instance.MoneyName;
if (Instance.Configuration.Instance.EffectOnDeath)
{
EffectManager.sendEffect((ushort)Instance.Configuration.Instance.EffectOnDeathId, 30, player.Position);
}
if (Instance.Configuration.Instance.ShowHeadshotMessages)
{
headshot = Instance.Translations.Instance.Translate("headshot");
Expand All @@ -85,6 +96,7 @@ private void UnturnedPlayerEvents_OnPlayerDeath(UnturnedPlayer player, EDeathCau
{
switch (death)
{

case "BLEEDING":
UnturnedChat.Say(Translate("bleeding", player.DisplayName), UnturnedChat.GetColorFromName(Configuration.Instance.DeathMessagesColor, Color.green));
break;
Expand Down Expand Up @@ -161,8 +173,11 @@ private void UnturnedPlayerEvents_OnPlayerDeath(UnturnedPlayer player, EDeathCau
default:
UnturnedChat.Say(Translate("null", player.DisplayName), UnturnedChat.GetColorFromName(Configuration.Instance.DeathMessagesColor, Color.green));
break;


}
}

catch (Exception exc)
{
if (Instance.Configuration.Instance.Debug)
Expand All @@ -172,6 +187,50 @@ private void UnturnedPlayerEvents_OnPlayerDeath(UnturnedPlayer player, EDeathCau
}
}
}
internal void TrySendBack(UnturnedPlayer player )
{
if (!Configuration.Instance.BackEnabled)
return;

if (deathNotes.ContainsKey(player.SteamName))
{
DeathNote deathNote = deathNotes[player.SteamName];

if (DateTime.Now <= deathNote.TimeOfDeath.AddSeconds(Configuration.Instance.TimeLimit))
{
// Teleporting the player back.
player.Teleport(deathNote.Position, player.Rotation);

// Saying hello to the dead :)
UnturnedChat.Say(player, "Back !");
}
else
UnturnedChat.Say(player, "too slow, have a nice walk. ");

// Removing the reference, we dont want a smart player using our plugin as fast travel.
deathNotes.Remove(player.SteamName);
}
else
{
// Cant find the poor guy =/
UnturnedChat.Say(player, "You have to die first !");
}
}
[RocketCommand("back", "Back To Death Location", "", AllowedCaller.Both)]

public void Execute(UnturnedPlayer caller , string[] command)
{
if (command.Length == 0)
{
if (caller is ConsolePlayer)
{
Logger.Log("Admin , Your trying to execute the command from console , Back : to your fucking server!");
return;
}
if (caller != null )
TrySendBack(caller);
}
}
}

}
}
Binary file modified bin/Debug/DeathManager.dll
Binary file not shown.
Binary file modified bin/Debug/DeathManager.pdb
Binary file not shown.
Binary file added bin/Debug/Uconomy.dll
Binary file not shown.
12 changes: 12 additions & 0 deletions obj/Debug/DeathManager.csproj.FileListAbsolute.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,15 @@ C:\Users\gost\Documents\GitHub\DeathManager\bin\Debug\UnityEngine.dll
C:\Users\gost\Documents\GitHub\DeathManager\obj\Debug\DeathManager.csprojResolveAssemblyReference.cache
C:\Users\gost\Documents\GitHub\DeathManager\obj\Debug\DeathManager.dll
C:\Users\gost\Documents\GitHub\DeathManager\obj\Debug\DeathManager.pdb
C:\Users\User\Desktop\DeathManager-master\DeathManager-master\bin\Debug\DeathManager.dll
C:\Users\User\Desktop\DeathManager-master\DeathManager-master\bin\Debug\DeathManager.pdb
C:\Users\User\Desktop\DeathManager-master\DeathManager-master\bin\Debug\Assembly-CSharp-firstpass.dll
C:\Users\User\Desktop\DeathManager-master\DeathManager-master\bin\Debug\Assembly-CSharp.dll
C:\Users\User\Desktop\DeathManager-master\DeathManager-master\bin\Debug\Rocket.API.dll
C:\Users\User\Desktop\DeathManager-master\DeathManager-master\bin\Debug\Rocket.Core.dll
C:\Users\User\Desktop\DeathManager-master\DeathManager-master\bin\Debug\Rocket.Unturned.dll
C:\Users\User\Desktop\DeathManager-master\DeathManager-master\bin\Debug\Uconomy.dll
C:\Users\User\Desktop\DeathManager-master\DeathManager-master\bin\Debug\UnityEngine.dll
C:\Users\User\Desktop\DeathManager-master\DeathManager-master\obj\Debug\DeathManager.csprojResolveAssemblyReference.cache
C:\Users\User\Desktop\DeathManager-master\DeathManager-master\obj\Debug\DeathManager.dll
C:\Users\User\Desktop\DeathManager-master\DeathManager-master\obj\Debug\DeathManager.pdb
Binary file modified obj/Debug/DeathManager.csprojResolveAssemblyReference.cache
Binary file not shown.
Binary file modified obj/Debug/DeathManager.dll
Binary file not shown.
Binary file modified obj/Debug/DeathManager.pdb
Binary file not shown.
Binary file modified obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Binary file not shown.

0 comments on commit 5402929

Please sign in to comment.