C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
using Oxide.Core;
using System;
using System.Collections.Generic;
using Oxide.Core.Plugins;
using Oxide.Core.Libraries.Covalence;
using Rust;
using UnityEngine;
using Newtonsoft.Json;
using System.Linq;
/*========================================================*
* *
* *************************************************** *
* *Original author : Slydelix on versions <1.8.5 * *
* *Maintainer(s) : RustySpoon342 from v1.8.6 * *
* *************************************************** *
* *
* Patch Submissions : Nivex on versions 1.8.9, 1.9.0 *
* *
*=========================================================*/
namespace Oxide.Plugins {
[Info("AntiNoobRaid", "MasterSplinter", "2.1.1", ResourceId = 2697)]
class AntiNoobRaid : RustPlugin {
[PluginReference]
private Plugin PlaytimeTracker, WipeProtection, Clans, StartProtection;
//Pre-release Version Number
private bool beta = false;
private string betaversion = "0.0.6";
private List<BasePlayer> cooldown = new List<BasePlayer>();
private List<BasePlayer> MessageCooldown = new List<BasePlayer>();
private List<ulong> LeaderLower = new List<ulong>();
private List<BuildingBlock> _blocks = new List<BuildingBlock>();
private Timer CheckingPT;
private Timer CheckingC;
//private Dictionary<ulong, Timer> RaidTimerDictionary = new Dictionary<ulong, Timer>();
private Dictionary<string, string> raidtools = new Dictionary<string, string> {
{
"ammo.rocket.fire", "rocket_fire"
}
, {
"ammo.rocket.hv", "rocket_hv"
}
, {
"ammo.rocket.basic", "rocket_basic"
}
, {
"ammo.rocket.smoke", "rocket_smoke"
}
, {
"explosive.timed", "explosive.timed.deployed"
}
, {
"surveycharge", "survey_charge.deployed"
}
, {
"explosive.satchel", "explosive.satchel.deployed"
}
, {
"grenade.beancan", "grenade.beancan.deployed"
}
, {
"grenade.f1", "grenade.f1.deployed"
}
, {
"ammo.grenadelauncher.he", "40mm_grenade_he"
}
, {
"ammo.rifle", "riflebullet"
}
, {
"ammo.rifle.explosive", "riflebullet_explosive"
}
, {
"ammo.rifle.incendiary", "riflebullet_fire"
}
, {
"ammo.pistol", "pistolbullet"
}
, {
"ammo.pistol.fire", "pistolbullet_fire"
}
, {
"ammo.shotgun", "shotgunbullet"
}
, {
"ammo.shotgun.fire", "shotgunbullet_fire"
}
, {
"ammo.shotgun.slug", "shotgunslug"
}
, {
"ammo.rocket.mlrs", "rocket_mlrs"
}
, {
"arrow.wooden", "arrow_wooden"
}
, {
"arrow.hv", "arrow_hv"
}
, {
"arrow.fire", "arrow_fire"
}
, {
"arrow.bone", "arrow_bone"
}
}
;
private Dictionary<string, string> RaidToolsCheck = new Dictionary<string, string> {
{
"ammo.rocket.fire", "rocket_fire"
}
, {
"ammo.rocket.hv", "rocket_hv"
}
, {
"ammo.rocket.basic", "rocket_basic"
}
, {
"ammo.rocket.smoke", "rocket_smoke"
}
, {
"explosive.timed", "explosive.timed.deployed"
}
, {
"surveycharge", "survey_charge.deployed"
}
, {
"explosive.satchel", "explosive.satchel.deployed"
}
, {
"grenade.beancan", "grenade.beancan.deployed"
}
, {
"grenade.f1", "grenade.f1.deployed"
}
, {
"ammo.grenadelauncher.he", "40mm_grenade_he"
}
, {
"ammo.grenadelauncher.buckshot", "shotgunbullet"
}
, {
"ammo.rifle", "riflebullet"
}
, {
"ammo.rifle.hv", "riflebullet"
}
, {
"ammo.pistol", "pistolbullet"
}
, {
"ammo.pistol.hv", "pistolbullet"
}
, {
"ammo.shotgun", "shotgunbullet"
}
, {
"ammo.shotgun.slug", "shotgunslug"
}
, {
"ammo.handmade.shell", "handmade_shell.projectile"
}
, {
"ammo.rocket.mlrs", "rocket_mlrs"
}
, {
"ammo.nailgun.nails", "nailgun.entity"
}
, {
"flamethrower", "flamethrower.entity"
}
, {
"arrow.wooden", "arrow_wooden"
}
, {
"arrow.hv", "arrow_hv"
}
, {
"arrow.bone", "arrow_bone"
}
, {
"spear.stone", "spear_stone.entity"
}
, {
"speargun.spear", "speargun_spear"
}
, {
"spear.wooden", "spear_wooden.entity"
}
, {
"knife.bone", "knife_bone.entity"
}
, {
"bone.club", "bone_club.entity"
}
, {
"knife.butcher", "butcherknife.entity"
}
, {
"machete", "machete.weapon"
}
, {
"knife.combat", "knife.combat.entity"
}
, {
"longsword", "longsword.entity"
}
, {
"mace", "mace.entity"
}
, {
"paddle", "paddle.entity"
}
, {
"pitchfork", "pitchfork.entity"
}
, {
"salvaged.cleaver", "salvaged_cleaver.entity"
}
, {
"salvaged.sword", "salvaged_sword.entity"
}
, {
"hatchet", "hatchet.entity"
}
, {
"pickaxe", "pickaxe.entity"
}
, {
"axe.salvaged", "axe_salvaged.entity"
}
, {
"hammer.salvaged", "hammer_salvaged.entity"
}
, {
"icepick.salvaged", "icepick_salvaged.entity"
}
, {
"stonehatchet", "stonehatchet.entity"
}
, {
"stone.pickaxe", "stone_pickaxe.entity"
}
, {
"rock", "rock.entity"
}
, {
"skull", "skull.entity"
}
, {
"jackhammer", "jackhammer.entity"
}
}
;
private Dictionary<string, string> NotSupportedRaidTools = new Dictionary<string, string> {
{
"ammo.rifle.explosive", "riflebullet_explosive"
}
, {
"ammo.rifle.incendiary", "riflebullet_fire"
}
, {
"ammo.pistol.fire", "pistolbullet_fire"
}
, {
"ammo.shotgun.fire", "shotgunbullet_fire"
}
, {
"flamethrower", "flamethrower.entity"
}
, {
"snowball", "snowballgunbullet"
}
, {
"arrow.fire", "arrow_fire"
}
}
;
private int layers = LayerMask.GetMask("Construction", "Deployed");
private readonly string AdminPerm = "antinoobraid.admin";
private readonly string NoobPerm = "antinoobraid.noob";
#region Config
private class ConfigFile {
[JsonProperty(PropertyName = "Main Settings")]
public MainSettings Main = new MainSettings();
[JsonProperty(PropertyName = "Other Settings")]
public OtherSettings Other = new OtherSettings();
[JsonProperty(PropertyName = "Team & Clan Settings")]
public RelationshipSettings Relationship = new RelationshipSettings();
[JsonProperty(PropertyName = "Refund Settings")]
public RefundSettings Refund = new RefundSettings();
[JsonProperty(PropertyName = "Manage Messages")]
public ManageMessages Messages = new ManageMessages();
[JsonProperty(PropertyName = "Entity Settings")]
public EntitySettings Entity = new EntitySettings();
[JsonProperty(PropertyName = "Weapon Settings")]
public WeaponSettings RaidTools = new WeaponSettings();
[JsonProperty(PropertyName = "Advance Settings")]
public AdvanceSettings Advance = new AdvanceSettings();
public static readonly ConfigFile DefaultConfigFile = new ConfigFile();
}
public class MainSettings {
[JsonProperty("Time (seconds) after which noob will lose protection (in-game time)")]
public int ProtectionTime = 43200;
[JsonProperty("Days of inactivity after which player will be raidable")]
public double InactivityRemove = 3;
[JsonProperty("Remove noob status of a raider on raid attempt")]
public bool UnNoobNew = true;
[JsonProperty("Remove noob status of a raider who is manually marked as a noob on raid attempt")]
public bool UnNoobManual = true;
}
public class OtherSettings {
[JsonProperty("Allow Patrol Helicopter to damage noob structures (This will allow players to raid noobs with Patrol Helicopter)")]
public bool PatrolHeliDamage = true;
[JsonProperty("Ignore twig when calculating base ownership (prevents exploiting)")]
public bool IgnoreTwig = true;
[JsonProperty("Check full ownership of the base instead of only one block")]
public bool CheckFullOwnership = true;
[JsonProperty("Kill fireballs when someone tries to raid protected player with fire (prevents lag)")]
public bool KillFire = true;
[JsonProperty("Clear Player Data on Map-Wipe")]
public bool MapWipe = false;
}
public class RelationshipSettings {
[JsonProperty("Enable 'Clan' Support (Allow clan members to destroy each others entities & Remove protection from clan members when a member tries to raid)")]
public bool CheckClan = true;
[JsonProperty("Enable 'Team' Support (Allow team members to destroy each others entities & Remove protection from team members when a member tries to raid)")]
public bool CheckTeam = true;
[JsonProperty("Enable 'Team' playtime sync (Sync's all player's within a team to the highest playtime)")]
public bool SyncTeamPlaytime = true;
}
public class RefundSettings {
[JsonProperty("Refund explosives")]
public bool RefundItem = true;
[JsonProperty("Refunds before player starts losing explosives")]
public int RefundTimes = 4;
}
public class ManageMessages {
[JsonProperty("Notify player on first connection with protection time")]
public bool MessageOnFirstConnection = true;
[JsonProperty("Use game tips to send most messages to players")]
public bool UseGT = false;
[JsonProperty("Show message for not being able to raid")]
public bool ShowMessage = true;
[JsonProperty("Show time until raidable")]
public bool ShowTime = false;
[JsonProperty("Show time until raidable only to owners")]
public bool ShowOwnerTime = true;
[JsonProperty("Show message on first Twig placement that Twig is not protected")]
public bool ShowMessageTwig = true;
}
public class EntitySettings {
[JsonProperty("List of entities that can be destroyed even if owner is noob")]
public Dictionary<string, string> AllowedEntities = AllowedEntitiesDictionary;
[JsonProperty("List of entities that can be destroyed without losing noob protection")]
public Dictionary<string, string> AllowedEntitiesNoob = AllowedEntitiesNoobDictionary;
public static Dictionary<string, string> AllowedEntitiesDictionary = new Dictionary<string, string> {
{
"ShortPrefabName", "Common Name"
}
, {
"beartrap", "Snap Trap"
}
, {
"landmine", "Landmine"
}
,
}
;
public static Dictionary<string, string> AllowedEntitiesNoobDictionary = new Dictionary<string, string> {
{
"ShortPrefabName", "Common Name"
}
, {
"campfire", "Camp Fire"
}
,
}
;
}
public class WeaponSettings {
[JsonProperty("List of Weapons/Tools that won't trigger player to lose noob protection")]
public Dictionary<string, string> AllowedRaidTools = AllowedRaidToolsDictionary;
public static Dictionary<string, string> AllowedRaidToolsDictionary = new Dictionary<string, string> {
{
"ShortPrefabName", "Common Name"
}
, {
"rocket_smoke", "Smoke Rocket WIP!!!!"
}
,
}
;
}
public class AdvanceSettings {
[JsonProperty("User data refresh interval (seconds)")]
public int Frequency = 30;
[JsonProperty("Save interval (seconds)")]
public int SaveFrequency = 60;
[JsonProperty("Save data on Server Save")]
public bool OnServerSave = true;
[JsonProperty("Show structure has no owner in console")]
public bool ShowNoOwnerBase = false;
[JsonProperty("Enable Logs (Logs can be found in /oxide/logs/antinoobraid)")]
public bool EnableLogging = true;
}
private ConfigFile config;
protected override void LoadDefaultConfig() {
Config.Clear();
PrintWarning("Creating new config file");
NextTick(() => Config.WriteObject(config));
SaveConfig();
}
#endregion
#region Lang
protected override void LoadDefaultMessages() {
lang.RegisterMessages(new Dictionary<string, string>() {
{
"NoPlayerFound", "Couldn't find '{0}'"
}
, {
"NotNumber", "{0} is not a number"
}
, {
"antinoobcmd_syntax", "Wrong syntax! /antinoob <addnoob|removenoob|wipe>"
}
, {
"antinoobcmd_addnoob_syntax", "Wrong syntax! /antinoob addnoob <name/steamid>"
}
, {
"antinoobcmd_alreadynoob", "{0} is already marked as a noob"
}
, {
"antinoobcmd_marked", "Marked {0} as a noob"
}
, {
"antinoobcmd_removenoob_syntax", "Wrong syntax! /antinoob removenoob <name/steamid>"
}
, {
"antinoobcmd_removednoob", "{0} does not have a noob status anymore"
}
, {
"antinoobcmd_missingnoob", "{0} is not a noob"
}
, {
"antinoobcmd_wipe_syntax", "Missing argument! <all|playerdata|attempts>"
}
, {
"dataFileWiped", "Data file successfully wiped"
}
, {
"dataFileWiped_attempts", "Data file successfully wiped (raid attempts)"
}
, {
"dataFileWiped_playerdata", "Data file successfully wiped (player data)"
}
, {
"struct_noowner", "Structure at {0} has no owner! OwnerID = {1} buildingID = {2}"
}
, {
"clan_lostnoob" , "Clan '{0}' lost their noob status because they tried to raid"
}
, {
"lost_teamsprotection" , "You lost your team noob protection for damaging a structure"
}
, {
"lost_clansprotection" , "You lost your clan noob protection for damaging a structure"
}
, {
"new_user_lostprotection" , "You lost your noob protection for damaging a structure"
}
, {
"console_lostnoobstatus", "{0} hasn't connected for {1} days so he lost his noob status (can be raided)"
}
, {
"console_notenough", "{0} doesn't have enough hours in game to be marked as a non-noob"
}
, {
"firstconnectionmessage", "You are a new player so your buildings are protected for first {0} hours of your time on server"
}
, {
"pt_notInstalled", "Playtime Tracker is not installed, will check again in 15 seconds!"
}
, {
"pt_detected", "Playtime Tracker detected"
}
, {
"C_notInstalled", "Clans is not installed, will check again in 15 seconds!"
}
, {
"C_detected", "Clans detected"
}
, {
"userinfo_nofound", "Failed to get playtime info for {0}! trying again in 300 seconds!"
}
, {
"userinfo_nofound_2nd_attempt", "Failed to get playtime info for {0}! Has been marked as non-noob!"
}
, {
"userinfo_found", "Successfully got playtime info for {0}!"
}
, {
"twig_can_attack", "This structure is Twig & is not raid protected.Please upgrade to Wood or higer for protection!"
}
, {
"can_attack", "This structure is not raid protected"
}
, {
"NotLooking", "You are not looking at a building/deployable"
}
, {
"refunditem_help", "Wrong Syntax! /refunditem add <you have to hold the item you want to add>\n/refunditem remove <you have to hold the item you want to remove>\n/refunditem list\n/refunditem clear\n/refunditem all <sets all raid tools as refundable>"
}
, {
"refunditem_needholditem", "You need to hold the item you want to add/remove from refund list"
}
, {
"refunditem_notexplosive", "This item is not an explosive"
}
, {
"refunditem_added", "Added '{0}' to list of items to refund"
}
, {
"refunditem_alreadyonlist", "This item is already on the list"
}
, {
"refunditem_notonlist", "This item is not on the list"
}
, {
"refunditem_removed", "Removed '{0}' from the list of items to refund"
}
, {
"refunditem_addedall", "Added all raid tools to refund list"
}
, {
"refunditem_cleared", "Cleared list of items to refund"
}
, {
"refunditem_empty", "There are no item set up yet"
}
, {
"refunditem_list", "List of items which will get refunded: \n{0}"
}
, {
"refund_free", "Your '{0}' was refunded."
}
, {
"refund_last", "Your '{0}' was refunded but will not be next time."
}
, {
"refund_1time", "Your '{0}' was refunded.After 1 more attempt it wont be refunded."
}
, {
"refund_nTimes", "Your '{0}' was refunded.After {1} more attempts it wont be refunded"
}
, {
"cannot_attack_no_time", "This entity cannot be destroyed because it was built by a new player"
}
, {
"cannot_attack_time", "This entity cannot be destroyed because it was built by a new player ({0})"
}
, {
"looking_item", "The entity name is {0}"
}
, {
"notlooking_item", "You need to look at a deployed item to get the name!"
}
, {
"holding_item", "The items name is {0}"
}
, {
"notholding_item", "You need to hold a Raiding Tool to get the name!"
}
, {
"Not_Supported", "This Raiding Tool is not supported for \"Weapon Settings\"!"
}
, {
"Increase_Refresh", "Increase \"User data refresh interval\" in the Config and reload! Can't be less or equal than 10 seconds."
}
, {
"secs", " seconds"
}
, {
"mins", " minutes"
}
, {
"min", " minute"
}
, {
"hours", " hours"
}
, {
"hour", " hour"
}
, {
"day", " day"
}
, {
"days", " days"
}
}
, this);
}
#endregion
#region DataFile/Classes
private class BuildingInfo {
public static HashSet<BuildingInfo> buildCache = new HashSet<BuildingInfo>();
public BuildingInfo() {
}
public uint buildingID;
public ulong OwnerID;
public DateTime lastUpdate;
public static BuildingInfo GetByBuildingID(uint bID) {
foreach (var entry in buildCache) if (entry.buildingID == bID) return entry;
return null;
}
public double GetCacheAge() {
if (lastUpdate == null) return -1;
return DateTime.UtcNow.Subtract(lastUpdate).TotalSeconds;
}
}
private class ClanInfo {
public static HashSet<ClanInfo> clanCache = new HashSet<ClanInfo>();
public ClanInfo() {
}
public static ClanInfo FindClanByName(string clanName) {
foreach (var clan in ClanInfo.clanCache) if (clan.clanName == clanName) return clan;
return null;
}
public static ClanInfo GetClanOf(ulong playerID) {
foreach (var clan in ClanInfo.clanCache) if (clan.members.Contains(playerID)) return clan;
return null;
}
public string clanName {
get;
set;
}
public List<ulong> members = new List<ulong>();
}
private class StoredData {
public Dictionary<ulong, double> players = new Dictionary<ulong, double>();
public Dictionary<ulong, int> AttackAttempts = new Dictionary<ulong, int>();
public List<ulong> playersWithNoData = new List<ulong>();
public List<ulong> FirstMessaged = new List<ulong>();
public List<ulong> InTeam = new List<ulong>();
public List<ulong> ShowTwigsNotProtected = new List<ulong>();
public Dictionary<ulong, string> lastConnection = new Dictionary<ulong, string>();
public List<ulong> IgnoredPlayers = new List<ulong>();
public StoredData() {
}
}
private class StoredDataItemList {
public Dictionary<string, string> ItemList = new Dictionary<string, string>();
public StoredDataItemList() {
}
}
private void SaveData() => Interface.Oxide.DataFileSystem.WriteObject($"{this.Name}\\{this.Name}_Data", storedData);
private void SaveDataItemList() => Interface.Oxide.DataFileSystem.WriteObject($"{this.Name}\\{this.Name}_RefundItemList", storedDataItemList);
StoredData storedData;
StoredDataItemList storedDataItemList;
#endregion
#region Setup/Saving
private void Init() {
permission.RegisterPermission(AdminPerm, this);
permission.RegisterPermission(NoobPerm, this);
storedData = Interface.Oxide.DataFileSystem.ReadObject<StoredData>($"{this.Name}\\{this.Name}_Data");
storedDataItemList = Interface.Oxide.DataFileSystem.ReadObject<StoredDataItemList>($"{this.Name}\\{this.Name}_RefundItemList");
config = Config.ReadObject<ConfigFile>();
Unsubscribe(nameof(OnEntityDeath));
Unsubscribe(nameof(OnEntityKill));
Unsubscribe(nameof(OnEntitySpawned));
Unsubscribe(nameof(OnEntityTakeDamage));
//if (config.AutoMinutes <= 0 && config.AutoAddProtection) PrintError("Time (minutes) after which the raided person gains raid protection is set to 0!!! Change this!!");
}
private void RegisterCommands() {
foreach (var command in AdminCommands) AddCovalenceCommand(command.Key, command.Value, AdminPerm);
}
private void OnServerInitialized(bool isStartup) // Reminder use this hook instead of Loaded().Thanks Nivex
{
foreach (var block in BaseEntity.saveList.OfType<BuildingBlock>()) _blocks.Add(block);
Subscribe(nameof(OnEntityDeath));
Subscribe(nameof(OnEntityKill));
Subscribe(nameof(OnEntitySpawned));
Subscribe(nameof(OnEntityTakeDamage));
RegisterCommands();
foreach (var entry in storedData.players.Where(x => !storedData.lastConnection.ContainsKey(x.Key))) storedData.lastConnection.Add(entry.Key, string.Empty);
StartChecking();
CheckPlayersWithNoInfo();
if (!config.Advance.OnServerSave) {
float args = config.Advance.SaveFrequency;
int offset = (int) args;
timer.Every(offset, SaveData);
}
if (beta) PrintWarning($"Debug Version: {betaversion}");
if (config.Advance.Frequency <= 10) {
timer.Every(15f, () => {
PrintWarning(lang.GetMessage("Increase_Refresh", this, null));
}
);
}
if (PlaytimeTracker == null) {
PrintWarning(lang.GetMessage("pt_notInstalled", this, null));
CheckingPT = timer.Every(15f, () => {
if (PlaytimeTracker == null) {
PrintWarning(lang.GetMessage("pt_notInstalled", this, null));
}
else {
PrintWarning(lang.GetMessage("pt_detected", this, null));
timer.Destroy(ref CheckingPT);
}
}
);
}
if (config.Relationship.CheckClan && Clans != null) {
timer.Every(60f, RefreshClanCache);
}
if (config.Relationship.CheckClan && Clans == null) {
PrintWarning(lang.GetMessage("C_notInstalled", this, null));
CheckingC = timer.Every(15f, () => {
if (Clans == null) {
PrintWarning(lang.GetMessage("C_notInstalled", this, null));
}
else {
PrintWarning(lang.GetMessage("C_detected", this, null));
timer.Destroy(ref CheckingC);
}
}
);
}
}
private void Unload() {
LeaderLower.Clear();
SaveData();
SaveDataItemList();
}
private void OnServerSave() {
if (config.Advance.OnServerSave) timer.Once(UnityEngine.Random.Range(5, 15), SaveData);
}
private void OnNewSave() {
if (config.Other.MapWipe == true) {
storedData.players.Clear();
storedData.IgnoredPlayers.Clear();
storedData.lastConnection.Clear();
storedData.ShowTwigsNotProtected.Clear();
storedData.InTeam.Clear();
storedData.FirstMessaged.Clear();
storedData.playersWithNoData.Clear();
storedData.AttackAttempts.Clear();
SaveData();
PrintWarning("New savefile detected.All Player Data was cleared!");
}
}
#endregion
#region Commands
private Dictionary<string, string> AdminCommands = new Dictionary<string, string> {
{
"antinoob", "AntiNoobCommand"
}
, {
"checkname", "CheckNameCmd"
}
, {
"refunditem", "RefundCmd"
}
,
}
;
private void AntiNoobCommand(IPlayer player, string command, string[] args) {
if (args.Length < 1) {
player.Reply(lang.GetMessage("antinoobcmd_syntax", this, player.Id));
return;
}
switch (args[0].ToLower()) {
case "addnoob" : {
if (args.Length < 2) {
player.Reply(lang.GetMessage("antinoobcmd_addnoob_syntax", this, player.Id));
return;
}
var p = covalence.Players.FindPlayer(args[1]);
if (p == null) {
player.Reply(lang.GetMessage("NoPlayerFound", this, player.Id), null, args[1]);
return;
}
foreach (var entry in storedData.players) {
if (entry.Key == ulong.Parse(p.Id)) {
if (storedData.players[entry.Key] == -25d) {
player.Reply(lang.GetMessage("antinoobcmd_alreadynoob", this, player.Id), null, p.Name);
return;
}
storedData.players[entry.Key] = -25d;
player.Reply(lang.GetMessage("antinoobcmd_marked", this, player.Id), null, p.Name);
return;
}
}
player.Reply(lang.GetMessage("NoPlayerFound", this, player.Id), null, args[1]);
return;
}
case "removenoob" : {
if (args.Length < 2) {
player.Reply(lang.GetMessage("antinoobcmd_removenoob_syntax", this, player.Id));
return;
}
var p = covalence.Players.FindPlayer(args[1]);
if (p == null) {
player.Reply(lang.GetMessage("NoPlayerFound", this, player.Id), null, args[1]);
}
foreach (var entry in storedData.players) {
if (entry.Key == ulong.Parse(p.Id)) {
if (storedData.players[entry.Key] == -50d) {
player.Reply(lang.GetMessage("antinoobcmd_missingnoob", this, player.Id), null, p.Name);
return;
}
storedData.players[entry.Key] = -50d;
player.Reply(lang.GetMessage("antinoobcmd_removednoob", this, player.Id), null, p.Name);
return;
}
}
player.Reply(lang.GetMessage("NoPlayerFound", this, player.Id), null, args[1]);
return;
}
case "wipe" : {
if (args.Length < 2) {
player.Reply(lang.GetMessage("antinoobcmd_wipe_syntax", this, player.Id));
return;
}
switch (args[1].ToLower()) {
case "all" : {
storedData.lastConnection.Clear();
storedData.playersWithNoData.Clear();
storedData.FirstMessaged.Clear();
storedData.AttackAttempts.Clear();
storedDataItemList.ItemList.Clear();
storedData.players.Clear();
player.Reply(lang.GetMessage("dataFileWiped", this, player.Id));
return;
}
case "playerdata" : {
storedData.players.Clear();
player.Reply(lang.GetMessage("dataFileWiped_playerdata", this, player.Id));
return;
}
case "attempts" : {
storedData.AttackAttempts.Clear();
player.Reply(lang.GetMessage("dataFileWiped_attempts", this, player.Id));
return;
}
default : {
player.Reply(lang.GetMessage("antinoobcmd_wipe_syntax", this, player.Id));
return;
}
}
}
default : {
player.Reply(lang.GetMessage("antinoobcmd_syntax", this, player.Id));
return;
}
}
}
[ChatCommand("checknew")]
private void CheckNewCmd(BasePlayer player, string command, string[] args) {
BaseEntity hitEnt = GetLookAtEntity(player);
if (hitEnt == null) {
SendReply(player, lang.GetMessage("NotLooking", this, player.UserIDString));
return;
}
if (config.Messages.ShowMessage && config.Other.IgnoreTwig && (hitEnt as BuildingBlock)?.grade == BuildingGrade.Enum.Twigs) {
SendReply(player, lang.GetMessage("twig_can_attack", this, player.UserIDString));
return;
}
ulong owner = config.Other.CheckFullOwnership ? FullOwner(hitEnt) : hitEnt.OwnerID;
if (owner == 0u || !storedData.players.ContainsKey(owner)) return;
MessagePlayer(player, owner);
}
[ChatCommand("entdebug")]
private void EntDebugCmd(BasePlayer player, string command, string[] args) {
if (!player.IsAdmin) return;
BaseEntity ent = GetLookAtEntity(player);
if (ent == null) {
SendReply(player, "No entity");
return;
}
var ownerid = (FullOwner(ent) != 0) ? FullOwner(ent) : ent.OwnerID;
if (args.Length < 1) {
SendReply(player, "OwnerID: " + ent.OwnerID);
SendReply(player, "FullOwner: " + FullOwner(ent));
if (storedData.players.ContainsKey(ownerid)) {
var tiem = (int)storedData.players[ownerid];
switch (tiem) {
case -25 : {
SendReply(player, "Time: -25d (manually set noob)");
break;
}
case -50 : {
SendReply(player, "Time: -50d (damaged structure, clan lost protection, inactive)");
break;
}
default : {
SendReply(player, "Time: " + tiem + " ('natural' time)");
if (tiem >= config.Main.ProtectionTime) SendReply(player, "Should be raidable");
else SendReply(player, "Shouldn't be raidable");
break;
}
}
}
else SendReply(player, "StoredData does not contain info for " + ownerid);
return;
}
var t = ulong.Parse(args[0]);
ent.OwnerID = t;
ent.SendNetworkUpdate();
SendReply(player, "Set OwnerID: " + ent.OwnerID);
return;
}
private void CheckNameCmd(IPlayer p, string command, string[] args) {
BasePlayer player = p.Object as BasePlayer;
BaseEntity hitEnt = GetLookAtEntity(player);
Item helditem = player.GetActiveItem();
if (player == null) return;
if (args.Length < 1) {
return;
}
switch (args[0].ToLower()) {
case "looking" : {
if (hitEnt == null) {
p.Reply(lang.GetMessage("notlooking_item", this, p.Id));
return;
}
if (hitEnt != null) {
p.Reply(lang.GetMessage("looking_item", this, player.UserIDString), null, hitEnt);
return;
}
return;
}
case "holding" : {
if (helditem == null) {
p.Reply(lang.GetMessage("notholding_item", this, p.Id));
return;
}
if (NotSupportedRaidTools.ContainsKey(helditem.info.shortname)) {
p.Reply(lang.GetMessage("Not_Supported", this, p.Id));
return;
}
if (RaidToolsCheck.ContainsKey(helditem.info.shortname)) {
p.Reply(lang.GetMessage("holding_item", this, player.UserIDString), null, RaidToolsCheck[helditem.info.shortname]);
return;
}
else {
p.Reply(lang.GetMessage("notholding_item", this, p.Id));
return;
}
}
}
}
private void RefundCmd(IPlayer p, string command, string[] args) {
BasePlayer player = p.Object as BasePlayer;
if (player == null) return;
if (args.Length < 1) {
p.Reply(lang.GetMessage("refunditem_help", this, p.Id));
return;
}
Item helditem = player.GetActiveItem();
switch (args[0].ToLower()) {
case "add" : {
if (player.GetActiveItem() == null) {
p.Reply(lang.GetMessage("refunditem_needholditem", this, player.UserIDString));
return;
}
if (raidtools.ContainsKey(helditem.info.shortname)) {
if (!storedDataItemList.ItemList.ContainsKey(helditem.info.shortname)) {
storedDataItemList.ItemList.Add(helditem.info.shortname, raidtools[helditem.info.shortname]);
p.Reply(lang.GetMessage("refunditem_added", this, player.UserIDString), null, helditem.info.displayName.english);
return;
}
p.Reply(lang.GetMessage("refunditem_alreadyonlist", this, player.UserIDString));
return;
}
p.Reply(lang.GetMessage("refunditem_notexplosive", this, player.UserIDString));
SaveDataItemList();
return;
}
case "remove" : {
if (player.GetActiveItem() == null) {
p.Reply(lang.GetMessage("refunditem_needholditem", this, player.UserIDString));
return;
}
if (storedDataItemList.ItemList.ContainsKey(helditem.info.shortname)) {
storedDataItemList.ItemList.Remove(helditem.info.shortname);
p.Reply(lang.GetMessage("refunditem_removed", this, player.UserIDString), null, helditem.info.displayName.english);
return;
}
p.Reply(lang.GetMessage("refunditem_notonlist", this, player.UserIDString));
SaveDataItemList();
return;
}
case "all" : {
foreach (var t in raidtools) if (!storedDataItemList.ItemList.ContainsKey(t.Key)) storedDataItemList.ItemList.Add(t.Key, t.Value);
p.Reply(lang.GetMessage("refunditem_addedall", this, player.UserIDString));
SaveDataItemList();
return;
}
case "clear" : {
storedDataItemList.ItemList.Clear();
p.Reply(lang.GetMessage("refunditem_cleared", this, player.UserIDString));
SaveDataItemList();
return;
}
case "list" : {
if (storedDataItemList.ItemList.Count < 1) {
p.Reply(lang.GetMessage("refunditem_empty", this, player.UserIDString));
return;
}
List<string> T2 = new List<string>();
foreach (var entry in storedDataItemList.ItemList) {
Item item = ItemManager.CreateByName(entry.Key, 1);
if (item.info.displayName.english == null) LogToFile("other", "Failed to find display name for " + entry.Key, this, true);
T2.Add(item?.info?.displayName?.english);
}
string final = string.Join("\n", T2.ToArray());
p.Reply(lang.GetMessage("refunditem_list", this, player.UserIDString), null, final);
return;
}
default : {
p.Reply(lang.GetMessage("refunditem_help", this, player.UserIDString));
return;
}
}
}
#endregion
#region Rust/uMod Hooks
private object OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitinfo) {
var owner = config.Other.CheckFullOwnership ? FullOwner(entity) : entity.OwnerID;
BasePlayer attacker = hitinfo.InitiatorPlayer;
var dmgType = hitinfo?.damageTypes?.GetMajorityDamageType() ?? DamageType.Generic;
string name = CheckForRaidingTools(hitinfo);
if (hitinfo == null || entity == null || attacker == null || owner == 0) return null;
//null checks
if (!entity.OwnerID.IsSteamId() || !attacker.userID.IsSteamId()) return null;
if (entity?.OwnerID == attacker?.userID) return null;
if (dmgType == DamageType.Decay || dmgType == DamageType.Generic || dmgType == DamageType.Bite || dmgType == DamageType.Fun_Water) return null;
if (entity.OwnerID == 0u || CheckForBuildingOrDeployable(entity, hitinfo) == false) return null;
if (HasProtection(attacker) == true) return null;
if (config.Other.IgnoreTwig && (entity as BuildingBlock)?.grade == BuildingGrade.Enum.Twigs) return null;
if (CheckForHelicopterOrMLRS(entity, hitinfo) == true) return null;
if (NullWeaponCheck(entity, hitinfo) == true) return null;
if (config.RaidTools.AllowedRaidTools.ContainsKey(name)) {
if (PlayerIsNew(owner)) {
hitinfo.damageTypes = new DamageTypeList();
hitinfo.DoHitEffects = false;
hitinfo.HitMaterial = 0;
hitinfo.damageTypes.ScaleAll(0f);
NextTick(() => {
MessagePlayer(attacker, owner);
Refund(attacker, name, entity);
}
);
return true;
}
else {
return null;
}
}
if (config.Entity.AllowedEntities.ContainsKey(entity.ShortPrefabName)) {
return null;
}
if (config.Entity.AllowedEntitiesNoob.ContainsKey(entity.ShortPrefabName)) {
if (PlayerIsNew(owner)) {
hitinfo.damageTypes = new DamageTypeList();
hitinfo.DoHitEffects = false;
hitinfo.HitMaterial = 0;
hitinfo.damageTypes.ScaleAll(0f);
NextTick(() => {
MessagePlayer(attacker, owner);
Refund(attacker, name, entity);
}
);
return true;
}
else {
return null;
}
}
if (attacker == null || owner == 0u) return null;
if (sto
// ... [Code preview truncated due to length. Full source in attached file] ...