I'm working on a simple plugin that mimics the default hostile warning in rust and could use a little help. The code I have right now will send a player a message when hostile state is changed. Things I need to figure out are how to only print this once and not on every hostile update, and I don't know how to call/draw the warning symbol in the top right corner. I would also like to make the warning last the duration of the hostile timer but am unsure how I would go about that.
Here's what I got so far:
using Facepunch;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using Oxide.Core;
using Oxide.Core.Configuration;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using Rust;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("HostileWarn", "Savage", "0.0.4")]
[Description("Hostile Chat Warning.")]
public class HostileWarn : RustPlugin
{
private void OnEntityMarkHostile(BasePlayer player, float duration)
{
if (player.IsValid() == true || player.IsHostile() == true)
{
SendMessage(player, "You Are Marked <color=red>Hostile</color>!");
return;
}
}
void SendMessage(BasePlayer player, string msg, params object[] args)
{
{
PrintToChat(player, msg, args);
return;
}
}
}
}