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

FREE Scopes : 1.3.2 1.3.2

Нет прав для скачивания
C#:
using System;
using Oxide.Game.Rust.Cui;
using UnityEngine;

namespace Oxide.Plugins
{
	[Info("Scopes", "MikeHawke", "1.3.2")]
	[Description("On screen crosshairs")]
	class Scopes : RustPlugin
	{
		void Destroy(BasePlayer player, bool all)
		{
			CuiHelper.DestroyUi(player, "ScopesUI");
		}
		void Unload() 
		{
			foreach (BasePlayer current in BasePlayer.activePlayerList)   
			{
				CuiHelper.DestroyUi(current, "ScopesUI");
			}
		}
		private void OnPlayerDisconnected(BasePlayer player)
		{
			Destroy(player, true); 
		}
		void ScopesUI(BasePlayer player, int scope)
		{
			var elements = new CuiElementContainer();

			var mainName = elements.Add(new CuiPanel
			{
				Image =
				{
					Color = "0 0 0 0"
				},
				RectTransform =
				{
					AnchorMin = "0.47 0.47",
					AnchorMax = "0.53 0.53"
				},
				CursorEnabled = false
			}, "Overlay", "ScopesUI");
			elements.Add(new CuiLabel
			{
				Text =
				{
					Text = configData.symbols[scope],
					Color = configData.Colour,
					FontSize = 24,
					Align = TextAnchor.MiddleCenter
				},
				RectTransform =
				{
					AnchorMin = "0 0",
					AnchorMax = "1 1"
				}
			}, mainName);
			CuiHelper.AddUi(player, elements);
		}
		[ChatCommand("scope")]
		void HelpToScreen(BasePlayer player, string cmd, string[] args)
		{
			if (args == null)
				return;
			if (!permission.UserHasPermission(player.userID.ToString(), "Scopes.Toggle"))
			{
				SendReply(player, "You do not have permission to use this command!");
				return;
			}

			if (args.Length == 0)
			{
				string info = $"Use one of the following commands:\n/Scope 1,\n/Scope 2,\n/Scope 3,\n/Scope 4,\n/Scope 5,\n/Scope 6,\n/NoScope to remove Scopes";
				SendReply(player, info);
				return;
			}
			int scope = -1;
			if (!int.TryParse(args[0], out scope))
				return;
			scope--;//make 1 0, 2 1, etc for array indexing.
			if (scope < 0)
			{
				string info = $"Usage - /scope <number> : 1-{configData.symbols.Length}.";
				SendReply(player, info);
				return;
			}
			if (configData.symbols.Length <= scope)
			{
				string info = $"There are only {configData.symbols.Length} available scopes.";
				SendReply(player, info);
				return;
			}
			Destroy(player, true);
			ScopesUI(player, scope);
			SendReply(player, $"Scope {scope+1} Active");
		}
		[ChatCommand("NoScope")]
		void RemoveScope(BasePlayer player, string cmd, string[] args)
            {
				Destroy(player, true);
				SendReply(player, "Scopes Deactivated");
				
			}

		#region Config
		void Init()
		{
			if (!LoadConfigVariables())
			{
				Puts("Config file issue detected. Please delete file, or check syntax and fix.");
				return;
			}
			permission.RegisterPermission("Scopes.Toggle", this);
		}
		private ConfigData configData;

		public class ConfigData
		{
			public String[] symbols = { "「」", "+", "◎", "◬", "・", "Ⓧ" };
			public string Colour = "1 0 0 1";
		}

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

		protected override void LoadDefaultConfig()
		{
			Puts("Creating new config file.");
			var config = new ConfigData();
			SaveConfig(config);
		}

		void SaveConfig(ConfigData config) => Config.WriteObject(config, true);
		#endregion

	}
}

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