Try it
PHP Code:
#include <sourcemod>
#pragma semicolon 1
#define PLUGIN_VERSION "1.0"
public Plugin:myinfo =
{
name = "Set mp_force_pick_time for steamids",
author = "CamerDisco/Stevo.TVR",
description = "The code is from whitelist plugin by Stevo.TVR",
version = PLUGIN_VERSION,
url = ""
}
// maximum SteamIDs the plugin can handle; increase value as needed
#define WHITELIST_MAX 255
new String:whitelist[WHITELIST_MAX][64];
new listlen;
public OnPluginStart()
{
RegAdminCmd("sm_cvar_reload", CommandReload, ADMFLAG_GENERIC, "Reloads server whitelist");
RegAdminCmd("sm_cvar_list", CommandList, ADMFLAG_GENERIC, "List all SteamIDs in whitelist");
RegAdminCmd("sm_cvar_add", CommandAdd, ADMFLAG_CONVARS, "Adds a SteamID to the whitelist");
LoadList();
}
public OnClientPostAdminCheck(client)
{
if(!IsFakeClient(client))
{
new String:auth[64];
GetClientAuthString(client, auth, sizeof(auth));
for(new i; i < listlen; i++)
{
if(strcmp(auth, whitelist[i]) == 0)
{
SendConVarValue(client, FindConVar("mp_force_pick_time"), "3600");
break;
}
}
}
}
public Action:CommandReload(client, args)
{
LoadList();
ReplyToCommand(client, "%d SteamIDs loaded from list", listlen);
return Plugin_Handled;
}
public Action:CommandList(client, args)
{
PrintToConsole(client, " Listing current list (%d items):", listlen);
for(new i; i < listlen; i++)
{
PrintToConsole(client, "%s", whitelist[i]);
}
return Plugin_Handled;
}
public Action:CommandAdd(client, args)
{
if(args < 1)
{
ReplyToCommand(client, "[SM] Usage: sm_cvar_add <steamid>");
return Plugin_Handled;
}
new String:steamid[64];
GetCmdArg(1, steamid, sizeof(steamid));
TrimString(steamid);
new String:path[PLATFORM_MAX_PATH];
BuildPath(PathType:Path_SM, path, sizeof(path), "configs/list.txt");
new Handle:file = OpenFile(path, "a");
if(file != INVALID_HANDLE)
{
WriteFileLine(file, steamid);
whitelist[listlen] = steamid;
listlen++;
ReplyToCommand(client, "[SM] %s successfully added to list", steamid);
}
else
{
ReplyToCommand(client, "[SM] Failed to open %s for writing", path);
}
CloseHandle(file);
return Plugin_Handled;
}
public LoadList()
{
new String:path[PLATFORM_MAX_PATH];
BuildPath(PathType:Path_SM, path, sizeof(path), "configs/list.txt");
new Handle:file = OpenFile(path, "r");
if(file == INVALID_HANDLE)
{
SetFailState("[Whitelist] Unable to read file %s", path);
}
listlen = 0;
new String:steamid[64];
while(!IsEndOfFile(file) && ReadFileLine(file, steamid, sizeof(steamid)))
{
if (steamid[0] == ';' || !IsCharAlpha(steamid[0]))
{
continue;
}
new len = strlen(steamid);
for (new i; i < len; i++)
{
if (IsCharSpace(steamid[i]) || steamid[i] == ';')
{
steamid[i] = '\0';
break;
}
}
whitelist[listlen] = steamid;
listlen++;
}
CloseHandle(file);
}
The code for checking steamids is from this plugin:
https://forums.alliedmods.net/showthread.php?p=715068 and huge thanks to the author. It's untested, give me information if it'll work! You must put steamid on new file configs/list.txt
__________________