Skip to content

Commit

Permalink
Fixed flight speed hotkeys triggering multiple times on key hold
Browse files Browse the repository at this point in the history
  • Loading branch information
ShimmyMySherbet committed Sep 14, 2020
1 parent 8845885 commit 592d8ba
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions ShimmysAdminTools/Behaviors/FlightSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using SDG.Unturned;
using ShimmysAdminTools.Components;
using ShimmysAdminTools.Models;
using ShimmysAdminTools.Modules;
using UnityEngine;

namespace ShimmysAdminTools.Behaviors
Expand Down Expand Up @@ -84,28 +83,35 @@ private void OnKeyStateChanged(UnturnedKey Key, bool State)
}
else if (Key == UnturnedKey.CodeHotkey1)
{
if (Helpers.PlayerCanFlyAtSpeed(UPlayer, Speed - 1))
{
Speed -= 1;
Player.movement.sendPluginSpeedMultiplier(Speed);
}
else
if (State)
{
UnturnedChat.Say(UPlayer, "Flight_Speed_Denied_Hotkey".Translate());
if (Helpers.PlayerCanFlyAtSpeed(UPlayer, Speed - 1))
{
Speed -= 1;
Player.movement.sendPluginSpeedMultiplier(Speed);
}
else
{
UnturnedChat.Say(UPlayer, "Flight_Speed_Denied_Hotkey".Translate());
}
}
}
else if (Key == UnturnedKey.CodeHotkey2)
{
if (Helpers.PlayerCanFlyAtSpeed(UPlayer, Speed + 1))
{
Speed += 1;
Player.movement.sendPluginSpeedMultiplier(Speed);
}
else
if (State)
{
UnturnedChat.Say(UPlayer, "Flight_Speed_Denied_Hotkey".Translate());
if (Helpers.PlayerCanFlyAtSpeed(UPlayer, Speed + 1))
{
Speed += 1;
Player.movement.sendPluginSpeedMultiplier(Speed);
}
else
{
UnturnedChat.Say(UPlayer, "Flight_Speed_Denied_Hotkey".Translate());
}
}
} else if (Key == UnturnedKey.CodeHotkey3)
}
else if (Key == UnturnedKey.CodeHotkey3)
{
if (State)
{
Expand Down Expand Up @@ -187,6 +193,5 @@ public void OnDestroy()
{
Stop();
}

}
}

0 comments on commit 592d8ba

Please sign in to comment.