C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography.X509Certificates;
using ConVar;
using Facepunch.Extend;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Oxide.Core;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using UnityEngine;
using Quaternion = UnityEngine.Quaternion;
using Random = UnityEngine.Random;
namespace Oxide.Plugins
{
[Info("TextPromo", "LAGZYA", "1.0.1")]
public class TextPromo : RustPlugin
{
public class ConfigData
{
[JsonProperty("Адресс магазина")] public string nameserver;
[JsonProperty("Первый промо")] public string promo1;
[JsonProperty("Второй промо")] public string promo2;
[JsonProperty("Сколько игроков получит промо")] public int count;
public static ConfigData GetNewConf()
{
ConfigData newConfig = new ConfigData();
newConfig.nameserver = "HARD-RUST.RU";
newConfig.promo1 = "wipe (15%)";
newConfig.promo2 = "global (20 rub)";
newConfig.count = 10;
return newConfig;
}
}
protected override void LoadDefaultConfig() => cfg = ConfigData.GetNewConf();
protected override void SaveConfig() => Config.WriteObject(cfg);
protected override void LoadConfig()
{
base.LoadConfig();
try
{
cfg = Config.ReadObject<ConfigData>();
}
catch
{
LoadDefaultConfig();
}
NextTick(SaveConfig);
}
private ConfigData cfg { get; set;}
public List<TextPromos> TextPromo2 = new List<TextPromos>();
[ChatCommand("givepromonote")]
void cmdgive(BasePlayer player)
{
if (player.IsAdmin)
{
GivePromo(player);
}
}
public class TextPromos
{
[JsonProperty("Ник")] public string Name { get; set; }
[JsonProperty("СтимАйди")] public ulong SteamID { get; set; }
[JsonProperty("Выдал")] public bool Vidal { get; set; }
}
void OnPlayerConnected(BasePlayer player)
{
TextPromos data = TextPromo2.Find(x => x.SteamID == player.userID);
if((player is NPCPlayer)) return;
if (TextPromo2.Count >= cfg.count)
{
return;
}
if (data == null)
{
data = new TextPromos()
{
Name = player.displayName,
SteamID = player.userID,
Vidal = false,
};
TextPromo2.Add(data);
return;
}
if (data.Vidal)
{
return;
}
if (data != null)
{
GivePromo(player);
SendReply(player, "Вы получили записку с промо!");
data.Vidal = true;
SaveData();
}
}
void OnPlayerSleepEnded(BasePlayer player)
{
OnPlayerConnected(player);
}
void GivePromo(BasePlayer player)
{
Item it = ItemManager.CreateByName("note", 1);
it.name = "PROMO";
it.skin = 1923090978;
it.text = $"{cfg.nameserver}\n\nPROMO:\n{cfg.promo1}\n{cfg.promo2}\n\n{cfg.nameserver}";
if (!player.inventory.GiveItem(it))
{
it.Drop(player.inventory.containerMain.dropPosition,
player.inventory.containerMain.dropVelocity,
new Quaternion());
}
}
void SaveData()
{
Interface.Oxide.DataFileSystem.WriteObject("TextPromoData", TextPromo2);
}
void OnServerInitialized()
{
TextPromo2 = Interface.Oxide.DataFileSystem.ReadObject<List<TextPromos>>("TextPromoData");
}
}
}