C#:
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
using System;
namespace Oxide.Plugins
{
[Info("BlockBoxPlacement", "wazzzup", "0.0.2", ResourceId = 2312)]
[Description("Blocks box and oven placement under foundations")]
public class BlockBoxPlacement : RustPlugin
{
void Loaded()
{
lang.RegisterMessages(messages, this);
}
Dictionary<string, string> messages = new Dictionary<string, string>()
{
{"cantPlace", "Deploying boxes and ovens under foundations is disabled"},
};
void OnEntitySpawned(BaseEntity entity, GameObject gameObject)
{
if (entity is BoxStorage || entity is BaseOven)
{
var player = BasePlayer.FindByID(entity.OwnerID);
if (player != null && Math.Round(Math.Abs(entity.transform.position.y - TerrainMeta.HeightMap.GetHeight(entity.transform.position)), 2) < 0.05)
{
foreach (var ent in BaseNetworkable.serverEntities.Where(p => p is BuildingBlock && p.ShortPrefabName.Contains("foundation") && Vector3.Distance(p.transform.position, entity.transform.position) <= 3).ToList())
{
SendReply(player, lang.GetMessage("cantPlace", this, player.UserIDString));
entity.Kill(BaseNetworkable.DestroyMode.None);
return;
}
}
}
}
}
}