AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Dump files ending with .dem (https://forums.alliedmods.net/showthread.php?t=57369)

Ramono 07-03-2007 14:00

Dump files ending with .dem
 
Hello,

I want to dump all the files ending on .dem (demo files) into a menu.
I can make the menu myself but not the function to get the filenames. and I would be happy if somone can create this for me.


Thanks for your help,
Ramon

stupok 07-03-2007 14:35

Re: Dump files ending with .dem
 
Try this:

Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "stupok69"

#define MAX_FILES 32
#define MAX_FILENAME 64

#define DEM_DIR "."

new dem_files[MAX_FILES][MAX_FILENAME]

public plugin_init()
{
        register_plugin(PLUGIN, VERSION, AUTHOR)
       
        new buffer[MAX_FILENAME], count
       
        new dh = open_dir(DEM_DIR, buffer, MAX_FILENAME-1)
       
        if(!dh) return PLUGIN_HANDLED
       
        if(containi(buffer, ".dem") != -1)
        {
                dem_files[count] = buffer
                count++
        }
       
        while(next_file(dh, buffer, MAX_FILENAME-1)
        {
                if(containi(buffer, ".dem") != -1)
                {
                        if(count < MAX_FILES)
                        {
                                dem_files[count] = buffer
                                count++
                        }
                        else
                        {
                                server_print("Too many .dem files!")
                                break
                        }
                }
        }
       
        close_dir(dh)
}


Ramono 07-03-2007 15:51

Re: Dump files ending with .dem
 
Works, Thank you!


All times are GMT -4. The time now is 21:26.

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