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

FREE WEco : 0.0.1 0.0.1

Нет прав для скачивания
C#:
using Newtonsoft.Json;
using Oxide.Core;
using Oxide.Core.Configuration;
using Oxide.Core.Database;
using Oxide.Core.Libraries.Covalence;
using Oxide.Core.Plugins;
using System;
using System.Collections.Generic;
using System.Linq;
using Oxide.Core.SQLite.Libraries;
using System.Text.RegularExpressions;
using UnityEngine;
using Oxide.Game.Rust.Cui;
using System.Collections;
using Newtonsoft.Json.Linq;
using CompanionServer.Handlers;

namespace Oxide.Plugins
{
	[Info("Gold Silver", "WOLF#4002", "0.0.1")]
    class WEco : RustPlugin
	{
		void OnServerInitialized()
		{
			if (Interface.Oxide.DataFileSystem.ExistsDatafile($"{Name}/{Title}"))
                DB = Oxide.Core.Interface.Oxide.DataFileSystem.ReadObject<Dictionary<ulong, PlayerEco>>($"{Name}/{Title}");
			foreach (BasePlayer player in BasePlayer.activePlayerList)
            {
				OnPlayerConnected(player);
			}
			timer.Every(60f, PlayTime);
		}
		void OnPlayerConnected(BasePlayer player)
		{
			if (!DB.ContainsKey(player.userID))
			{
				PlayerEco NewUser = new PlayerEco()
                {
                    DisplayName = player.displayName,
					SteamID = player.userID,
                    Gold = 0,
					Silver = 0, 
                };
				DB.Add(player.userID, NewUser);
				OnServerSave();
			} 
		}
		void OnServerSave()
        {
            Oxide.Core.Interface.Oxide.DataFileSystem.WriteObject($"{Name}/{Title}", DB);
		}
		private Dictionary<ulong, PlayerEco> DB = new Dictionary<ulong, PlayerEco>();
		private class PlayerEco
        {
			[JsonProperty("Name")]
            public string DisplayName;
			[JsonProperty("SteamID")]
            public ulong SteamID;
            [JsonProperty("Gold")]
            public int Gold;
			[JsonProperty("Silver")]
            public int Silver;
		}
		
		void ADDGold(BasePlayer player, int amount)
		{
			var data = DB[player.userID];
            data.Gold += amount;
            OnServerSave();			
		}
		void TAKEGold(BasePlayer player, int amount)
		{
			var data = DB[player.userID];
			data.Gold -= amount;
            OnServerSave();
		}
		int FINDGold(BasePlayer player)
		{
			var data = DB[player.userID];
			return data.Gold; 
		}
		
		
		void ADDSilver(BasePlayer player, int amount)
		{
			var data = DB[player.userID];
			data.Silver += amount;
            OnServerSave();
		}
		void TAKESilver(BasePlayer player, int amount)
		{
			var data = DB[player.userID];
			data.Silver -= amount;
			OnServerSave();
		}
		int FINDSilver(BasePlayer player)
		{
			var data = DB[player.userID];
			return data.Silver; 
		}
		
		
		private void PlayTime()
        {
            foreach (var player in BasePlayer.activePlayerList)
			{
                DB[player.userID].Silver += 1;
				player.SendConsoleCommand($"note.inv 605467368 1 \"<color=#C0C0C0FF>Silver</color>\"");
				player.BroadcastEntityMessage("fdghjklkjhg");

            }
			OnServerSave();
            



        }
		
		void OnPlayerDeath(BasePlayer player, HitInfo info)
        {
            if (info == null || player == null || player.IsNpc || info.InitiatorPlayer == null || info.InitiatorPlayer.IsNpc) return;
            
            if (info.InitiatorPlayer != null)
            {
                var killer = info.InitiatorPlayer;
                DB[killer.userID].Silver += 10;
				player.SendConsoleCommand($"note.inv 605467368 20 \"<color=#C0C0C0FF>Silver</color>\"");
            }
        }
		
		public ulong lastDamageName;
        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
            if (entity is BradleyAPC && info.Initiator is BasePlayer)
                lastDamageName = info.Initiator.ToPlayer().userID;
            if (entity is BaseHelicopter && info.Initiator is BasePlayer)
                lastDamageName = info.Initiator.ToPlayer().userID;
        }

        void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
            if (entity == null || info == null) return;
            BasePlayer player = null;

            if (info.InitiatorPlayer != null) 
                player = info.InitiatorPlayer;

            if (player == null) return;
            
            if (entity is BradleyAPC)
            { 
                player = BasePlayer.FindByID(lastDamageName);
                DB[player.userID].Gold += 1;
				player.SendConsoleCommand($"note.inv 605467368 1 \"<color=#FF8000FF>Gold</color>\"");
            }

            if (entity is BaseHelicopter) 
            { 
                player = BasePlayer.FindByID(lastDamageName);
                DB[player.userID].Gold += 2;
				player.SendConsoleCommand($"note.inv 605467368 2 \"<color=#FF8000FF>Gold</color>\"");
            }

            if (entity.ShortPrefabName.Contains("barrel"))
            {
				DB[player.userID].Silver += 1;
				player.SendConsoleCommand($"note.inv 605467368 1 \"<color=#C0C0C0FF>Silver</color>\"");
            }
			
        }
		
		
		
		
		
	}
}

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