C#:
using UnityEngine;
using System.Collections.Generic;
namespace Oxide.Plugins
{
[Info("xNoHorseRiding", "xNullPointer95", "1.1.0")]
[Description("Discord: https://discord.gg/rGm7VS5ERc")]
public class xNoHorseRiding : RustPlugin
{
const string BypassPermission = "xnohorseriding.bypass";
const float NotifyCooldownSeconds = 1.5f;
const float WorldTextDurationSeconds = 2.5f;
static readonly Color MainTextColor = new Color(1f, 0.25f, 0.25f, 1f);
readonly Dictionary<ulong, float> nextNotifyAt = new Dictionary<ulong, float>();
void Init()
{
permission.RegisterPermission(BypassPermission, this);
}
object CanMountEntity(BasePlayer player, BaseMountable mountable)
{
if (player == null || mountable == null)
{
return null;
}
BaseVehicle vehicleParent = mountable.VehicleParent();
if (!(mountable is RidableHorse) && !(vehicleParent is RidableHorse))
{
return null;
}
if (permission.UserHasPermission(player.UserIDString, BypassPermission))
{
return null;
}
float now = Time.realtimeSinceStartup;
if (nextNotifyAt.TryGetValue(player.userID, out float nextAllowedAt) && now < nextAllowedAt)
{
return false;
}
nextNotifyAt[player.userID] = now + NotifyCooldownSeconds;
BaseEntity anchor = vehicleParent ?? mountable;
Vector3 basePos = anchor.CenterPoint() + new Vector3(0f, 0.5f, 0f);
player.SendConsoleCommand("ddraw.text", WorldTextDurationSeconds, MainTextColor, basePos, "RIDING DISABLED");
return false;
}
void OnPlayerDisconnected(BasePlayer player, string reason)
{
if (player == null)
{
return;
}
nextNotifyAt.Remove(player.userID);
}
void Unload()
{
nextNotifyAt.Clear();
}
}
}