Quote:
Originally Posted by shavit
if OnFileReceive does what i think it does, this should work
Code:
#include <sourcemod>
#include <sdktools>
char block[][] =
{
"cfg",
"addons",
".dll",
".so",
".smx",
".txt",
};
public Action OnFileReceive(int client, const char[] sFile)
{
for(int i = 0; i < sizeof(block); i++)
{
if(StrContains(sFile, block[i], false) != -1)
{
return Plugin_Handled;
}
}
return Plugin_Continue;
}
untested ^
|
D-fens extension did something similar to this:
Code:
char g_szAllowedPaths[][] =
{
"downloads",
"maps",
"materials",
"particles",
"models",
"sound"
};
public Action OnFileReceive(int client, const char[] sFile)
{
bool bAllowed = false;
char getDir[10];
if (SplitString(sFile, "/", getDir, sizeof(getDir)) == -1)
{
SplitString(sFile, "\\", getDir, sizeof(getDir));
}
for(int i = 0; i < sizeof(g_szAllowedPaths); i++)
{
if(StrEqual(getDir, g_szAllowedPaths[i], false))
{
bAllowed = true;
}
}
if(!bAllowed)
{
if (client != 0){
LogMessage("%N attempted to upload illegal file %s", client, sFile);
}
return Plugin_Handled;
}
return Plugin_Continue;
}
public Action OnFileSend(int client, const char[] sFile)
{
bool bAllowed = false;
char getDir[10];
if (SplitString(sFile, "/", getDir, sizeof(getDir)) == -1)
{
SplitString(sFile, "\\", getDir, sizeof(getDir));
}
for(int i = 0; i < sizeof(g_szAllowedPaths); i++)
{
if(StrEqual(getDir, g_szAllowedPaths[i], false))
{
bAllowed = true;
}
}
if(!bAllowed)
{
if (client != 0){
LogMessage("%N attempted to download illegal file %s", client, sFile);
}
return Plugin_Handled;
}
return Plugin_Continue;
}