2007-06-07 08:17:57 +02:00
|
|
|
/**
|
2007-06-07 09:22:19 +02:00
|
|
|
* basecommands.sp
|
|
|
|
* Implements basic admin commands.
|
2007-06-07 08:17:57 +02:00
|
|
|
* This file is part of SourceMod, Copyright (C) 2004-2007 AlliedModders LLC
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2007-06-07 09:22:19 +02:00
|
|
|
*
|
|
|
|
* Version: $Id$
|
2007-06-07 08:17:57 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sourcemod>
|
|
|
|
|
2007-06-07 09:22:19 +02:00
|
|
|
#pragma semicolon 1
|
|
|
|
|
2007-06-07 08:17:57 +02:00
|
|
|
public Plugin:myinfo =
|
|
|
|
{
|
|
|
|
name = "Basic Commands",
|
|
|
|
author = "AlliedModders LLC",
|
|
|
|
description = "Basic Admin Commands",
|
|
|
|
version = SOURCEMOD_VERSION,
|
|
|
|
url = "http://www.sourcemod.net/"
|
|
|
|
};
|
|
|
|
|
|
|
|
public OnPluginStart()
|
|
|
|
{
|
2007-06-07 23:24:29 +02:00
|
|
|
LoadTranslations("common.cfg");
|
2007-06-07 08:17:57 +02:00
|
|
|
RegAdminCmd("sm_kick", Command_Kick, ADMFLAG_KICK, "sm_kick <#userid|name> [reason]");
|
2007-06-07 23:24:29 +02:00
|
|
|
RegAdminCmd("sm_map", Command_Map, ADMFLAG_CHANGEMAP, "sm_map <map>");
|
|
|
|
}
|
|
|
|
|
|
|
|
public Action:Command_Map(client, args)
|
|
|
|
{
|
|
|
|
if (args < 1)
|
|
|
|
{
|
|
|
|
ReplyToCommand(client, "[SM] Usage: sm_map <map>");
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
|
|
|
|
|
|
|
new String:map[64];
|
|
|
|
GetCmdArg(1, map, sizeof(map));
|
|
|
|
|
|
|
|
if (!IsMapValid(map))
|
|
|
|
{
|
|
|
|
ReplyToCommand(client, "[SM] %t", "Map was not found", map);
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
|
|
|
|
|
|
|
LogMessage("\"%L\" changed map to \"%s\"", client, map);
|
|
|
|
ShowActivity(client, "%t", "Changing map", map);
|
|
|
|
ReplyToCommand(client, "%t", "Changing map", map);
|
|
|
|
|
|
|
|
new Handle:dp
|
|
|
|
CreateDataTimer(3.0, Timer_ChangeMap, dp);
|
|
|
|
WritePackString(dp, map);
|
|
|
|
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Action:Timer_ChangeMap(Handle:timer, Handle:dp)
|
|
|
|
{
|
|
|
|
new String:map[65];
|
|
|
|
|
|
|
|
ResetPack(dp);
|
|
|
|
ReadPackString(dp, map, sizeof(map));
|
|
|
|
|
|
|
|
ServerCommand("changelevel \"%s\"", map);
|
|
|
|
|
|
|
|
return Plugin_Stop;
|
2007-06-07 08:17:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Action:Command_Kick(client, args)
|
|
|
|
{
|
|
|
|
if (args < 1)
|
|
|
|
{
|
|
|
|
ReplyToCommand(client, "[SM] Usage: sm_kick <#userid|name> [reason]");
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
|
|
|
|
|
|
|
new String:arg[65];
|
|
|
|
GetCmdArg(1, arg, sizeof(arg));
|
|
|
|
|
|
|
|
new clients[2];
|
|
|
|
new numClients = SearchForClients(arg, clients, 2);
|
|
|
|
|
|
|
|
if (numClients == 0)
|
|
|
|
{
|
|
|
|
ReplyToCommand(client, "[SM] %t", "No matching client");
|
|
|
|
return Plugin_Handled;
|
|
|
|
} else if (numClients > 1) {
|
|
|
|
ReplyToCommand(client, "[SM] %t", "More than one client matches", arg);
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
|
|
|
|
|
|
|
new userid = GetClientUserId(clients[0]);
|
|
|
|
new String:name[65];
|
|
|
|
|
|
|
|
GetClientName(clients[0], name, sizeof(name));
|
|
|
|
|
2007-06-07 09:22:19 +02:00
|
|
|
decl String:reason[256];
|
2007-06-07 08:17:57 +02:00
|
|
|
if (args < 2)
|
|
|
|
{
|
|
|
|
/* Safely null terminate */
|
|
|
|
reason[0] = '\0';
|
|
|
|
} else {
|
|
|
|
GetCmdArg(2, reason, sizeof(reason));
|
|
|
|
}
|
|
|
|
|
|
|
|
LogMessage("\"%L\" kicked \"%L\" (reason \"%s\")", client, clients[0], reason);
|
|
|
|
ShowActivity(client, "%t", "Kicked player", name);
|
|
|
|
|
|
|
|
if (args < 2)
|
|
|
|
{
|
|
|
|
ServerCommand("kickid %d", userid);
|
|
|
|
} else {
|
|
|
|
ServerCommand("kickid %d \"%s\"", userid, reason);
|
|
|
|
}
|
|
|
|
|
2007-06-07 23:24:29 +02:00
|
|
|
ReplyToCommand(client, "[SM] %t", "Client kicked", name);
|
2007-06-07 08:17:57 +02:00
|
|
|
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|