SourcePawn:SMFAdmins
From Devicenull's Code
This provides admin access based on the group someone is in using the SMF forum software.
#pragma semicolon 1 #include <sourcemod> public Plugin:myinfo = { name = "SMF Admins", author = "devicenull", description = "Pulls access from smf forums", version = "1.0.0.0", url = "http://www.sourcemod.net/" }; public OnPluginStart() { LoadAdmins(); } public OnRebuildAdminCache(AdminCachePart:part) { if (part == AdminCache_Admins) { LoadAdmins(); } } LoadAdmins() { new String:error[256]; new Handle:db = SQL_DefConnect(error,sizeof(error)); if (db == INVALID_HANDLE) { LogToGame("Failed to connect: %s", error); return; } new Handle:query = SQL_Query(db, "SELECT th.value, gf.flags, mb.memberName \ FROM smf_themes AS th \ LEFT JOIN smf_members AS mb ON th.ID_MEMBER = mb.ID_MEMBER \ LEFT JOIN group_flags AS gf ON mb.ID_GROUP = gf.GroupID \ WHERE th.variable = 'CP1' \ AND gf.flags IS NOT NULL and th.value is not NULL and th.value != ''" ); if (query == INVALID_HANDLE) { SQL_GetError(db, error, sizeof(error)); LogToGame("Failed to query: %s", error); } else { CacheAdmins(query); CloseHandle(query); } CloseHandle(db); } CacheAdmins(Handle:query) { if (!SQL_HasResultSet(query)) { LogToGame("0 admins loaded"); return; } new String:placcess[32],String:plsteam[64],String:plname[64]; new count = SQL_GetRowCount(query); while (SQL_FetchRow(query)) { SQL_FetchString(query,0,plsteam,sizeof(plsteam)); SQL_FetchString(query,1,placcess,sizeof(placcess)); SQL_FetchString(query,2,plname,sizeof(plname)); LogToGame("Loading admin %s %s %s",plsteam,plname,placcess); new AdminId:adm = CreateAdmin(plname); BindAdminIdentity(adm, AUTHMETHOD_STEAM, plsteam); for (new i=0;i<strlen(placcess);++i) { switch (placcess[i]) { case 'b': { SetAdminFlag(adm,Admin_Reservation,true); } case 'c': { SetAdminFlag(adm,Admin_Kick,true); } case 'd': { SetAdminFlag(adm,Admin_Ban,true); SetAdminFlag(adm,Admin_Unban,true); } case 'e': { SetAdminFlag(adm,Admin_Slay,true); } case 'f': { SetAdminFlag(adm,Admin_Changemap,true); } case 'g': { SetAdminFlag(adm,Admin_Convars,true); } case 'h': { SetAdminFlag(adm,Admin_Config,true); } case 'i': { SetAdminFlag(adm,Admin_Chat,true); } case 'j': { SetAdminFlag(adm,Admin_Vote,true); } case 'k': { SetAdminFlag(adm,Admin_RCON,true); SetAdminFlag(adm,Admin_Root,true); SetAdminFlag(adm,Admin_Cheats,true); SetAdminFlag(adm,Admin_Password,true); } } } } LogToGame("%i admins loaded",count); }