Jump to content

Rust Server Wiper (Single Button with Scheduling) - C# Script [Windows and Linux]


MarkMozza

Recommended Posts

 Rust Server Wiper

Allows your to wipe your rust server using a single button. You can also use this along with the Scheduler, you can choose to do a weekly map wipe with a monthly player wipe.

Note: Code could be better but works fine. I will make it better in the future.

Support: https://discord.gg/RmMmh7K

Installation

1. Create a new Custom Script.

  • Script Engine: C#
  • Event: Custom Icon
  • Allow Scheduling: True
  • Prompt for Variable Values: True
  • Stop Service Before Executing: True
  • Fill in remaining details

2. Copy the below code into the text area.

using System;
using System.IO;
using TCAdmin;

public class CSharpScript : CSharpScriptBase
{
  
  public void Main() {
    
    Script.WriteToConsole("Rust Wiper Starting.");
    
    // All Player Info
    var serverIdentity = (string)ThisService.Variables["Identity"];
    
    // Set Folder Paths
    var playerBP = Path.Combine(ThisService.RootDirectory, "server\\"+serverIdentity+"\\player.blueprints.3.db");
    var playerDeaths = Path.Combine(ThisService.RootDirectory, "server\\"+serverIdentity+"\\player.deaths.3.db");
    var playerIdentities = Path.Combine(ThisService.RootDirectory, "server\\"+serverIdentity+"\\player.identities.3.db");
    var playerStates = Path.Combine(ThisService.RootDirectory, "server\\"+serverIdentity+"\\player.states.191.db");
    var playerTokens = Path.Combine(ThisService.RootDirectory, "server\\"+serverIdentity+"\\player.tokens.db");

    if((string)ThisService.Variables["deleteblueprints"]=="yes" & File.Exists(playerBP)) {
      	Script.WriteToConsole("Deleting Blueprints...");
      	File.Delete(playerBP);
    }
    
    if((string)ThisService.Variables["deletedeaths"]=="yes" & File.Exists(playerDeaths)) {
      	Script.WriteToConsole("Deleting Deaths...");
      	File.Delete(playerDeaths);
    }
    
    if((string)ThisService.Variables["deleteidentities"]=="yes" & File.Exists(playerIdentities)) {
      	Script.WriteToConsole("Deleting Identities...");
    	File.Delete(playerIdentities);
    }
    
    if((string)ThisService.Variables["deletestates"]=="yes" & File.Exists(playerStates)) {
      	Script.WriteToConsole("Deleting States...");
      	File.Delete(playerStates);
    }
    
    if((string)ThisService.Variables["deletetokens"]=="yes" & File.Exists(playerTokens)) {
      	Script.WriteToConsole("Deleting Tokens...");
      	File.Delete(playerTokens);
    }
    
    // This will wipe map
    if((string)ThisService.Variables["deletemap"]=="yes") {
      	Script.WriteToConsole("Deleting Map...");
    	var mapPath = Path.Combine(ThisService.RootDirectory, "server\\"+serverIdentity);
    	var mapFiles = Directory.EnumerateFiles(mapPath, "*.map*", SearchOption.AllDirectories);
    	foreach (var item in mapFiles) { File.Delete(item); }
        var savFiles = Directory.EnumerateFiles(mapPath, "*.sav*", SearchOption.AllDirectories);
    	foreach (var item in savFiles) { File.Delete(item); }
    }
    
    Script.WriteToConsole("Rust Wiper Completed.");
    
  }
  
}

 

3. Setup Thw Following Variables.

  • Variable Names: deleteblueprints, deletedeaths, deleteidentities, deletestates, deletetokens, deletemap
  • Script Parameter: True
  • Admin Access: True
  • Sub Admin: True
  • Reseller: True
  • User Access: True
  • Server Owner: True
  • Item Type: Checkbox
  • On Value: yes
  • Off Value: no

4. Save & Done!

 

You're welcome

Edited by MarkMozza
Link to comment
Share on other sites

To make this script compatible with Linux you can change Path.Combine so each folder or file is a separate parameter. For example:

Path.Combine(ThisService.RootDirectory, "server\\"+serverIdentity+"\\player.states.191.db");

changes to:

 

Path.Combine(ThisService.RootDirectory, "server", serverIdentity, "player.states.191.db");
Link to comment
Share on other sites

This is the updated script that supports both Windows and Linux.

using System;
using System.IO;
using TCAdmin;

public class CSharpScript : CSharpScriptBase
{
  
  public void Main() {
    
    Script.WriteToConsole("Rust Wiper Starting.");
    
    // All Player Info
    var serverIdentity = (string)ThisService.Variables["Identity"];
    
    // Set Folder Paths
    var playerBP = Path.Combine(ThisService.RootDirectory, "server", serverIdentity, "player.blueprints.3.db");
    var playerDeaths = Path.Combine(ThisService.RootDirectory, "server", serverIdentity,"player.deaths.3.db");
    var playerIdentities = Path.Combine(ThisService.RootDirectory, "server", serverIdentity, "player.identities.3.db");
    var playerStates = Path.Combine(ThisService.RootDirectory, "server", serverIdentity, "player.states.191.db");
    var playerTokens = Path.Combine(ThisService.RootDirectory, "server", serverIdentity, "player.tokens.db");

    if((string)ThisService.Variables["deleteblueprints"]=="yes" & File.Exists(playerBP)) {
      	Script.WriteToConsole("Deleting Blueprints...");
      	File.Delete(playerBP);
    }
    
    if((string)ThisService.Variables["deletedeaths"]=="yes" & File.Exists(playerDeaths)) {
      	Script.WriteToConsole("Deleting Deaths...");
      	File.Delete(playerDeaths);
    }
    
    if((string)ThisService.Variables["deleteidentities"]=="yes" & File.Exists(playerIdentities)) {
      	Script.WriteToConsole("Deleting Identities...");
    	File.Delete(playerIdentities);
    }
    
    if((string)ThisService.Variables["deletestates"]=="yes" & File.Exists(playerStates)) {
      	Script.WriteToConsole("Deleting States...");
      	File.Delete(playerStates);
    }
    
    if((string)ThisService.Variables["deletetokens"]=="yes" & File.Exists(playerTokens)) {
      	Script.WriteToConsole("Deleting Tokens...");
      	File.Delete(playerTokens);
    }
    
    // This will wipe map
    if((string)ThisService.Variables["deletemap"]=="yes") {
      	Script.WriteToConsole("Deleting Map...");
    	var mapPath = Path.Combine(ThisService.RootDirectory, "server", serverIdentity);
    	var mapFiles = Directory.EnumerateFiles(mapPath, "*.map*", SearchOption.AllDirectories);
    	foreach (var item in mapFiles) { File.Delete(item); }
        var savFiles = Directory.EnumerateFiles(mapPath, "*.sav*", SearchOption.AllDirectories);
    	foreach (var item in savFiles) { File.Delete(item); }
    }
    
    Script.WriteToConsole("Rust Wiper Completed.");
    
  }
  
}

 

Link to comment
Share on other sites

  • LFA changed the title to Rust Server Wiper (Single Button with Scheduling) - C# Script [Windows and Linux]
  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Who's Online   0 Members, 0 Anonymous, 82 Guests (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Terms of Use