AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   delete files with a specific prefix (https://forums.alliedmods.net/showthread.php?t=224945)

faki 08-30-2013 06:12

delete files with a specific prefix
 
I need to delete some maps in my maps folder with amxx, i need to do that:
When maps is with czero_ prefix - delete automaticaly after XX seconds (by task)
Can someone help me?

Arkshine 08-30-2013 06:21

Re: delete files with a specific prefix
 
Explain instead what you want really to do, what is this czero_ maps, etc.
Because making a plugin to delete maps after X seconds doesn't make sense.

faki 08-30-2013 06:25

Re: delete files with a specific prefix
 
I hosting public servers but someone uploaded custom maps and i dont like this.
I need plugin to delete all maps with specific prefix
cz_
aim_
fy_
and etc...
After XX seconds (by task)

TheDS1337 08-30-2013 07:11

Re: delete files with a specific prefix
 
Try this: UNTESTED
Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN_NAME "[AMXx] Delete Maps By Prefix" #define PLUGIN_VERSION "1.0" new const g_MapsPrefix[][] = {     "cscz_"     "aim_",     "fy_" }; new g_CvarDeleteTime; public plugin_init() {     register_plugin(PLUGIN_NAME, PLUGIN_VERSION, "DeagLe.Studio");         g_CvarDeleteTime = register_cvar("md_delete_time", "10.0");         set_task(get_pcvar_float(g_CvarDeleteTime), "Task_DeleteMaps"); } public Task_DeleteMaps() {     static MapName[32], CurrentMapName[32], Patch[64];     get_mapname(CurrentMapName, charsmax(CurrentMapName));         new Position, Length, Iterator;         while (read_dir("maps", Position++, MapName, charsmax(MapName), Length))     {         for (Iterator = 0; Iterator < sizeof g_MapsPrefix; Iterator++)         {             if (equal(MapName, g_MapsPrefix[Iterator], strlen(g_MapsPrefix[Iterator])) && !equal(MapName, CurrentMapName))             {                 formatex(Patch, charsmax(Patch), "maps/%s", MapName);                 delete_file(Patch);             }         }     } }

Arkshine 08-30-2013 07:18

Re: delete files with a specific prefix
 
Are you going again to start to post random shit code ?

@faki, if you an hoster, what the hell you need a Pawn plugin ? Are you going to install this plugin on all servers ? And what about if admins remove the plugin ? This doesn't make sense, just do a bash script or something similar.


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

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