Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Networking;
- using Oxide.Core.Libraries;
- using Oxide.Core.Libraries.Covalence;
- using Oxide.Game.Rust.Cui;
- using Oxide.Core;
- using Oxide.Core.Plugins;
- using Oxide.Core.Configuration;
- using System.Collections.Generic;
- using System.Reflection;
- using System;
- using ProtoBuf;
- using System.Data;
- using UnityEngine;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using Newtonsoft.Json;
- using static UnityEngine.Camera;
- using Newtonsoft.Json.Linq;
- using System.Data;
- using Network;
- using Rust;
- using Facepunch;
- using Facepunch.Extend;
- namespace Oxide.Plugins
- {
- [Info("Blinkarrow", "Crushedice", 0.1)]
- [Description("Makes epic stuff happen")]
- class Blinkarrow : RustPlugin
- {
- [PluginReference] Plugin EntityOwner;
- [PluginReference] Plugin RunningMan;
- [PluginReference] Plugin ZoneManager;
- [PluginReference("SteamReport")]
- private Plugin stLib;
- #region Config + Variables
- List<string> admins;
- string requestUrl;
- string reportCommand;
- float healAmount = 50f; // Instant heal amount
- float hotAmount = -50f; // Heal-over-time amount
- float hotTime = 10f; // Heal-over-time time
- public float time = 30f;
- public float damageAmount;
- private static Quaternion currentRot;
- private static Quaternion newRot;
- public bool ShowOverlay = true;
- public bool ShowIndicator = false;
- public BaseCombatEntity attackEntity = null;
- private readonly int triggerMask = LayerMask.GetMask("Trigger");
- private List<string> currentRadTraps = new List<string>();
- int radiationRadius = 30;
- int radiationAmount = 75;
- Dictionary<ulong, string> GuiInfo = new Dictionary<ulong, string>();
- public string guiInfo;
- protected override void LoadDefaultConfig()
- {
- Config["Admins"] = new List<string>
- {
- "76561198023392824",
- "76561198089504909",
- "76561197963657583"
- };
- Config["RequestUrl"] = "http://steam.spicee.xyz:8192/";
- Config["ReportCommand"] = "report2";
- if(Config["Effects", "Height"] == null) Config["Effects", "Height"] = "2.5";
- if(Config["Effects", "Height"].ToString() != "2.5") return;
- if(Config["Effects", "Spacing"] == null) Config["Effects", "Spacing"] = "0.2";
- if(Config["Effects", "Spacing"].ToString() != "0.2") return;
- Puts("Default configuration created");
- }
- class StoredData
- {
- public HashSet<PlayerInfo> Players = new HashSet<PlayerInfo>();
- public StoredData()
- {
- }
- }
- public class LevelTool
- {
- uint ToolID;
- int Level;
- public LevelTool()
- {
- }
- }
- public class PlayerInfo
- {
- public string UserId;
- public string Name;
- public static int pressed;
- public static int Cd;
- public static int damageAmount;
- public PlayerInfo()
- {
- }
- public PlayerInfo(BasePlayer player)
- {
- UserId = player.userID.ToString();
- Name = player.displayName;
- pressed = 0;
- }
- }
- StoredData storedData;
- void Loaded ()
- {
- permission.RegisterPermission("Blinkarrow.use", this);
- permission.RegisterPermission("Blinkarrow.ta3", this);
- permission.RegisterPermission("Blinkarrow.protect", this);
- permission.RegisterPermission("Blinkarrow.Spot", this);
- }
- void Init()
- {
- admins = Config.Get<List<string>>("Admins");
- requestUrl = Config.Get<string>("RequestUrl");
- reportCommand = Config.Get<string>("ReportCommand");
- foreach (var id in admins)
- if (!id.IsSteamId())
- Puts($"{id} is not a valid SteamID64.");
- AddCovalenceCommand(reportCommand, "SendReport", "steamreport.use");
- }
- #endregion
- #region Commands
- [ConsoleCommand("quary")]
- void speedup(ConsoleSystem.Arg arg)
- {
- var quarries = UnityEngine.Object.FindObjectsOfType<MiningQuarry>();
- foreach (var quarry2 in quarries.Where(quarry2 => quarry2.IsOn()))
- {
- quarry2.CancelInvoke("ProcessResources");
- quarry2.InvokeRepeating("ProcessResources", 1f, 1f);
- }
- }
- [ConsoleCommand("SendReport")]
- void SendReport(IPlayer player, BasePlayer player2)
- {
- var PlayerPosi = player.Position();
- Vector3 PlayerPos = new Vector3(PlayerPosi.X , PlayerPosi.Y, PlayerPosi.Z);
- var GroundHeight = GetGround(PlayerPos);
- //var target = found.First();
- //var groundY = GroundHeight.y;
- //var playerY = PlayerPosi.Y;
- //var ActualHeight = playerY += playerY-groundY;
- var posx = Convert.ToInt32(PlayerPosi.X);
- var posy = Convert.ToInt32(PlayerPosi.Y);
- var posz = Convert.ToInt32(PlayerPosi.Z);
- var PosX = Convert.ToString(posx);
- var PosY = Convert.ToString(posy);
- var PosZ = Convert.ToString(posz);
- var message = "VIOLATIONKICK " + "| Player Position: " +PosX+","+PosY+","+PosZ ;
- //for (var i = 1; i < args.Length; i++)
- // message += args[i] + (i == args.Length ? string.Empty : " ");
- var request = string.Format("{0}?adminList={1}&reporterName={2}&reporterId={3}&message={4}",
- requestUrl, string.Join("|", admins.ToArray()), player.Name, player.Id, message);
- webrequest.EnqueueGet(request, (code, response) =>
- {
- if (code != 200 || response == null)
- {
- //player.Reply(_("Fail", player.Id));
- return;
- }
- //player.Reply(_("Sent", player.Id));
- }, this);
- }
- //eventManager Boost
- [ChatCommand("BoostOff")]
- void testing(BasePlayer player, string command, string[] args)
- {
- player.SendConsoleCommand("antihack.enforcementlevel 1 ");
- player.SendConsoleCommand("antihack.eye_protection 2 ");
- player.SendConsoleCommand("antihack.flyhack_penalty 100 ");
- player.SendConsoleCommand("antihack.flyhack_protection 3 ");
- player.SendConsoleCommand("antihack.melee_protection 3 ");
- player.SendConsoleCommand("antihack.noclip_protection 3 ");
- player.SendConsoleCommand("antihack.noclip_reject True ");
- player.SendConsoleCommand("antihack.projectile_protection 3 ");
- player.SendConsoleCommand("antihack.speedhack_protection 1 ");
- player.SendConsoleCommand("antihack.speedhack_reject True ");
- player.SendConsoleCommand("weather.clouds auto ");
- player.SendConsoleCommand("weather.fog auto ");
- player.SendConsoleCommand("weather.rain auto ");
- player.SendConsoleCommand("weather.wind auto ");
- player.SendConsoleCommand("AI.think true ");
- player.SendConsoleCommand("server.tickrate 32 ");
- }
- [ChatCommand("BoostOn")]
- void testing2(BasePlayer player, string command, string[] args)
- {
- player.SendConsoleCommand("antihack.enforcementlevel 0 ");
- player.SendConsoleCommand("antihack.eye_protection 0 ");
- player.SendConsoleCommand("antihack.flyhack_penalty 0 ");
- player.SendConsoleCommand("antihack.flyhack_protection 0 ");
- player.SendConsoleCommand("antihack.melee_protection 0 ");
- player.SendConsoleCommand("antihack.noclip_protection 0 ");
- player.SendConsoleCommand("antihack.noclip_reject False ");
- player.SendConsoleCommand("antihack.projectile_protection 0 ");
- player.SendConsoleCommand("antihack.speedhack_protection 0 ");
- player.SendConsoleCommand("antihack.speedhack_reject False ");
- player.SendConsoleCommand("weather.clouds 0 ");
- player.SendConsoleCommand("weather.fog 0 ");
- player.SendConsoleCommand("weather.rain 0 ");
- player.SendConsoleCommand("weather.wind 0 ");
- player.SendConsoleCommand("AI.think false ");
- player.SendConsoleCommand("server.tickrate 64 ");
- }
- //Copy an item with its Skin
- [ChatCommand("GCopy")]
- void Copyperking(BasePlayer player, string command, string[] args)
- {
- bool check = isAuth(player);
- if(check == false)
- return;
- var HItem = player.GetActiveItem();
- var Def = HItem.info;
- ulong skin = HItem.skin;
- //var itemdisplay = Convert.ToString(args[0]);
- // var definition = ItemManager.FindItemDefinition(itemdisplay);
- if (Def != null)
- {
- //itemdisplay = definition.displayName.english;
- var item = ItemManager.Create(Def, 1, skin);
- if (item != null)
- player.GiveItem(item);
- }
- }
- //Create an Skinned Item from a holding Item
- [ChatCommand("Gperk")]
- void Perking(BasePlayer player, string command, string[] args)
- {
- bool check = isAuth(player);
- if(check == false)
- return;
- ulong skin = Convert.ToUInt64(args[0]);
- var HeltItem = player.GetActiveItem();
- var Def = HeltItem.info;
- //var itemdisplay = Convert.ToString(args[0]);
- // var definition = ItemManager.FindItemDefinition(itemdisplay);
- if (Def != null)
- {
- //itemdisplay = definition.displayName.english;
- var item = ItemManager.Create(Def, 1, skin);
- if (item != null)
- player.GiveItem(item);
- }
- }
- [ChatCommand("ticket")]
- void ChatCommand(BasePlayer player, string command, string[] args)
- {
- if (args.Length == 0)
- {
- SendReply(player,"Syntax Error, /suggest YOURTEXT ");
- return;
- }
- string message = string.Join(" ", args);
- //for (var i = 1; i < args.Length; i++)
- // message += args[i] + (i == args.Length ? string.Empty : " ");
- var request = string.Format("{0}?adminList={1}&reporterName={2}&reporterId={3}&message={4}",
- requestUrl, string.Join("|", admins.ToArray()), player.displayName, player.UserIDString, message.ToString());
- webrequest.EnqueueGet(request, (code, response) =>
- {
- if (code != 200 || response == null)
- {
- SendReply(player , "Fail");
- return;
- }
- SendReply(player ,"Sent");
- }, this);
- }
- //Fix for Error in Entity Save List
- [ConsoleCommand("savelistfix")]
- private void consoleSaveFix(ConsoleSystem.Arg arg)
- {
- if (arg.Connection != null) return;
- BaseEntity.saveList.RemoveWhere(p => !p);
- BaseEntity.saveList.RemoveWhere(p => p == null);
- Puts("Attempted to remove nulls in save list if any were present");
- }
- #endregion
- #region Main Methods
- //Anti-Cheat Method. Notify on sight
- void OnSpotPlayer (BasePlayer source, BasePlayer target, float distance)
- {
- if(!permission.UserHasPermission(target.UserIDString, "Blinkarrow.Spot"))
- return;
- var PName = source.displayName;
- SendReply(target , "You have been spotted by :"+ PName);
- //Puts("onspot Works");
- }
- //SafeZone - GodMode
- private HitInfo OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo)
- {
- var ZoneID = "94462760";
- if (entity is BasePlayer)
- {
- var player = entity as BasePlayer;
- bool id = Convert.ToBoolean(ZoneManager?.Call("isPlayerInZone", ZoneID, player));
- if (id == true)
- {
- hitInfo.damageTypes.ScaleAll(0f);
- return hitInfo;
- }
- }
- return null;
- }
- //FX For fun
- void OnWeaponFired(BaseProjectile projectile, BasePlayer player, ItemModProjectile mod, ProtoBuf.ProjectileShoot projectiles)
- {
- if(player.displayName=="Ursa")
- {
- BaseEntity weaponEntity = player.GetHeldEntity();
- Effect.server.Run(("assets/bundled/prefabs/fx/survey_explosion.prefab"), weaponEntity, StringPool.closest, Vector3.zero, Vector3.zero);
- }
- }
- //Fx for fun + MainCode for Blinkarrow
- void OnPlayerAttack(BasePlayer player, HitInfo hitInfo)
- {
- Rust.DamageType explodeDamage = Rust.DamageType.Explosion;
- Rust.DamageType flameDamage = Rust.DamageType.Heat;
- Rust.DamageType elecDamage = Rust.DamageType.ElectricShock;
- if(player.displayName=="Ursa")
- {
- Vector3 temp = hitInfo.HitPositionWorld;
- //for(float i = 0F ; i <= "10.0".ToString().ToFloat() ; i = i + "0.7".ToString().ToFloat())
- //{
- var Exit = new Vector3(Convert.ToInt32(temp.x) , Convert.ToInt32(temp.y) , Convert.ToInt32(temp.z) );
- //Effect.server.Run(("assets/prefabs/locks/keypad/effects/lock.code.shock.prefab"),Exit);
- //Effect.server.Run(("assets/bundled/prefabs/fx/gas_explosion_small.prefab"), Exit);
- //Effect.server.Run(("assets/prefabs/npc/m2bradley/effects/bradley_explosion.prefab"), Exit);
- //Effect.server.Run(("assets/prefabs/npc/patrol helicopter/effects/heli_explosion.prefab"), Exit);
- Effect.server.Run(("assets/bundled/prefabs/fx/gestures/drink_vomit.prefab"), temp);
- dealDamage(hitInfo.HitPositionWorld, 1f, 1f, explodeDamage);
- //}
- }
- var weapon = hitInfo?.Weapon?.GetItem()?.GetHeldEntity() as BaseProjectile ?? null;
- if (!weapon) return;
- string ammoType = weapon.primaryMagazine.ammoType?.displayName.english ?? "Melee";
- string guiInfo;
- var newPos = GetGround(hitInfo.HitPositionWorld);
- if(!permission.UserHasPermission(player.UserIDString, "Blinkarrow.use"))
- return;
- if (!usingCorrectWeapon(player))
- {
- return;
- }
- // var RaycastHit = raycastHit();
- if( PlayerInfo.pressed == 1)
- {
- if (hitInfo.HitEntity == true)
- {
- if(player.displayName!="Ursa")
- {
- SendReply(player , "Cannot Blink on Buildings");
- return;
- }
- }
- }
- //Checks if the set Weapon is used - Has to be still active item on arrow land
- if (!IsBuildingAllowed(newPos, player))
- {
- SendReply(player , "Building Blockled!");
- return;
- }
- if (PlayerInfo.pressed==0)
- {
- return;
- }
- if (PlayerInfo.Cd==1)
- {
- SendReply(player , "Skill is on Cooldown");
- return;
- }
- if (PlayerInfo.pressed==1)
- {
- TeleportPlayerTo(player, newPos);
- enableCooldown(player);
- timer.Once(0.2f, () =>
- {
- PlayerInfo.pressed = 0;
- SendReply(player,"Disabled");
- });
- }
- return;
- }
- //Blinking / Teleport Forward (FunUse)
- void Blink (BasePlayer player)
- {
- if(!permission.UserHasPermission(player.UserIDString, "Blinkarrow.use"))
- return;
- var prefab = "assets/prefabs/npc/cargo plane/cargo_plane.prefab";
- var newPos = player.transform.position;
- //DroppedItem worldModel = ItemManager.CreateByItemID(3655341).Drop(newPos, Vector3.zero).GetComponent<DroppedItem>();
- //worldModel.GetComponent<Rigidbody>().mass =0.1f;
- //worldModel.GetComponent<Rigidbody>().rotation = Quaternion.Euler(player.GetNetworkRotation()*3.5f);
- //worldModel.GetComponent<Rigidbody>().AddForce(0f,0.6f,0.1f);
- var pY = player.transform.position.y;
- Vector3 Dest = player.transform.position + player.eyes.HeadForward() * 10f;
- //player.eyes.HeadForward().x = player.eyes.HeadForward().x + 5f;
- Dest.y = GetGround(Dest).y;
- Effect.server.Run(("assets/prefabs/plants/plantseed.effect.prefab"), Dest);
- player.MovePosition(Dest);
- player.ClientRPCPlayer(null, player, "ForcePositionTo", Dest);
- }
- void BlinkBack (BasePlayer player)
- {
- if(!permission.UserHasPermission(player.UserIDString, "Blinkarrow.use"))
- return;
- var prefab = "assets/prefabs/resource/paper.item.prefab";
- var newPos = player.transform.position;
- //DroppedItem worldModel = ItemManager.CreateByItemID(3655341).Drop(newPos, Vector3.zero).GetComponent<DroppedItem>();
- //worldModel.GetComponent<Rigidbody>().mass = 0.01f;
- //worldModel.GetComponent<Rigidbody>().rotation = Quaternion.Euler(player.GetNetworkRotation()*3f);
- //worldModel.GetComponent<Rigidbody>().AddForce(0f,0.6f,0.1f);
- var pY = player.transform.position.y;
- Vector3 Dest = player.transform.position + player.eyes.HeadForward() * -10f;
- //player.eyes.HeadForward().x = player.eyes.HeadForward().x + 5f;
- Dest.y = GetGround(Dest).y;
- Effect.server.Run(("assets/bundled/prefabs/fx/water/midair_splash.prefab"), Dest);
- player.MovePosition(Dest);
- player.ClientRPCPlayer(null, player, "ForcePositionTo", Dest);
- }
- void OnPlayerDisconnected(BasePlayer player, string reason)
- {
- string partreason = "Violation";
- bool b = reason.Contains(partreason);
- var posx = Convert.ToInt32(player.transform.position.x);
- var posy = Convert.ToInt32(player.transform.position.y);
- var posz = Convert.ToInt32(player.transform.position.z);
- var PosX = Convert.ToString(posx);
- var PosY = Convert.ToString(posy);
- var PosZ = Convert.ToString(posz);
- if (b)
- {
- LogToFile ( "Blinkarrow.txt", Convert.ToString(player.displayName)+"___"+Convert.ToString(player.userID) +"____"+ reason +"____"+PosX+","+PosY+","+PosZ,this);
- IPlayer player2 = null;
- player2 = covalence.Players.FindPlayerById(player.UserIDString);
- SendReport(player2,player);
- }
- }
- #endregion
- #region Helpers
- //Method to Deny violation while Blinking
- object OnPlayerViolation(BasePlayer player, AntiHackType type, float amount)
- {
- if(!permission.UserHasPermission(player.UserIDString, "Blinkarrow.use"))
- return null;
- Item activeItem = player.GetActiveItem(); //Checks for Crossbow + bow
- if (activeItem != null && activeItem.info.shortname == "flare")
- {
- return false;
- }
- return null;
- Puts("OnPlayerViolation works!");
- }
- void OnPlayerInput(BasePlayer player, InputState input)
- {
- var RunnerID = RunningMan?.Call("GetRunnerID");
- if(!permission.UserHasPermission(player.UserIDString, "Blinkarrow.use"))
- return;
- if (usingCorrectWeapon(player))
- {
- if (input.WasJustPressed(BUTTON.FIRE_THIRD))
- {
- if (PlayerInfo.Cd==0)
- {
- PlayerInfo.pressed = 1;
- SendReply(player,"Enabled");
- //GUICreate(player);
- return;
- }
- SendReply(player, "Skill is on Cooldown");
- }
- }
- if(input.WasJustPressed(BUTTON.FIRE_SECONDARY))
- {
- Item activeItem = player.GetActiveItem(); //Checks for Crossbow + bow
- if (activeItem != null && activeItem.info.shortname == "flare")
- {
- BlinkBack(player);
- }
- }
- if(input.WasJustPressed(BUTTON.FIRE_PRIMARY))
- {
- Item activeItem = player.GetActiveItem(); //Checks for Crossbow + bow
- if (activeItem != null && activeItem.info.shortname == "flare")
- {
- Blink(player);
- }
- }
- }
- private void dealDamage(Vector3 deathPos, float damage, float radius, Rust.DamageType type)
- {
- List<BaseCombatEntity> entitiesClose = new List<BaseCombatEntity>();
- List<BaseCombatEntity> entitiesNear = new List<BaseCombatEntity>();
- List<BaseCombatEntity> entitiesFar = new List<BaseCombatEntity>();
- Vis.Entities(deathPos, radius / 3, entitiesClose);
- Vis.Entities(deathPos, radius / 2, entitiesNear);
- Vis.Entities(deathPos, radius, entitiesFar);
- foreach (BaseCombatEntity entity in entitiesClose)
- {
- entity.Hurt(damage, type, null, true);
- // notifyPlayer(entity);
- }
- foreach (BaseCombatEntity entity in entitiesNear)
- {
- if (entitiesClose.Contains(entity)) return;
- entity.Hurt(damage / 2, type, null, true);
- // notifyPlayer(entity);
- }
- foreach (BaseCombatEntity entity in entitiesFar)
- {
- if (entitiesClose.Contains(entity) || entitiesNear.Contains(entity)) return;
- entity.Hurt(damage / 4, type, null, true);
- //notifyPlayer(entity);
- }
- }
- private static Vector3 GetGround(Vector3 position)
- {
- var height = TerrainMeta.HeightMap.GetHeight(position);
- position.y = System.Math.Max(position.y, height);
- return position;
- }
- private bool IsBuildingAllowed(Vector3 position, BasePlayer player)
- {
- var hits = Physics.OverlapSphere(position, 2f, triggerMask);
- foreach (var collider in hits)
- {
- var buildingPrivlidge = collider.GetComponentInParent<BuildingPrivlidge>();
- if (buildingPrivlidge == null) continue;
- if (!buildingPrivlidge.IsAuthed(player)) return false;
- }
- return true;
- }
- private static void TeleportPlayerTo(BasePlayer player, Vector3 position)
- {
- player.MovePosition(position);
- player.ClientRPCPlayer(null, player, "ForcePositionTo", position);
- //player.TransformChanged();
- }
- bool usingCorrectWeapon(BasePlayer player)
- { // todo - Move this into the config.
- Item activeItem = player.GetActiveItem(); //Checks for Crossbow + bow
- if (activeItem != null && activeItem.info.shortname == "crossbow") return true;
- if (activeItem != null && activeItem.info.shortname == "bow.hunting") return true;
- return false;
- }
- public void enableCooldown (BasePlayer player)
- {
- //GUIDestroy(player);
- if (PlayerInfo.Cd == 0)
- {
- PlayerInfo.Cd =1;
- timer.Once(time, () =>
- {
- finishCooldown();
- SendReply(player,"Ready");
- CuiHelper.DestroyUi(player, "Cooldown");
- });
- }
- }
- bool isAuth(BasePlayer player)
- {
- if (player.net.connection != null)
- if (player.net.connection.authLevel < 2 )
- return false;
- return true;
- }
- void finishCooldown()
- {
- PlayerInfo.Cd = 0;
- return;
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement