I am new to this scene, but not new to programming, albeit C# was 7 years ago.
Here is my first plugin, could use some feedback as Rust console is throwing a "expecting )" error and visual studio is showing no errors and I manually searched through to make sure all my parenthesis were matched and that I had all the required semi-colons.
using Oxide.Core.Libraries.Covalence;
using System.Collections.Generic;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("Home Marker", "Crat", "1.0")]
public class HomeMarker : CovalencePlugin
{
private Dictionary<string, GenericPosition> homes = new Dictionary<string, GenericPosition>();
private void Init()
{
Puts("Home Marker Plugin Initialized.");
}
[Command("sethome")]
private void CommandSetHome(IPlayer player, string cmd, string[] args)
{
homes[player.Id] = player.Position();
player.Reply("Home is set to current location.");
}
[Command("showhome")]
private void CommandShowHome(IPlayer player, string cmd, string[] args)
{
if (!homes.ContainsKey(player.Id))
{
player.Reply("You do not have a home set.");
return;
}
else
{
var homePosition = new Vector3(homes[player.Id].X, homes[player.Id].Y, homes[player.Id].Z);
MapMarkerGenericRadius mapMarker = (MapMarkerGenericRadius)GameManager.server.CreateEntity("assets/content/ui/gameui/gameui.hud.compassmapmarker.prefab", pos: homePosition, rot: default);
mapMarker.alpha = 1;
mapMarker.color1 = UnityEngine.Color.green;
mapMarker.color2 = UnityEngine.Color.green;
mapMarker.radius = 1f;
mapMarker.Spawn();
mapMarker.SendUpdate();
player.Reply("Base has been marked.");
}
}
}
}