plugins/admin-flatfile/admin-flatfile.sp
author Matt Schubert <schubertm@gmail.com>
Fri Sep 12 20:36:53 2008 +0000 (2008-09-12)
changeset 2280 156053eea73c
parent 1952 b7aa2b626807
child 2289 44045ead61cd
permissions -rw-r--r--
Fixed amb1929 - Banning via console should now work properly
ds@1952
     1
/**
ds@1952
     2
 * vim: set ts=4 :
ds@1952
     3
 * =============================================================================
ds@1952
     4
 * SourceMod Admin File Reader Plugin
ds@1952
     5
 * Manages the standard flat files for admins.  This is the file to compile.
ds@1952
     6
 *
ds@1952
     7
 * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
ds@1952
     8
 * =============================================================================
ds@1952
     9
 *
ds@1952
    10
 * This program is free software; you can redistribute it and/or modify it under
ds@1952
    11
 * the terms of the GNU General Public License, version 3.0, as published by the
ds@1952
    12
 * Free Software Foundation.
ds@1952
    13
 * 
ds@1952
    14
 * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1952
    15
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1952
    16
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
ds@1952
    17
 * details.
ds@1952
    18
 *
ds@1952
    19
 * You should have received a copy of the GNU General Public License along with
ds@1952
    20
 * this program.  If not, see <http://www.gnu.org/licenses/>.
ds@1952
    21
 *
ds@1952
    22
 * As a special exception, AlliedModders LLC gives you permission to link the
ds@1952
    23
 * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1952
    24
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1952
    25
 * by the Valve Corporation.  You must obey the GNU General Public License in
ds@1952
    26
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
ds@1952
    27
 * this exception to all derivative works.  AlliedModders LLC defines further
ds@1952
    28
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1952
    29
 * or <http://www.sourcemod.net/license.php>.
ds@1952
    30
 *
ds@1952
    31
 * Version: $Id$
ds@1952
    32
 */
ds@1952
    33
ds@1952
    34
/* We like semicolons */
ds@1952
    35
#pragma semicolon 1
ds@1952
    36
ds@1952
    37
#include <sourcemod>
ds@1952
    38
ds@1952
    39
public Plugin:myinfo = 
ds@1952
    40
{
ds@1952
    41
	name = "Admin File Reader",
ds@1952
    42
	author = "AlliedModders LLC",
ds@1952
    43
	description = "Reads admin files",
ds@1952
    44
	version = SOURCEMOD_VERSION,
ds@1952
    45
	url = "http://www.sourcemod.net/"
ds@1952
    46
};
ds@1952
    47
ds@1952
    48
/** Various parsing globals */
ds@1952
    49
new bool:g_LoggedFileName = false;			/* Whether or not the file name has been logged */
ds@1952
    50
new g_ErrorCount = 0;						/* Current error count */
ds@1952
    51
new g_IgnoreLevel = 0;						/* Nested ignored section count, so users can screw up files safely */
ds@1952
    52
new g_CurrentLine = 0;						/* Current line we're on */
ds@1952
    53
new String:g_Filename[PLATFORM_MAX_PATH];	/* Used for error messages */
ds@1952
    54
ds@1952
    55
#include "admin-overrides.sp"
ds@1952
    56
#include "admin-groups.sp"
ds@1952
    57
#include "admin-users.sp"
ds@1952
    58
#include "admin-simple.sp"
ds@1952
    59
ds@1952
    60
public OnRebuildAdminCache(AdminCachePart:part)
ds@1952
    61
{
ds@1952
    62
	if (part == AdminCache_Overrides)
ds@1952
    63
	{
ds@1952
    64
		ReadOverrides();
ds@1952
    65
	} else if (part == AdminCache_Groups) {
ds@1952
    66
		ReadGroups();
ds@1952
    67
	} else if (part == AdminCache_Admins) {
ds@1952
    68
		ReadUsers();
ds@1952
    69
		ReadSimpleUsers();
ds@1952
    70
	}
ds@1952
    71
}
ds@1952
    72
ds@1952
    73
ParseError(const String:format[], {Handle,String,Float,_}:...)
ds@1952
    74
{
ds@1952
    75
	decl String:buffer[512];
ds@1952
    76
	
ds@1952
    77
	if (!g_LoggedFileName)
ds@1952
    78
	{
ds@1952
    79
		LogError("Error(s) detected parsing %s", g_Filename);
ds@1952
    80
		g_LoggedFileName = true;
ds@1952
    81
	}
ds@1952
    82
	
ds@1952
    83
	VFormat(buffer, sizeof(buffer), format, 2);
ds@1952
    84
	
ds@1952
    85
	LogError(" (line %d) %s", g_CurrentLine, buffer);
ds@1952
    86
	
ds@1952
    87
	g_ErrorCount++;
ds@1952
    88
}
ds@1952
    89
ds@1952
    90
InitGlobalStates()
ds@1952
    91
{
ds@1952
    92
	g_ErrorCount = 0;
ds@1952
    93
	g_IgnoreLevel = 0;
ds@1952
    94
	g_CurrentLine = 0;
ds@1952
    95
	g_LoggedFileName = false;
ds@1952
    96
}