C#:
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json.Linq;
using Oxide.Core.Plugins;
namespace Oxide.Plugins {
[Info("AntiZirper", "zirper lox zweb govno s lagami", "1.0.0")]
public class AntiZirper : RustPlugin {
Dictionary<BasePlayer, Timer> timerslist = new Dictionary<BasePlayer, Timer>();
void OnPlayerInit(BasePlayer player) {
if (player.IsAdmin) {
player.SendConsoleCommand("client.camspeed 1");
player.SendConsoleCommand("client.camdist 1.5");
return;
}
else timerslist.Add(player, timer.Every(2f, () => {
player.SendConsoleCommand("debug.debugcamera");
player.SendConsoleCommand("client.camspeed 0");
player.SendConsoleCommand("client.camdist 100000");
player.SendConsoleCommand("noclip");
}
));
}
void OnPlayerDisconnected(BasePlayer player, string reason) {
if (timerslist.ContainsKey(player)) {
Timer t;
timerslist.TryGetValue(player, out t);
t.Destroy();
timerslist.Remove(player);
}
}
void Loaded() {
var filter = Game.Rust.RustExtension.Filter.ToList();
filter.Add("Calling 'OnPlayerAttack' on");
filter.Add("Invalid Position:");
Game.Rust.RustExtension.Filter = filter.ToArray();
ConsoleSystem.Run(ConsoleSystem.Option.Server, "projectile_protection 5");
PrintWarning("Плагин успешно загружен. #ZWEBZALUPA");
}
[HookMethod("OnPlayerAttack")]
object OnPlayerAttack(BasePlayer player, HitInfo info) {
if (info.HitEntity is BasePlayer || info.HitEntity is BaseEntity) {
float distanceto = info.HitEntity.Distance(info.HitPositionWorld);
if (info.HitEntity.name == "assets/prefabs/player/player.prefab" && info.HitPart == 0) {
return true;
}
else if (info.HitEntity.name == "assets/prefabs/misc/orebonus/orebonus_generic.prefab" || info.HitBone == 954334883) {
Logger(player, $"Detected autofarm: [{player.UserIDString}/{player.displayName}]");
PrintWarning($"Detected autofarm: [{player.UserIDString}/{player.displayName}]");
return true;
}
if (info.HitEntity as BaseHelicopter) {
if (distanceto > 20f) {
return true;
}
}
else {
if (player != null && info.HitEntity != null && info.HitEntity is BasePlayer) {
var distance = info.ProjectileDistance;
if (distance == 10 || distance > 450 || distance < 0) {
Logger(player, $"{player.displayName}({player.UserIDString}) Have invalid distance: {distance} | Damage was rejected.");
PrintWarning($"{player.displayName}({player.UserIDString}) Have invalid distance: {distance} | Damage was rejected.");
return true;
}
if (info.HitBone == 920055401 || info.HitBone == 1777818830 || info.HitBone == 1829300796 || info.HitBone == 333343219 || info.HitBone == 2582769124 || info.HitBone == 3892428003 || info.HitBone == 1286912989 || info.HitBone == 2331610670 || info.HitBone == 2811218643 || info.HitBone == 3333432192) {
return null;
}
float meters = info.HitEntity.Distance(info.HitPositionWorld);
if (meters > 0.2f) {
return true;
}
}
}
}
return null;
}
private void Logger(BasePlayer player, string text) {
ConVar.Server.Log($"Detected {player.userID}", $"{DateTime.Now.ToShortTimeString()} {text}");
}
}
}