Code:
#include <sourcemod>
public Plugin:myinfo = {
name = "Anti Café",
author = "p3tsin",
description = "Anti Café",
version = "1.0.0.0",
url = ""
}
new String:g_szWhiteListFile[PLATFORM_MAX_PATH]
new Handle:g_hWhiteList = INVALID_HANDLE
public OnPluginStart() {
BuildPath(Path_SM,g_szWhiteListFile,sizeof g_szWhiteListFile,"configs/anticafe_whitelist.txt")
}
public OnMapStart() {
if(g_hWhiteList != INVALID_HANDLE) {
CloseHandle(g_hWhiteList)
}
g_hWhiteList = CreateArray(64)
decl Handle:file
if(!FileExists(g_szWhiteListFile)) {
file = OpenFile(g_szWhiteListFile,"wt")
if(file != INVALID_HANDLE) {
WriteFileLine(file,"; List below SteamIDs starting with 777 or 775 that are known not to be cafe accounts.\n")
CloseHandle(file)
}
return
}
file = OpenFile(g_szWhiteListFile,"rt")
if(file != INVALID_HANDLE) {
decl String:data[128], String:steamid[64], len
while(!IsEndOfFile(file) && ReadFileLine(file,data,sizeof data)) {
if(data[0] == ';') {
continue
}
len = strlen(data)
if(data[len - 1] == '\n') {
data[--len] = 0
}
if(!len) {
continue
}
BreakString(data,steamid,sizeof steamid)
if(strncmp(steamid,"STEAM_",6) == 0) {
PushArrayString(g_hWhiteList,steamid)
}
}
CloseHandle(file)
}
}
public OnClientAuthorized(client,const String:authid[]) {
//if the SteamID is 7 digits long and the first 3 characters equal "777" or "775"
if(strlen(authid[10]) == 7 && (strncmp(authid[10],"777",3) == 0) || (strncmp(authid[10],"775",3) == 0)) {
if(FindStringInArray(g_hWhiteList,authid) == -1) {
PrintToChatAll("Player %N with SteamID %s has been kicked because of a cafe account. If you would like to be whitelisted please post at www.n00bunlimited.net",client,authid)
ServerCommand("kickid %d \"sorry, no cafe accounts allowed here\"",GetClientUserId(client))
}
else {
PrintToChatAll("Player %N with SteamID %s has been allowed to play here.",client,authid)
}
}
}
Untested. List clean SteamIDs in addons/sourcemod/configs/anticafe_whitelist.txt (created if doesnt exist), type in complete IDs and not just the number part.