using System;
using System.Collections.Generic;
using System.Linq;
using Oxide.Core;
using Oxide.Core.Plugins;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("RecyclerAnywhere", "Author", "1.0.0")]
class RecyclerAnywhere : RustPlugin
{
void Init()
{
permission.RegisterPermission("recycleranywhere.use", this);
}
void OnServerInitialized()
{
foreach (var player in BasePlayer.activePlayerList)
{
CheckPlayer(player);
}
}
void CheckPlayer(BasePlayer player)
{
if (player != null && permission.UserHasPermission(player.UserIDString, "recycleranywhere.use"))
{
// Добавляем команду для установки перерабатывающего объекта в любом месте
cmd.AddChatCommand("setrecycler", player, cmdSetRecycler);
}
}
private void cmdSetRecycler(BasePlayer player, string command, string[] args)
{
if (player != null)
{
RaycastHit hit;
if (Physics.Raycast(player.eyes.position, player.eyes.HeadForward(), out hit, 10f))
{
BaseEntity entity = hit.GetEntity();
if (entity != null)
{
BaseEntity recycler = GameManager.server.CreateEntity("assets/prefabs/autoturret/recycler_static.prefab", hit.point, Quaternion.identity);
if (recycler != null)
{
recycler.Spawn();
SendReply(player, "Recycler placed successfully!");
}
}
}
}
}
void OnPlayerInit(BasePlayer player)
{
CheckPlayer(player);
}
void Unload()
{
foreach (var player in BasePlayer.activePlayerList)
{
if (player != null)
{
cmd.RemoveChatCommand("setrecycler", player);
}
}
}
}
}