Hello! I have extremely limited coding experience (1 course in the past 10 years), and just want the server to restart if Bradley is destroyed. I thought this would be an easy endeavor but a week and a half later I have a few lines of code that dont work. Any help or guidance is incredibly appreciated!
Here is my code:
using System;
using Oxide.Plugins;
namespace Oxide.Plugins
{
public class BradReset : RustPlugin
{
void OnEntityDestroy(BaseCombatEntity entity)
{
if (entity.GetType() == typeof(BradleyAPC))
{
ConsoleSystem.Run(ConsoleSystem.Option.Server.Quiet(), "global.restart");
}
}
}
}
Restart server on bradley death?Solved
try if (entity is BradleyAPC)
also try
void OnEntityDeath(BradleyAPC entity, HitInfo info)
{
Puts("OnEntityDeath works!");
ConsoleSystem.Run(ConsoleSystem.Option.Server.Quiet(), "global.restart");
} Unfortunately, that did not do it. It does not even seem to be triggering anything on Bradley's death either way. Going to keep troubleshooting, thank you for the help!!!!
Just out of curiousity, why?
I'm making a Rust Tower Defense map/server! I'll upload everything when it is ready for the community!
Merged post
Next step is to make server reset/wipe saved data on server restart, this way when the game is over the server can start anew, like a mini-game essentially.
Merged post
OK!!! I figure out the issue. I never put an [Info] section, I had no idea that was necessary....
This is the new code, works perfect
(I am 100% doing things that are unnecessary, so please excuse my coding ignorance.)
---------------------------
using System;
using Oxide.Plugins;
using Facepunch;
using Oxide.Core;
using System.Configuration;
using Unity;
namespace Oxide.Plugins
{
[Info("Bradley Dies and the Server Resets", "Produce", "1.0")]
public class BradReset : RustPlugin
{
void OnEntityDestroy(BradleyAPC entity)
{
if (entity is BradleyAPC)
{
Server.Command("restart 60 GAME-OVER");
}
}
}
}
Merged post
Next question would be, how the heck do you delete server saved files for a new game via this or another plugin?? I am 100% lost there.
You can not you would need to add that to your startup script.
I will try that! Thank you!!