Иконка ресурса

FREE Jump : 0.1.0 0.1.0

Нет прав для скачивания
C#:
using UnityEngine;
using Newtonsoft.Json;
using Oxide.Core.Libraries.Covalence;

namespace Oxide.Plugins
{
    [Info("Jump", "Zeeuss", "0.1.0")]
    [Description("Jumps you to the location you are looking at")]
    public class Jump : RustPlugin
    {
        #region Init
        private const string permUse = "jump.use";
        void Init()
        {
            permission.RegisterPermission(permUse, this);
            if (!LoadConfigVariables())
            {
                return;
            }
        }
        #endregion

        #region Command
        [ChatCommand("jump")]
        void jumpCmd(BasePlayer ply, string command, string[] args)
        {
            if (!permission.UserHasPermission(ply.UserIDString, permUse))
            {
                return;
            }

            IPlayer iPly = covalence.Players.FindPlayer(ply.UserIDString);
            
            LayerMask terrainLayerMask = LayerMask.GetMask("Terrain", "World", "Tree", "Deployed", "Construction", "Vehicle Large");
            RaycastHit hit;
            if (Physics.Raycast(ply.eyes.HeadRay(), out hit, configData.MaxDistance, terrainLayerMask))
            {
                iPly.Teleport(hit.point.x, hit.point.y, hit.point.z);
            }
            else
            {
                var pos = ply.eyes.position + ply.eyes.HeadRay().direction * configData.MaxDistance;
                iPly.Teleport(pos.x, pos.y, pos.z);
            }

            // DEBUG:
            //RaycastHit[] hits = Physics.RaycastAll(ply.eyes.transform.position, ply.eyes.HeadRay().direction);
            //foreach (RaycastHit hitInfo in hits)
            //{
            //    Collider hitCollider = hitInfo.collider;
            //    GameObject hitObject = hitCollider.gameObject;
            //    int hitLayer = hitObject.layer;

            //    // Do something with the hitLayer value, e.g., print it
            //    Puts($"Hit layer: {LayerMask.LayerToName(hitLayer)}");
            //}

            //DEBUG: Puts($"{hit.collider.ToString()}\n{hit.collider.name.ToString()}");
            //DEBUG: Puts($"{hit.point.x}, {hit.point.y}, {hit.point.z}");
        }
        #endregion

        #region Config
        private ConfigData configData;
        class ConfigData
        {
            [JsonProperty(PropertyName = "Max jump distance")]
            public float MaxDistance = 300f;

        }

        private bool LoadConfigVariables()
        {
            try
            {
                configData = Config.ReadObject<ConfigData>();
            }
            catch
            {
                return false;
            }
            SaveConfig(configData);
            return true;
        }

        protected override void LoadDefaultConfig()
        {
            configData = new ConfigData();
            SaveConfig(configData);
        }

        void SaveConfig(ConfigData config)
        {
            Config.WriteObject(config, true);
        }
        #endregion

    }
}

Автор
15FPS
Скачиваний
0
Просмотры
1
Первый выпуск
Обновление
Оценка
0.00 звёзд 0 оценок
Сверху