AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [CS:GO] Map Deleter (https://forums.alliedmods.net/showthread.php?t=321822)

SpirT 03-01-2020 13:05

[CS:GO] Map Deleter
 
3 Attachment(s)
Map Deleter

by SpirT



What is this?
A Map Deleter. This allow you to AUTO-DELETE any map you want from the folder 'gamemode_folder/maps/' folder when your server boots.

Requirements
- SourceMod Installed on your server (plugin was tested on 1.10 build 6482)
- MetaMod Installed on your server (plugin was tested on 1.9 build 971)

Installation
  • Upload all files to your server
  • Restart your server / change map / type this command in your server console: 'sm plugins reload spirt_mapdelete'
  • Config file is automatically created on 'csgo/cfg/SpirT/spirt.mapdelete.cfg'
  • Add a file of a map per line for example 'de_dust2.bsp' or 'de_dust2.nav' without the ''

ToDo List
  • Nothing for now

Releases
-------------
1.1:
-> Added a config file to delete the desired maps
-> Deleted all existing ConVars and added one to enable / disable Map Delete Function
-> Compiled with version 1.10.0 build 6482
-------------
1.0.0:
-> Plugin Release
-------------

For any issue or bug, reply to the post or contact me on steam.

Groven 03-01-2020 13:26

Re: [CS:GO] Map Deleter
 
Thanks :)

zwolofmeister 03-01-2020 17:47

Re: [CS:GO] Map Deleter
 
bro I dont wanna be that guy, but this is hoooooooooooorrriiibleeeee, why not just make a loop? instead of 1286 lines ????????????????

stickz 03-01-2020 22:50

Re: [CS:GO] Map Deleter
 
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);
                        }
                }
        }
}


SpirT 03-02-2020 06:17

Re: [CS:GO] Map Deleter
 
Quote:

Originally Posted by stickz (Post 2685548)
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.

Ilusion9 03-02-2020 06:36

Re: [CS:GO] Map Deleter
 
Check if the current map is not in that list. Create config option where users can put their maps name to be removed.

SpirT 03-02-2020 16:42

Re: [CS:GO] Map Deleter
 
Quote:

Originally Posted by Ilusion9 (Post 2685576)
Check if the current map is not in that list. Create config option where users can put their maps name to be removed.

Added that to ToDo list 😁.

Ilusion9 03-02-2020 17:11

Re: [CS:GO] Map Deleter
 
Edited.
See my post with github link.

SpirT 03-03-2020 17:24

Re: [CS:GO] Map Deleter
 
Quote:

Originally Posted by Ilusion9 (Post 2685648)
Put delete_maps in configs.

Thanks, I'll atatch those later to the main post and credit u. Thanks one more time

Ilusion9 03-04-2020 03:23

Re: [CS:GO] Map Deleter
 
I made a github repository. Users can delete maps and configs.
https://github.com/Ilusion9/delete-files-sm

Your plugin idea was good, but the code is ugly ...


All times are GMT -4. The time now is 18:04.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.