Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 14 additions & 76 deletions addons/sourcemod/scripting/include/autoexecconfig.inc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* AutoExecConfig
*
*
* Copyright (C) 2013-2017 Impact
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -16,7 +16,10 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/


#pragma semicolon 1
#pragma newdecls required

#if defined _autoexecconfig_included
#endinput
#endif
Expand All @@ -27,43 +30,33 @@
#include <sourcemod>

#define AUTOEXECCONFIG_VERSION "0.1.5"
#define AUTOEXECCONFIG_URL "https://forums.alliedmods.net/showthread.php?t=204254"
#define AUTOEXECCONFIG_URL "https://forums.alliedmods.net/showthread.php?t=204254"

// Append
#define AUTOEXEC_APPEND_BAD_FILENAME 0
#define AUTOEXEC_APPEND_FILE_NOT_FOUND 1
#define AUTOEXEC_APPEND_BAD_HANDLE 2
#define AUTOEXEC_APPEND_SUCCESS 3



// Find
#define AUTOEXEC_FIND_BAD_FILENAME 10
#define AUTOEXEC_FIND_FILE_NOT_FOUND 11
#define AUTOEXEC_FIND_BAD_HANDLE 12
#define AUTOEXEC_FIND_NOT_FOUND 13
#define AUTOEXEC_FIND_SUCCESS 14



// Clean
#define AUTOEXEC_CLEAN_FILE_NOT_FOUND 20
#define AUTOEXEC_CLEAN_BAD_HANDLE 21
#define AUTOEXEC_CLEAN_SUCCESS 22



// General
#define AUTOEXEC_NO_CONFIG 30



// Formatter
#define AUTOEXEC_FORMAT_BAD_FILENAME 40
#define AUTOEXEC_FORMAT_SUCCESS 41



// Global variables
static char g_sConfigFile[PLATFORM_MAX_PATH];
static char g_sRawFileName[PLATFORM_MAX_PATH];
Expand All @@ -75,7 +68,6 @@ static Handle g_hPluginHandle = null;
static bool g_bCreateDirectory = false;
static int g_bCreateDirectoryMode = FPERM_U_READ|FPERM_U_WRITE|FPERM_U_EXEC|FPERM_G_READ|FPERM_G_EXEC|FPERM_O_READ|FPERM_O_EXEC;


// Workaround for now
static int g_iLastFindResult;
static int g_iLastAppendResult;
Expand All @@ -84,7 +76,7 @@ static int g_iLastAppendResult;
stock void AutoExecConfig_EC_File()
{
// Execute and clean the cfg file
AutoExecConfig_ExecuteFile();
AutoExecConfig_ExecuteFile();
AutoExecConfig_CleanFile();
}
stock void AutoExecConfig_Setup(char[] file, bool create = true)
Expand All @@ -93,7 +85,6 @@ stock void AutoExecConfig_Setup(char[] file, bool create = true)
AutoExecConfig_SetFile(file);
}


/**
* Returns the last result from the parser.
*
Expand All @@ -104,10 +95,6 @@ stock int AutoExecConfig_GetFindResult()
return g_iLastFindResult;
}





/**
* Returns the last result from the appender.
*
Expand All @@ -118,7 +105,6 @@ stock int AutoExecConfig_GetAppendResult()
return g_iLastAppendResult;
}


/**
* Set if the config file should be created by the autoexecconfig include itself if it doesn't exist.
*
Expand All @@ -130,10 +116,9 @@ stock void AutoExecConfig_SetCreateFile(bool create)
g_bCreateFile = create;
}


/**
* Set if the config file's folder should be created by the autoexecconfig include itself if it doesn't exist.
* Note: Must be used before AutoExecConfig_SetFile as the potential creation of it happens there
* Note: Must be used before AutoExecConfig_SetFile as the potential creation of it happens there
*
* @param create True if config file should be created, false otherwise.
* @param mode Folder permission mode, default is u=rwx,g=rx,o=rx.
Expand All @@ -145,7 +130,6 @@ stock void AutoExecConfig_SetCreateDirectory(bool create, int mode=FPERM_U_READ|
g_bCreateDirectoryMode = mode;
}


/**
* Returns if the config file should be created if it doesn't exist.
*
Expand All @@ -156,7 +140,6 @@ stock bool AutoExecConfig_GetCreateFile()
return g_bCreateFile;
}


/**
* Set the plugin for which the config file should be created.
* Set to null to use the calling plugin.
Expand All @@ -170,7 +153,6 @@ stock void AutoExecConfig_SetPlugin(Handle plugin)
g_hPluginHandle = plugin;
}


/**
* Returns the plugin's handle for which the config file is created.
*
Expand All @@ -181,7 +163,6 @@ stock Handle AutoExecConfig_GetPlugin()
return g_hPluginHandle;
}


/**
* Set the global autoconfigfile used by functions of this file.
* Note: does not support subfolders like folder1/folder2
Expand All @@ -203,11 +184,6 @@ stock bool AutoExecConfig_SetFile(char[] file, char[] folder="sourcemod")
return AutoExecConfig_FormatFileName(g_sConfigFile, sizeof(g_sConfigFile), folder) == AUTOEXEC_FORMAT_SUCCESS;
}






/**
* Get the formatted autoconfigfile used by functions of this file.
*
Expand All @@ -230,11 +206,6 @@ stock bool AutoExecConfig_GetFile(char[] buffer,int size)
return false;
}






/**
* Creates a convar and appends it to the autoconfigfile if not found.
* FCVAR_DONTRECORD will be skipped.
Expand Down Expand Up @@ -268,7 +239,7 @@ stock ConVar AutoExecConfig_CreateConVar(const char[] name, const char[] default
// We only add this convar if it doesn't exist, or the file doesn't exist and it should be auto-generated
if (g_iLastFindResult == AUTOEXEC_FIND_NOT_FOUND || (g_iLastFindResult == AUTOEXEC_FIND_FILE_NOT_FOUND && g_bCreateFile))
{
g_iLastAppendResult = AutoExecConfig_AppendValue(name, defaultValue, description, flags, hasMin, min, hasMax, max);
g_iLastAppendResult = AutoExecConfig_AppendValue(name, defaultValue, description, hasMin, min, hasMax, max);
}
}

Expand All @@ -277,9 +248,6 @@ stock ConVar AutoExecConfig_CreateConVar(const char[] name, const char[] default
return CreateConVar(name, defaultValue, description, flags, hasMin, min, hasMax, max);
}




/**
* Executes the autoconfigfile and adds it to the OnConfigsExecuted forward.
* If we didn't create it ourselves we let SourceMod create it.
Expand All @@ -288,14 +256,10 @@ stock ConVar AutoExecConfig_CreateConVar(const char[] name, const char[] default
*/
stock void AutoExecConfig_ExecuteFile()
{
// Only let sourcemod create the file, if we didn't do that already.
// Only let sourcemod create the file, if we didn't do that already.
AutoExecConfig(!g_bCreateFile, g_sRawFileName, g_sFolderPath);
}





/**
* Formats a autoconfigfile, prefixes path and adds .cfg extension if missing.
*
Expand Down Expand Up @@ -359,25 +323,19 @@ stock static int AutoExecConfig_FormatFileName(char[] buffer, int size, char[] f
return AUTOEXEC_FORMAT_SUCCESS;
}






/**
* Appends a convar to the global autoconfigfile
*
* @param name Name of new convar.
* @param defaultValue String containing the default value of new convar.
* @param description Optional description of the convar.
* @param flags Optional bitstring of flags determining how the convar should be handled. See FCVAR_* constants for more details.
* @param hasMin Optional boolean that determines if the convar has a minimum value.
* @param min Minimum floating point value that the convar can have if hasMin is true.
* @param hasMax Optional boolean that determines if the convar has a maximum value.
* @param max Maximum floating point value that the convar can have if hasMax is true.
* @return Returns one of the AUTOEXEC_APPEND values
*/
stock int AutoExecConfig_AppendValue(const char[] name, const char[] defaultValue, const char[] description, int flags, bool hasMin, float min, bool hasMax, float max)
stock int AutoExecConfig_AppendValue(const char[] name, const char[] defaultValue, const char[] description, bool hasMin, float min, bool hasMax, float max)
{
// No config set
if (strlen(g_sConfigFile) < 1)
Expand Down Expand Up @@ -474,19 +432,14 @@ stock int AutoExecConfig_AppendValue(const char[] name, const char[] defaultValu
fFile.WriteLine(writebuffer);


fFile.Close();
fFile.Close();

return AUTOEXEC_APPEND_SUCCESS;
}

return AUTOEXEC_APPEND_FILE_NOT_FOUND;
}






/**
* Returns a convar's value from the global autoconfigfile
*
Expand Down Expand Up @@ -582,7 +535,7 @@ stock int AutoExecConfig_FindValue(const char[] cvar, char[] value, int size, bo
}


// Get the start of the cvar,
// Get the start of the cvar,
if ( (cvarend = StrContains(readbuffer, " ")) == -1 || cvarend >= valuestart)
{
continue;
Expand Down Expand Up @@ -623,19 +576,14 @@ stock int AutoExecConfig_FindValue(const char[] cvar, char[] value, int size, bo
}
}

fFile.Close();
fFile.Close();
return AUTOEXEC_FIND_NOT_FOUND;
}


return AUTOEXEC_FIND_FILE_NOT_FOUND;
}






/**
* Cleans the global autoconfigfile from too much spaces
*
Expand Down Expand Up @@ -738,11 +686,6 @@ stock int AutoExecConfig_CleanFile()
return AUTOEXEC_CLEAN_SUCCESS;
}






/**
* Returns how many times the given char occures in the given string.
*
Expand All @@ -765,11 +708,6 @@ stock static int GetCharCountInStr(int character, const char[] str)
return count;
}






#pragma deprecated
stock bool AutoExecConfig_CacheConvars()
{
Expand Down
18 changes: 9 additions & 9 deletions addons/sourcemod/scripting/include/sourcebans.inc
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
#pragma semicolon 1
#pragma newdecls required

#if defined _sourcebans_included
#endinput
#endinput
#endif
#define _sourcebans_included

public SharedPlugin:__pl_sourcebans =
public SharedPlugin __pl_sourcebans =
{
name = "SourceBans",
file = "sourcebans.smx",
#if defined REQUIRE_PLUGIN
required = 1
required = 1
#else
required = 0
required = 0
#endif
};

Expand All @@ -21,16 +24,13 @@ public __pl_sourcebans_SetNTVOptional()
}
#endif


/*********************************************************
* Ban Player from server
*
* @param client The client index of the admin who is banning the client
* @param target The client index of the player to ban
* @param time The time to ban the player for (in minutes, 0 = permanent)
* @param reason The reason to ban the player from the server
* @noreturn
* @noreturn
*********************************************************/
native SBBanPlayer(client, target, time, String:reason[]);

//Yarr!
native void SBBanPlayer(int client, int target, int time, char[] reason);
Loading