View Single Post
SpirT
Senior Member
Join Date: Sep 2018
Location: Portugal
Old 03-02-2020 , 06:17   Re: [CS:GO] Map Deleter
Reply With Quote #5

Quote:
Originally Posted by stickz View Post
This is how to create a plugin using arrays. It's only 150 lines and does the same thing as your 1250 lines.

Code:
#include <sourcemod>

#pragma newdecls required

#define CSGO_MAP_COUNT 54

char csgoMapName[CSGO_MAP_COUNT][] = {
	"ar_baggage",
	"ar_dizzy",
	"ar_lunacy",
	"ar_monastery",
	"ar_shoots",
	"coop_kasbah",
	"cs_agency",
	"cs_assault",
	"cs_downtown",
	"cs_insertion",
	"cs_italy",
	"cs_militia",
	"cs_motel",
	"cs_office",
	"cs_rush",
	"cs_siege",
	"cs_thunder",
	"de_ali",
	"de_aztec",
	"de_bank",
	"de_blackgold",
	"de_breach",
	"de_cache",
	"de_canals",
	"de_cbble",
	"de_chinatown",
	"de_dust",
	"de_dust2",
	"de_favela",
	"de_gwalior",
	"de_inferno",
	"de_lake",
	"de_mirage",
	"de_mist",
	"de_nuke",
	"de_overgrown",
	"de_overpass",
	"de_ruins",
	"de_safehouse",
	"de_seaside",
	"de_shortdust",
	"de_shortnuke",
	"de_shorttrain",
	"de_stmarc",
	"de_studio",
	"de_sugarcane",
	"de_train",
	"de_vertigo",
	"dz_blacksite",
	"dz_junglety",
	"dz_sirocco",
	"gd_cbble",
	"gd_rialto",
	"training1"
};

ConVar g_DeleteMap[CSGO_MAP_COUNT];

public Plugin myinfo = 
{
	name = "[SpirT] Map Delete",
	author = "SpirT",
	description = "Deletes the default CS:GO Maps after a steam update. Plugin will check for that maps when it loads",
	version = "2.0",
	url = ""
};

public void OnPluginStart()
{	
	for (int i = 0; i < CSGO_MAP_COUNT; i++)
	{
		// Create cvar name
		char cvarName[32];
		Format(cvarName, sizeof(cvarName), "spirt_mapdel_%s", csgoMapName[i]);
		
		// Create cvar description
		char cvarDesc[64];
		Format(cvarDesc, sizeof(cvarDesc), "Deletes all %s files", csgoMapName[i]);
		
		// Create cvar from name and description. Set bool min and max values
		g_DeleteMap[i] = CreateConVar(cvarName, "1", cvarDesc, _, true, 0.0, true, 1.0);
	}
	
	AutoExecConfig(true, "spirt.mapdelete", "SpirT");
}

public void OnMapStart()
{
	DeleteAllMaps();
	return;
}

void DeleteAllMaps()
{
	char fileExt[3][] = {
		"bsp",
		"nav",
		"jpg"
	};
		
	for (int i = 0; i < CSGO_MAP_COUNT; i++)
	{		
		if (g_DeleteMap[i].BoolValue)
		{		
			for (int f = 0; f < 3; f++)
			{
				// Create the file name string
				char fileName[32];
				Format(fileName, sizeof(fileName), "maps/%s.%s", csgoMapName[i], fileExt[f]);
				
				// Delete the file if it exists
				if (FileExists(fileName))
					DeleteFile(fileName);
			}
		}
	}
}
Thanks, I will update it to that code and credit you.

Best Regards,

SpirT.
__________________
SpirT is offline