Esempio n. 1
0
 protected override void Unload()
 {
     PlayerInput.onPluginKeyTick -= KeyDown;
     InFly.Clear();
     Cooldowns.Clear();
     try
     {
         UnturnedPlayer p  = UnturnedPlayer.FromPlayer(Player.player);
         TFlyComponent  cp = p.GetComponent <TFlyComponent>();
         if (cp.isFlying)
         {
             FlyMode(p, false);
         }
     } catch { }
     Logger.Log("TFly is successfully unloaded!", color: ConsoleColor.Green);
 }
Esempio n. 2
0
        public void KeyDown(Player player, uint simulation, byte key, bool state)
        {
            UnturnedPlayer p  = UnturnedPlayer.FromPlayer(player);
            TFlyComponent  cp = p.GetComponent <TFlyComponent>();

            if (cp.isFlying)
            {
                if (key == 0 && state)
                {
                    if (cp.FlySpeed == 0)
                    {
                        cp.FlySpeed = Configuration.Instance.DefaultSpeedInFly;
                    }
                    cp.FlySpeed = cp.FlySpeed + 1;
                    p.Player.movement.sendPluginGravityMultiplier(Configuration.Instance.Gravity);
                    p.Player.movement.sendPluginSpeedMultiplier(cp.FlySpeed);

                    if (Configuration.Instance.GodModeWhenFlyEnabled)
                    {
                        p.GodMode = true;
                    }

                    if (Configuration.Instance.FlyAnimationEnabled)
                    {
                        p.Player.stance.channel.send("tellStance", ESteamCall.OWNER, ESteamPacket.UPDATE_UNRELIABLE_BUFFER, new object[]
                        {
                            (byte)EPlayerStance.SWIM
                        });
                    }

                    if (Configuration.Instance.UIEnabled)
                    {
                        EffectManager.sendUIEffect(Configuration.Instance.UIId, 8731, p.CSteamID, true, Translate("Your_Flying_Speed", cp.FlySpeed.ToString()));
                    }
                }
                if (key == 1 && state)
                {
                    if (cp.FlySpeed - 1 > 1)
                    {
                        if (cp.FlySpeed == 0)
                        {
                            cp.FlySpeed = Configuration.Instance.DefaultSpeedInFly;
                        }
                        cp.FlySpeed = cp.FlySpeed - 1;
                        p.Player.movement.sendPluginGravityMultiplier(Configuration.Instance.Gravity);
                        p.Player.movement.sendPluginSpeedMultiplier(cp.FlySpeed);

                        if (Configuration.Instance.GodModeWhenFlyEnabled)
                        {
                            p.GodMode = true;
                        }

                        if (Configuration.Instance.FlyAnimationEnabled)
                        {
                            p.Player.stance.channel.send("tellStance", ESteamCall.OWNER, ESteamPacket.UPDATE_UNRELIABLE_BUFFER, new object[]
                            {
                                (byte)EPlayerStance.SWIM
                            });
                        }

                        if (Configuration.Instance.UIEnabled)
                        {
                            EffectManager.sendUIEffect(Configuration.Instance.UIId, 8731, p.CSteamID, true, Translate("Your_Flying_Speed", cp.FlySpeed.ToString()));
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public void FlyMode(UnturnedPlayer player, bool enabled)
        {
            TFlyComponent cp = player.GetComponent <TFlyComponent>();

            float flyspeed = Configuration.Instance.DefaultSpeedInFly;

            if (cp.FlySpeed != 0)
            {
                flyspeed = cp.FlySpeed;
            }

            if (cp.isFlying && !enabled)
            {
                cp.isFlying = false;
                InFly.Remove(player.CSteamID);
                player.Player.movement.sendPluginGravityMultiplier(1f);
                player.Player.movement.sendPluginSpeedMultiplier(1f);

                if (Configuration.Instance.GodModeWhenFlyEnabled)
                {
                    player.GodMode = false;
                }

                if (Configuration.Instance.FlyAnimationEnabled)
                {
                    player.Player.stance.channel.send("tellStance", ESteamCall.OWNER, ESteamPacket.UPDATE_UNRELIABLE_BUFFER, new object[]
                    {
                        (byte)EPlayerStance.STAND
                    });
                }
                if (Configuration.Instance.UIEnabled)
                {
                    EffectManager.askEffectClearByID(Configuration.Instance.UIId, player.CSteamID);
                }
                UnturnedChat.Say(player, Translate("Fly_Stop"));
            }
            else if (!cp.isFlying && enabled)
            {
                cp.isFlying = true;
                InFly.Add(player.CSteamID);
                player.Player.movement.sendPluginGravityMultiplier(Configuration.Instance.Gravity);
                player.Player.movement.sendPluginSpeedMultiplier(flyspeed);

                if (Configuration.Instance.GodModeWhenFlyEnabled)
                {
                    player.GodMode = true;
                }

                if (Configuration.Instance.FlyAnimationEnabled)
                {
                    player.Player.stance.channel.send("tellStance", ESteamCall.OWNER, ESteamPacket.UPDATE_UNRELIABLE_BUFFER, new object[]
                    {
                        (byte)EPlayerStance.SWIM
                    });
                }
                if (Configuration.Instance.UIEnabled)
                {
                    EffectManager.sendUIEffect(Configuration.Instance.UIId, 8731, player.CSteamID, true, Translate("Your_Flying_Speed", cp.FlySpeed.ToString()));
                }
                UnturnedChat.Say(player, Translate("Fly_Start"));
            }
        }
Esempio n. 4
0
        public void Execute(IRocketPlayer caller, string[] args)
        {
            UnturnedPlayer player = (UnturnedPlayer)caller;
            var            main   = TFly.Instance;
            var            config = main.Configuration.Instance;

            if (main.Cooldowns.TryGetValue(player.CSteamID, out DateTime now) && now != null)
            {
                if (DateTime.Now > now)
                {
                    main.Cooldowns.Remove(player.CSteamID);
                }
                else
                {
                    UnturnedChat.Say(caller, main.Translate("Cooldown", Convert.ToInt32((now - DateTime.Now).TotalSeconds).ToString()));
                    return;
                }
            }

            if (args.Length == 1)
            {
                if (args[0].ToLower() == "all" && player.HasPermission(config.PermissionAdmin))
                {
                    foreach (SteamPlayer sp in Provider.clients)
                    {
                        UnturnedPlayer target = UnturnedPlayer.FromSteamPlayer(sp);
                        TFlyComponent  cp     = target.GetComponent <TFlyComponent>();
                        if (cp.isFlying)
                        {
                            cp.FlySpeed = config.DefaultSpeedInFly;
                            main.FlyMode(target, false);
                        }
                        else if (!cp.isFlying)
                        {
                            cp.FlySpeed = config.DefaultSpeedInFly;
                            main.FlyMode(target, true);
                        }
                    }
                    UnturnedChat.Say(caller, main.Translate("Fly_changed_all"));
                }
                else if (args[0].ToLower() != "all" && player.HasPermission(config.PermissionAdmin))
                {
                    UnturnedPlayer target = UnturnedPlayer.FromName(args[0]);
                    if (target == null)
                    {
                        UnturnedChat.Say(caller, main.Translate("Player_Not_Found", args[0].ToString()));
                        return;
                    }
                    else
                    {
                        TFlyComponent cp = target.GetComponent <TFlyComponent>();
                        if (cp.isFlying)
                        {
                            cp.FlySpeed = config.DefaultSpeedInFly;
                            main.FlyMode(target, false);
                            main.Cooldowns.Add(player.CSteamID, DateTime.Now.AddSeconds(config.CooldownInSeconds));
                        }
                        else if (!cp.isFlying)
                        {
                            cp.FlySpeed = config.DefaultSpeedInFly;
                            main.FlyMode(target, true);
                            main.Cooldowns.Add(player.CSteamID, DateTime.Now.AddSeconds(config.CooldownInSeconds));
                        }
                    }
                }
            }
            else if (args.Length == 0)
            {
                TFlyComponent cp = player.GetComponent <TFlyComponent>();

                if (cp.isFlying)
                {
                    cp.FlySpeed = config.DefaultSpeedInFly;
                    main.FlyMode(player, false);
                    main.Cooldowns.Add(player.CSteamID, DateTime.Now.AddSeconds(config.CooldownInSeconds));
                }
                else if (!cp.isFlying)
                {
                    cp.FlySpeed = config.DefaultSpeedInFly;
                    main.FlyMode(player, true);
                    main.Cooldowns.Add(player.CSteamID, DateTime.Now.AddSeconds(config.CooldownInSeconds));
                }
            }
            else
            {
                UnturnedChat.Say(caller, main.Translate("Fly_Usage" + Syntax));
                return;
            }
        }