jit refactoring branch
--HG-- branch : refac-jit extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/branches/refac-jit%402369
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Basecommands Plugin
|
||||
* Provides cancelvote functionality.
|
||||
*
|
||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
PerformCancelVote(client)
|
||||
{
|
||||
if (!IsVoteInProgress())
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Vote Not In Progress");
|
||||
return;
|
||||
}
|
||||
|
||||
ShowActivity2(client, "[SM] ", "%t", "Cancelled Vote");
|
||||
|
||||
CancelVote();
|
||||
}
|
||||
|
||||
public AdminMenu_CancelVote(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
Format(buffer, maxlength, "%T", "Cancel vote", param);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
PerformCancelVote(param);
|
||||
RedisplayAdminMenu(topmenu, param);
|
||||
}
|
||||
else if (action == TopMenuAction_DrawOption)
|
||||
{
|
||||
buffer[0] = IsVoteInProgress() ? ITEMDRAW_DEFAULT : ITEMDRAW_IGNORE;
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_CancelVote(client, args)
|
||||
{
|
||||
PerformCancelVote(client);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Basecommands Plugin
|
||||
* Provides exec cfg functionality
|
||||
*
|
||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
new Handle:g_ConfigMenu = INVALID_HANDLE;
|
||||
|
||||
PerformExec(client, String:path[])
|
||||
{
|
||||
if (!FileExists(path))
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Config not found", path[4]);
|
||||
return;
|
||||
}
|
||||
|
||||
ShowActivity2(client, "[SM] ", "%t", "Executed config", path[4]);
|
||||
|
||||
LogAction(client, -1, "\"%L\" executed config (file \"%s\")", client, path[4]);
|
||||
|
||||
ServerCommand("exec \"%s\"", path[4]);
|
||||
}
|
||||
|
||||
public AdminMenu_ExecCFG(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
Format(buffer, maxlength, "%T", "Exec CFG", param);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
DisplayMenu(g_ConfigMenu, param, MENU_TIME_FOREVER);
|
||||
}
|
||||
}
|
||||
|
||||
public MenuHandler_ExecCFG(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
if (action == MenuAction_Cancel)
|
||||
{
|
||||
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
|
||||
{
|
||||
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
}
|
||||
else if (action == MenuAction_Select)
|
||||
{
|
||||
decl String:path[256];
|
||||
|
||||
GetMenuItem(menu, param2, path, sizeof(path));
|
||||
|
||||
PerformExec(param1, path);
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_ExecCfg(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_execcfg <filename>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
new String:path[64] = "cfg/";
|
||||
GetCmdArg(1, path[4], sizeof(path)-4);
|
||||
|
||||
PerformExec(client, path);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
new Handle:config_parser = INVALID_HANDLE;
|
||||
ParseConfigs()
|
||||
{
|
||||
if (config_parser == INVALID_HANDLE)
|
||||
{
|
||||
config_parser = SMC_CreateParser();
|
||||
}
|
||||
|
||||
SMC_SetReaders(config_parser, NewSection, KeyValue, EndSection);
|
||||
|
||||
if (g_ConfigMenu != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(g_ConfigMenu);
|
||||
}
|
||||
|
||||
g_ConfigMenu = CreateMenu(MenuHandler_ExecCFG);
|
||||
SetMenuTitle(g_ConfigMenu, "Choose Config");
|
||||
SetMenuExitBackButton(g_ConfigMenu, true);
|
||||
|
||||
decl String:configPath[256];
|
||||
BuildPath(Path_SM, configPath, sizeof(configPath), "configs/adminmenu_cfgs.txt");
|
||||
|
||||
if (!FileExists(configPath))
|
||||
{
|
||||
LogError("Unable to locate exec config file, no maps loaded.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
new line;
|
||||
new SMCError:err = SMC_ParseFile(config_parser, configPath, line);
|
||||
if (err != SMCError_Okay)
|
||||
{
|
||||
decl String:error[256];
|
||||
SMC_GetErrorString(err, error, sizeof(error));
|
||||
LogError("Could not parse file (line %d, file \"%s\"):", line, configPath);
|
||||
LogError("Parser encountered error: %s", error);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public SMCResult:NewSection(Handle:smc, const String:name[], bool:opt_quotes)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public SMCResult:KeyValue(Handle:smc, const String:key[], const String:value[], bool:key_quotes, bool:value_quotes)
|
||||
{
|
||||
AddMenuItem(g_ConfigMenu, key, value);
|
||||
}
|
||||
|
||||
public SMCResult:EndSection(Handle:smc)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Basecommands Plugin
|
||||
* Provides kick functionality
|
||||
*
|
||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
PerformKick(client, target, const String:reason[])
|
||||
{
|
||||
LogAction(client, target, "\"%L\" kicked \"%L\" (reason \"%s\")", client, target, reason);
|
||||
|
||||
if (reason[0] == '\0')
|
||||
{
|
||||
KickClient(target, "%t", "Kicked by admin");
|
||||
}
|
||||
else
|
||||
{
|
||||
KickClient(target, "%s", reason);
|
||||
}
|
||||
}
|
||||
|
||||
DisplayKickMenu(client)
|
||||
{
|
||||
new Handle:menu = CreateMenu(MenuHandler_Kick);
|
||||
|
||||
decl String:title[100];
|
||||
Format(title, sizeof(title), "%T:", "Kick player", client);
|
||||
SetMenuTitle(menu, title);
|
||||
SetMenuExitBackButton(menu, true);
|
||||
|
||||
AddTargetsToMenu(menu, client, false, false);
|
||||
|
||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
public AdminMenu_Kick(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
Format(buffer, maxlength, "%T", "Kick player", param);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
DisplayKickMenu(param);
|
||||
}
|
||||
}
|
||||
|
||||
public MenuHandler_Kick(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
if (action == MenuAction_End)
|
||||
{
|
||||
CloseHandle(menu);
|
||||
}
|
||||
else if (action == MenuAction_Cancel)
|
||||
{
|
||||
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
|
||||
{
|
||||
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
}
|
||||
else if (action == MenuAction_Select)
|
||||
{
|
||||
decl String:info[32];
|
||||
new userid, target;
|
||||
|
||||
GetMenuItem(menu, param2, info, sizeof(info));
|
||||
userid = StringToInt(info);
|
||||
|
||||
if ((target = GetClientOfUserId(userid)) == 0)
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Player no longer available");
|
||||
}
|
||||
else if (!CanUserTarget(param1, target))
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Unable to target");
|
||||
}
|
||||
else
|
||||
{
|
||||
decl String:name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Kicked target", "_s", name);
|
||||
PerformKick(param1, target, "");
|
||||
}
|
||||
|
||||
/* Re-draw the menu if they're still valid */
|
||||
if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
|
||||
{
|
||||
DisplayKickMenu(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_Kick(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_kick <#userid|name> [reason]");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:Arguments[256];
|
||||
GetCmdArgString(Arguments, sizeof(Arguments));
|
||||
|
||||
decl String:arg[65];
|
||||
new len = BreakString(Arguments, arg, sizeof(arg));
|
||||
|
||||
if (len == -1)
|
||||
{
|
||||
/* Safely null terminate */
|
||||
len = 0;
|
||||
Arguments[0] = '\0';
|
||||
}
|
||||
|
||||
decl String:target_name[MAX_TARGET_LENGTH];
|
||||
decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
|
||||
|
||||
if ((target_count = ProcessTargetString(
|
||||
arg,
|
||||
client,
|
||||
target_list,
|
||||
MAXPLAYERS,
|
||||
COMMAND_FILTER_CONNECTED,
|
||||
target_name,
|
||||
sizeof(target_name),
|
||||
tn_is_ml)) > 0)
|
||||
{
|
||||
if (tn_is_ml)
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Kicked target", target_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Kicked target", "_s", target_name);
|
||||
}
|
||||
|
||||
new kick_self = 0;
|
||||
|
||||
for (new i = 0; i < target_count; i++)
|
||||
{
|
||||
/* Kick everyone else first */
|
||||
if (target_list[i] == client)
|
||||
{
|
||||
kick_self = client;
|
||||
}
|
||||
else
|
||||
{
|
||||
PerformKick(client, target_list[i], Arguments[len]);
|
||||
}
|
||||
}
|
||||
|
||||
if (kick_self)
|
||||
{
|
||||
PerformKick(client, client, Arguments[len]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ReplyToTargetError(client, target_count);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Basecommands Plugin
|
||||
* Provides map functionality
|
||||
*
|
||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
public MenuHandler_ChangeMap(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
if (action == MenuAction_Cancel)
|
||||
{
|
||||
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
|
||||
{
|
||||
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
}
|
||||
else if (action == MenuAction_Select)
|
||||
{
|
||||
decl String:map[64];
|
||||
|
||||
GetMenuItem(menu, param2, map, sizeof(map));
|
||||
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Changing map", map);
|
||||
|
||||
LogAction(param1, -1, "\"%L\" changed map to \"%s\"", param1, map);
|
||||
|
||||
new Handle:dp;
|
||||
CreateDataTimer(3.0, Timer_ChangeMap, dp);
|
||||
WritePackString(dp, map);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public AdminMenu_Map(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
Format(buffer, maxlength, "%T", "Choose Map", param);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
DisplayMenu(g_MapList, param, MENU_TIME_FOREVER);
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_Map(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_map <map>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:map[64];
|
||||
GetCmdArg(1, map, sizeof(map));
|
||||
|
||||
if (!IsMapValid(map))
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Map was not found", map);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
ShowActivity2(client, "[SM] ", "%t", "Changing map", map);
|
||||
|
||||
LogAction(client, -1, "\"%L\" changed map to \"%s\"", client, map);
|
||||
|
||||
new Handle:dp;
|
||||
CreateDataTimer(3.0, Timer_ChangeMap, dp);
|
||||
WritePackString(dp, map);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Timer_ChangeMap(Handle:timer, Handle:dp)
|
||||
{
|
||||
decl String:map[65];
|
||||
|
||||
ResetPack(dp);
|
||||
ReadPackString(dp, map, sizeof(map));
|
||||
|
||||
ServerCommand("changelevel \"%s\"", map);
|
||||
|
||||
return Plugin_Stop;
|
||||
}
|
||||
|
||||
new Handle:g_map_array = INVALID_HANDLE;
|
||||
new g_map_serial = -1;
|
||||
|
||||
LoadMapList(Handle:menu)
|
||||
{
|
||||
new Handle:map_array;
|
||||
|
||||
if ((map_array = ReadMapList(g_map_array,
|
||||
g_map_serial,
|
||||
"sm_map menu",
|
||||
MAPLIST_FLAG_CLEARARRAY|MAPLIST_FLAG_NO_DEFAULT|MAPLIST_FLAG_MAPSFOLDER))
|
||||
!= INVALID_HANDLE)
|
||||
{
|
||||
g_map_array = map_array;
|
||||
}
|
||||
|
||||
if (g_map_array == INVALID_HANDLE)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
RemoveAllMenuItems(menu);
|
||||
|
||||
decl String:map_name[64];
|
||||
new map_count = GetArraySize(g_map_array);
|
||||
|
||||
for (new i = 0; i < map_count; i++)
|
||||
{
|
||||
GetArrayString(g_map_array, i, map_name, sizeof(map_name));
|
||||
AddMenuItem(menu, map_name, map_name);
|
||||
}
|
||||
|
||||
return map_count;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Basecommands Plugin
|
||||
* Provides reloadadmins functionality.
|
||||
*
|
||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
PerformReloadAdmins(client)
|
||||
{
|
||||
/* Dump it all! */
|
||||
DumpAdminCache(AdminCache_Groups, true);
|
||||
DumpAdminCache(AdminCache_Overrides, true);
|
||||
|
||||
LogAction(client, -1, "\"%L\" refreshed the admin cache.", client);
|
||||
ReplyToCommand(client, "[SM] %t", "Admin cache refreshed");
|
||||
}
|
||||
|
||||
public AdminMenu_ReloadAdmins(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
Format(buffer, maxlength, "%T", "Reload admins", param);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
PerformReloadAdmins(param);
|
||||
RedisplayAdminMenu(topmenu, param);
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_ReloadAdmins(client, args)
|
||||
{
|
||||
PerformReloadAdmins(client);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Basecommands Plugin
|
||||
* Provides sm_who functionality
|
||||
*
|
||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
PerformWho(client, target, ReplySource:reply, bool:is_admin)
|
||||
{
|
||||
decl String:name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
new bool:show_name = false;
|
||||
new String:admin_name[MAX_NAME_LENGTH];
|
||||
new AdminId:id = GetUserAdmin(target);
|
||||
if (id != INVALID_ADMIN_ID && GetAdminUsername(id, admin_name, sizeof(admin_name)))
|
||||
{
|
||||
show_name = true;
|
||||
}
|
||||
|
||||
new ReplySource:old_reply = SetCmdReplySource(reply);
|
||||
|
||||
if (id == INVALID_ADMIN_ID)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Player is not an admin", name);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!is_admin)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Player is an admin", name);
|
||||
}
|
||||
else
|
||||
{
|
||||
new flags = GetUserFlagBits(target);
|
||||
decl String:flagstring[255];
|
||||
if (flags == 0)
|
||||
{
|
||||
strcopy(flagstring, sizeof(flagstring), "none");
|
||||
}
|
||||
else if (flags & ADMFLAG_ROOT)
|
||||
{
|
||||
strcopy(flagstring, sizeof(flagstring), "root");
|
||||
}
|
||||
else
|
||||
{
|
||||
FlagsToString(flagstring, sizeof(flagstring), flags);
|
||||
}
|
||||
|
||||
if (show_name)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Admin logged in as", name, admin_name, flagstring);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Admin logged in anon", name, flagstring);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetCmdReplySource(old_reply);
|
||||
}
|
||||
|
||||
DisplayWhoMenu(client)
|
||||
{
|
||||
new Handle:menu = CreateMenu(MenuHandler_Who);
|
||||
|
||||
decl String:title[100];
|
||||
Format(title, sizeof(title), "%T:", "Identify player", client);
|
||||
SetMenuTitle(menu, title);
|
||||
SetMenuExitBackButton(menu, true);
|
||||
|
||||
AddTargetsToMenu(menu, client, false, false);
|
||||
|
||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
public AdminMenu_Who(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
Format(buffer, maxlength, "%T", "Identify player", param);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
DisplayWhoMenu(param);
|
||||
}
|
||||
}
|
||||
|
||||
public MenuHandler_Who(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
if (action == MenuAction_End)
|
||||
{
|
||||
CloseHandle(menu);
|
||||
}
|
||||
else if (action == MenuAction_Cancel)
|
||||
{
|
||||
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
|
||||
{
|
||||
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
}
|
||||
else if (action == MenuAction_Select)
|
||||
{
|
||||
decl String:info[32];
|
||||
new userid, target;
|
||||
|
||||
GetMenuItem(menu, param2, info, sizeof(info));
|
||||
userid = StringToInt(info);
|
||||
|
||||
if ((target = GetClientOfUserId(userid)) == 0)
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Player no longer available");
|
||||
}
|
||||
else if (!CanUserTarget(param1, target))
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Unable to target");
|
||||
}
|
||||
else
|
||||
{
|
||||
PerformWho(param1, target, SM_REPLY_TO_CHAT, (GetUserFlagBits(param1) != 0 ? true : false));
|
||||
}
|
||||
|
||||
/* Re-draw the menu if they're still valid */
|
||||
|
||||
/* - Close the menu? redisplay? jump back up to the category?
|
||||
if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
|
||||
{
|
||||
DisplayWhoMenu(param1);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
public Action:Command_Who(client, args)
|
||||
{
|
||||
new bool:is_admin = false;
|
||||
|
||||
if (!client || (client && GetUserFlagBits(client) != 0))
|
||||
{
|
||||
is_admin = true;
|
||||
}
|
||||
|
||||
if (args < 1)
|
||||
{
|
||||
/* Display header */
|
||||
decl String:t_access[16], String:t_name[16], String:t_username[16];
|
||||
Format(t_access, sizeof(t_access), "%t", "Admin access", client);
|
||||
Format(t_name, sizeof(t_name), "%t", "Name", client);
|
||||
Format(t_username, sizeof(t_username), "%t", "Username", client);
|
||||
|
||||
if (is_admin)
|
||||
{
|
||||
PrintToConsole(client, " %-24.23s %-18.17s %s", t_name, t_username, t_access);
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintToConsole(client, " %-24.23s %s", t_name, t_access);
|
||||
}
|
||||
|
||||
/* List all players */
|
||||
new maxClients = GetMaxClients();
|
||||
decl String:flagstring[255];
|
||||
|
||||
for (new i=1; i<=maxClients; i++)
|
||||
{
|
||||
if (!IsClientInGame(i))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
new flags = GetUserFlagBits(i);
|
||||
new AdminId:id = GetUserAdmin(i);
|
||||
if (flags == 0)
|
||||
{
|
||||
strcopy(flagstring, sizeof(flagstring), "none");
|
||||
}
|
||||
else if (flags & ADMFLAG_ROOT)
|
||||
{
|
||||
strcopy(flagstring, sizeof(flagstring), "root");
|
||||
}
|
||||
else
|
||||
{
|
||||
FlagsToString(flagstring, sizeof(flagstring), flags);
|
||||
}
|
||||
decl String:name[MAX_NAME_LENGTH];
|
||||
new String:username[MAX_NAME_LENGTH];
|
||||
|
||||
GetClientName(i, name, sizeof(name));
|
||||
|
||||
if (id != INVALID_ADMIN_ID)
|
||||
{
|
||||
GetAdminUsername(id, username, sizeof(username));
|
||||
}
|
||||
|
||||
if (is_admin)
|
||||
{
|
||||
PrintToConsole(client, "%2d. %-24.23s %-18.17s %s", i, name, username, flagstring);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (flags == 0)
|
||||
{
|
||||
PrintToConsole(client, "%2d. %-24.23s %t", i, name, "No");
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintToConsole(client, "%2d. %-24.23s %t", i, name, "Yes");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (GetCmdReplySource() == SM_REPLY_TO_CHAT)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "See console for output");
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg[65];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg, false, false);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
PerformWho(client, target, GetCmdReplySource(), is_admin);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
Reference in New Issue
Block a user