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

N/U PasteBin is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.