/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Map Manager Plugin
* Contains callbacks for commands
*
* 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 .
*
* 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 .
*
* Version: $Id$
*/
public Action:Command_Say(client, args)
{
decl String:text[192];
if (GetCmdArgString(text, sizeof(text)) < 1)
{
return Plugin_Continue;
}
new startidx;
if (text[strlen(text)-1] == '"')
{
text[strlen(text)-1] = '\0';
startidx = 1;
}
decl String:message[8];
BreakString(text[startidx], message, sizeof(message));
if (strcmp(message, "nextmap", false) == 0)
{
decl String:map[32];
GetConVarString(g_Cvar_Nextmap, map, sizeof(map));
PrintToChat(client, "%t", "Next Map", map);
}
else
{
if (GetConVarBool(g_Cvar_RockTheVote) && (strcmp(text[startidx], "rtv", false) == 0 || strcmp(text[startidx], "rockthevote", false) == 0))
{
if (g_MapChanged)
{
ReplyToCommand(client, "[SM] %t", "Map change in progress");
return Plugin_Continue;
}
if (!g_RTV_Allowed)
{
PrintToChat(client, "[SM] %t", "RTV Not Allowed");
return Plugin_Continue;
}
if (g_RTV_Ended)
{
PrintToChat(client, "[SM] %t", "RTV Ended");
return Plugin_Continue;
}
if (g_RTV_Started)
{
PrintToChat(client, "[SM] %t", "RTV Started");
return Plugin_Continue;
}
if (GetClientCount(true) < GetConVarInt(g_Cvar_MinPlayers) && g_RTV_Votes == 0) // Should we keep checking g_Votes here?
{
PrintToChat(client, "[SM] %t", "Minimal Players Not Met");
return Plugin_Continue;
}
if (g_RTV_Voted[client])
{
PrintToChat(client, "[SM] %t", "Already Voted");
return Plugin_Continue;
}
new String:name[64];
GetClientName(client, name, sizeof(name));
g_RTV_Votes++;
g_RTV_Voted[client] = true;
PrintToChatAll("[SM] %t", "RTV Requested", name, g_RTV_Votes, g_RTV_VotesNeeded);
if (g_RTV_Votes >= g_RTV_VotesNeeded)
{
g_RTV_Started = true;
CreateTimer(2.0, Timer_StartRTV, TIMER_FLAG_NO_MAPCHANGE);
}
}
else if (GetConVarBool(g_Cvar_Nominate) && strcmp(text[startidx], "nominate", false) == 0)
{
if (g_MapChanged)
{
ReplyToCommand(client, "[SM] %t", "Map change in progress");
return Plugin_Continue;
}
if (g_RTV_Started || g_HasVoteStarted)
{
ReplyToCommand(client, "[SM] %t", "Map vote in progress");
return Plugin_Continue;
}
if (g_Nominated[client])
{
PrintToChat(client, "[SM] %t", "Already Nominated");
return Plugin_Continue;
}
if (GetArraySize(g_Nominate) >= GetConVarInt(g_Cvar_Maps))
{
PrintToChat(client, "[SM] %t", "Max Nominations");
return Plugin_Continue;
}
DisplayMenu(g_Menu_Nominate, client, MENU_TIME_FOREVER);
}
}
return Plugin_Continue;
}
public Action:Command_Mapvote(client, args)
{
InitiateVote();
return Plugin_Handled;
}
public Action:Command_Nextmap(args)
{
decl String:map[64];
GetConVarString(g_Cvar_Nextmap, map, sizeof(map));
ReplyToCommand(0, "%t", "Next Map", map);
return Plugin_Handled;
}
public Action:Command_List(client, args)
{
PrintToConsole(client, "Map Cycle:");
decl String:currentMap[64];
GetCurrentMap(currentMap, 64);
decl String:mapName[64];
for (new i = 0; i < GetArraySize(g_MapCycle); i++)
{
GetArrayString(g_MapCycle, i, mapName, sizeof(mapName));
if (strcmp(mapName, currentMap) == 0)
{
PrintToConsole(client, "%s <========= Current map", mapName);
}
else if (strcmp(mapName, g_NextMap) == 0)
{
PrintToConsole(client, "%s <========= Next map", mapName);
}
else
{
PrintToConsole(client, "%s", mapName);
}
}
return Plugin_Handled;
}
public Action:Command_SetNextmap(client, args)
{
if (args < 1)
{
ReplyToCommand(client, "[SM] Usage: sm_setnextmap