Hello!
Please tell me how to write the full path of a file into an array. Example: sound/hit/hit1.wav
I managed to write only the file name.
PHP Code:
#include <sourcemod>
#define MAX_PATH_LENGTH 128
ArrayList g_hGlobalArray;
...
public OnPluginStart()
{
RegConsoleCmd("test", ShowFiles2, "");
new Handle:dir = OpenDirectory("sound/hit/");
g_hGlobalArray = new ArrayList(ByteCountToCells(128));
if (dir != INVALID_HANDLE)
{
decl String:Name[MAX_PATH_LENGTH];
new FileType:type;
while (ReadDirEntry(dir, Name, MAX_PATH_LENGTH, type))
{
if (type == FileType_File)
g_hGlobalArray.PushString(Name);
}
CloseHandle(dir);
}
}
public Action ShowFiles2(client, args)
{
int iSize;
char szBuffer[MAX_PATH_LENGTH];
iSize = g_hGlobalArray.Length;
PrintToServer("Size(GlobalArray) = %i", iSize);
for (new i = 0; i < iSize; ++i)
{
g_hGlobalArray.GetString(i, szBuffer, sizeof(szBuffer));
PrintToServer("GlobalArray[%i] = '%s'", i, szBuffer);
}
}