deprecated LoadMaps() and its usage in three plugins
renamed basefun* to fun* removed map file list cvars --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401895
This commit is contained in:
parent
2edce74e0f
commit
63cb644232
@ -27,12 +27,33 @@
|
||||
"target" "mapcyclefile"
|
||||
}
|
||||
|
||||
/* Admin menu, map menu */
|
||||
"sm_map menu"
|
||||
{
|
||||
"file" "addons/sourcemod/configs/adminmenu_maplist.ini"
|
||||
}
|
||||
|
||||
/* Admin menu, map voting menu */
|
||||
"sm_votemap menu"
|
||||
{
|
||||
"file" "addons/sourcemod/configs/adminmenu_maplist.ini"
|
||||
}
|
||||
|
||||
/* For the "randomcycle" plugin */
|
||||
"randomcycle"
|
||||
{
|
||||
"target" "default"
|
||||
}
|
||||
|
||||
/* For the "mapchooser" plugin */
|
||||
"mapchooser"
|
||||
{
|
||||
"target" "default"
|
||||
}
|
||||
|
||||
/* For the "randomcycle" plugin */
|
||||
"rockthevote"
|
||||
{
|
||||
"target" "default"
|
||||
}
|
||||
}
|
||||
|
@ -40,9 +40,9 @@
|
||||
|
||||
public Plugin:myinfo =
|
||||
{
|
||||
name = "Basic Fun Commands",
|
||||
name = "Fun Commands",
|
||||
author = "AlliedModders LLC",
|
||||
description = "Basic Fun Commands",
|
||||
description = "Fun Commands",
|
||||
version = SOURCEMOD_VERSION,
|
||||
url = "http://www.sourcemod.net/"
|
||||
};
|
||||
@ -53,7 +53,7 @@ public Plugin:myinfo =
|
||||
#define BEACON 1
|
||||
#define TIMEBOMB 1
|
||||
#define FIRE 1
|
||||
#define ICE 1
|
||||
#define ICE 1
|
||||
#define GRAVITY 1
|
||||
#define BLIND 1
|
||||
#define NOCLIP 1
|
||||
@ -71,7 +71,7 @@ new Handle:hTopMenu = INVALID_HANDLE;
|
||||
#define SOUND_BEEP "buttons/button17.wav"
|
||||
#define SOUND_FINAL "weapons/cguard/charging.wav"
|
||||
#define SOUND_BOOM "weapons/explode3.wav"
|
||||
#define SOUND_FREEZE "physics/glass/glass_impact_bullet4.wav"
|
||||
#define SOUND_FREEZE "physics/glass/glass_impact_bullet4.wav"
|
||||
|
||||
// Following are model indexes for temp entities
|
||||
new g_BeamSprite;
|
||||
@ -93,32 +93,37 @@ new UserMsg:g_FadeUserMsgId;
|
||||
|
||||
// Include various commands and supporting functions
|
||||
#if BEACON
|
||||
#include "basefuncommands/beacon.sp"
|
||||
#include "funcommands/beacon.sp"
|
||||
#endif
|
||||
#if TIMEBOMB
|
||||
#include "basefuncommands/timebomb.sp"
|
||||
#include "funcommands/timebomb.sp"
|
||||
#endif
|
||||
#if FIRE
|
||||
#include "basefuncommands/fire.sp"
|
||||
#include "funcommands/fire.sp"
|
||||
#endif
|
||||
#if ICE
|
||||
#include "basefuncommands/ice.sp"
|
||||
#include "funcommands/ice.sp"
|
||||
#endif
|
||||
#if GRAVITY
|
||||
#include "basefuncommands/gravity.sp"
|
||||
#include "funcommands/gravity.sp"
|
||||
#endif
|
||||
#if BLIND
|
||||
#include "basefuncommands/blind.sp"
|
||||
#include "funcommands/blind.sp"
|
||||
#endif
|
||||
#if NOCLIP
|
||||
#include "basefuncommands/noclip.sp"
|
||||
#include "funcommands/noclip.sp"
|
||||
#endif
|
||||
#if DRUG
|
||||
#include "basefuncommands/drug.sp"
|
||||
#include "funcommands/drug.sp"
|
||||
#endif
|
||||
|
||||
public OnPluginStart()
|
||||
{
|
||||
if (FindPluginByFile("basefuncommands.smx") != INVALID_HANDLE)
|
||||
{
|
||||
ThrowError("This plugin replaces basefuncommands. You cannot run both at once.");
|
||||
}
|
||||
|
||||
LoadTranslations("common.phrases");
|
||||
LoadTranslations("basefuncommands.phrases");
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
public Plugin:myinfo =
|
||||
{
|
||||
name = "Basic Fun Votes",
|
||||
name = "Fun Votes",
|
||||
author = "AlliedModders LLC",
|
||||
description = "Fun Vote Commands",
|
||||
version = SOURCEMOD_VERSION,
|
||||
@ -85,14 +85,19 @@ new String:g_voteInfo[3][65]; /* Holds the target's name, authid, and IP */
|
||||
|
||||
new Handle:hTopMenu = INVALID_HANDLE;
|
||||
|
||||
#include "basefunvotes/votegravity.sp"
|
||||
#include "basefunvotes/voteburn.sp"
|
||||
#include "basefunvotes/voteslay.sp"
|
||||
#include "basefunvotes/votealltalk.sp"
|
||||
#include "basefunvotes/voteff.sp"
|
||||
#include "funvotes/votegravity.sp"
|
||||
#include "funvotes/voteburn.sp"
|
||||
#include "funvotes/voteslay.sp"
|
||||
#include "funvotes/votealltalk.sp"
|
||||
#include "funvotes/voteff.sp"
|
||||
|
||||
public OnPluginStart()
|
||||
{
|
||||
if (FindPluginByFile("basefunvotes.smx") != INVALID_HANDLE)
|
||||
{
|
||||
ThrowError("This plugin replaces basefuncommands. You cannot run both at once.");
|
||||
}
|
||||
|
||||
LoadTranslations("common.phrases");
|
||||
LoadTranslations("basevotes.phrases");
|
||||
LoadTranslations("basefunvotes.phrases");
|
@ -202,6 +202,10 @@ stock FindTarget(client, const String:target[], bool:nobots = false, bool:immuni
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is no longer supported. It has been replaced with ReadMapList(),
|
||||
* which uses a more unified caching and configuration mechanism. This function also
|
||||
* has a bug where if the cvar contents changes, the fileTime change won't be recognized.
|
||||
*
|
||||
* Loads a specified array with maps. The maps will be either loaded from mapcyclefile, or if supplied
|
||||
* a cvar containing a file name. If the file in the cvar is bad, it will use mapcyclefile. The fileTime
|
||||
* parameter is used to store a timestamp of the file. If specified, the file will only be reloaded if it
|
||||
@ -210,8 +214,9 @@ stock FindTarget(client, const String:target[], bool:nobots = false, bool:immuni
|
||||
* @param array Valid array handle, should be created with CreateArray(33) or larger.
|
||||
* @param fileTime Variable containing the "last changed" time of the file. Used to avoid needless reloading.
|
||||
* @param fileCvar CVAR set to the file to be loaded. Optional.
|
||||
* @return Number of maps loaded or 0 if in error.
|
||||
* @return Number of maps loaded or 0 if in error.
|
||||
*/
|
||||
#pragma deprecated Use ReadMapList() instead.
|
||||
stock LoadMaps(Handle:array, &fileTime = 0, Handle:fileCvar = INVALID_HANDLE)
|
||||
{
|
||||
decl String:mapPath[256], String:mapFile[64];
|
||||
|
@ -56,7 +56,6 @@ new Handle:g_Cvar_StartFrags = INVALID_HANDLE;
|
||||
new Handle:g_Cvar_ExtendTimeStep = INVALID_HANDLE;
|
||||
new Handle:g_Cvar_ExtendRoundStep = INVALID_HANDLE;
|
||||
new Handle:g_Cvar_ExtendFragStep = INVALID_HANDLE;
|
||||
new Handle:g_Cvar_Mapfile = INVALID_HANDLE;
|
||||
new Handle:g_Cvar_ExcludeMaps = INVALID_HANDLE;
|
||||
new Handle:g_Cvar_IncludeMaps = INVALID_HANDLE;
|
||||
new Handle:g_Cvar_NoVoteMode = INVALID_HANDLE;
|
||||
@ -74,7 +73,7 @@ new Handle:g_VoteMenu = INVALID_HANDLE;
|
||||
new g_Extends;
|
||||
new g_TotalRounds;
|
||||
new bool:g_HasVoteStarted;
|
||||
new g_mapFileTime;
|
||||
new g_mapFileSerial = -1;
|
||||
|
||||
#define VOTE_EXTEND "##extend##"
|
||||
|
||||
@ -93,7 +92,6 @@ public OnPluginStart()
|
||||
g_Cvar_ExtendTimeStep = CreateConVar("sm_extendmap_timestep", "15", "Specifies how much many more minutes each extension makes", _, true, 5.0);
|
||||
g_Cvar_ExtendRoundStep = CreateConVar("sm_extendmap_roundstep", "5", "Specifies how many more rounds each extension makes", _, true, 5.0);
|
||||
g_Cvar_ExtendFragStep = CreateConVar("sm_extendmap_fragstep", "10", "Specifies how many more frags are allowed when map is extended.", _, true, 5.0);
|
||||
g_Cvar_Mapfile = CreateConVar("sm_mapvote_file", "configs/maps.ini", "Map file to use. (Def sourcemod/configs/maps.ini)");
|
||||
g_Cvar_ExcludeMaps = CreateConVar("sm_mapvote_exclude", "5", "Specifies how many past maps to exclude from the vote.", _, true, 0.0);
|
||||
g_Cvar_IncludeMaps = CreateConVar("sm_mapvote_include", "5", "Specifies how many maps to include in the vote.", _, true, 2.0, true, 6.0);
|
||||
g_Cvar_NoVoteMode = CreateConVar("sm_mapvote_novote", "1", "Specifies whether or not MapChooser should pick a map if no votes are received.", _, true, 0.0, true, 1.0);
|
||||
@ -128,13 +126,23 @@ public OnConfigsExecuted()
|
||||
SetFailState("sm_nextmap not found");
|
||||
}
|
||||
|
||||
if (LoadMaps(g_MapList, g_mapFileTime, g_Cvar_Mapfile))
|
||||
if (ReadMapList(g_MapList,
|
||||
g_mapFileSerial,
|
||||
"mapchooser",
|
||||
MAPLIST_FLAG_CLEARARRAY|MAPLIST_FLAG_MAPSFOLDER)
|
||||
!= INVALID_HANDLE)
|
||||
|
||||
{
|
||||
CreateNextVote();
|
||||
SetupTimeleftTimer();
|
||||
SetConVarString(g_Cvar_Nextmap, "Pending Vote");
|
||||
if (g_mapFileSerial == -1)
|
||||
{
|
||||
LogError("Unable to create a valid map list.");
|
||||
}
|
||||
}
|
||||
|
||||
CreateNextVote();
|
||||
SetupTimeleftTimer();
|
||||
SetConVarString(g_Cvar_Nextmap, "Pending Vote");
|
||||
|
||||
if (g_TeamScores != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(g_TeamScores);
|
||||
|
@ -44,12 +44,11 @@ public Plugin:myinfo =
|
||||
};
|
||||
|
||||
new Handle:g_Cvar_Nextmap = INVALID_HANDLE;
|
||||
new Handle:g_Cvar_Mapfile = INVALID_HANDLE;
|
||||
new Handle:g_Cvar_ExcludeMaps = INVALID_HANDLE;
|
||||
|
||||
new Handle:g_MapList = INVALID_HANDLE;
|
||||
new Handle:g_OldMapList = INVALID_HANDLE;
|
||||
new g_mapFileTime;
|
||||
new g_mapListSerial = -1;
|
||||
|
||||
public OnPluginStart()
|
||||
{
|
||||
@ -57,7 +56,6 @@ public OnPluginStart()
|
||||
g_MapList = CreateArray(arraySize);
|
||||
g_OldMapList = CreateArray(arraySize);
|
||||
|
||||
g_Cvar_Mapfile = CreateConVar("sm_randomcycle_file", "configs/maps.ini", "Map file to use. (Def sourcemod/configs/maps.ini)");
|
||||
g_Cvar_ExcludeMaps = CreateConVar("sm_randomcycle_exclude", "5", "Specifies how many past maps to exclude from the vote.", _, true, 0.0);
|
||||
|
||||
AutoExecConfig(true, "randomcycle");
|
||||
@ -73,10 +71,19 @@ public OnConfigsExecuted()
|
||||
SetFailState("sm_nextmap not found");
|
||||
}
|
||||
|
||||
if (LoadMaps(g_MapList, g_mapFileTime, g_Cvar_Mapfile))
|
||||
if (ReadMapList(g_MapList,
|
||||
g_mapListSerial,
|
||||
"randomcycle",
|
||||
MAPLIST_FLAG_CLEARARRAY|MAPLIST_FLAG_MAPSFOLDER)
|
||||
== INVALID_HANDLE)
|
||||
{
|
||||
CreateTimer(5.0, Timer_RandomizeNextmap); // Small delay to give Nextmap time to complete OnMapStart()
|
||||
if (g_mapListSerial == -1)
|
||||
{
|
||||
LogError("Unable to create a valid map list.");
|
||||
}
|
||||
}
|
||||
|
||||
CreateTimer(5.0, Timer_RandomizeNextmap); // Small delay to give Nextmap time to complete OnMapStart()
|
||||
}
|
||||
|
||||
public Action:Timer_RandomizeNextmap(Handle:timer)
|
||||
|
@ -1,93 +1,91 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Rock The Vote Plugin
|
||||
* Creates a map vote when the required number of players have requested one.
|
||||
*
|
||||
* SourceMod (C)2004-2007 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$
|
||||
*/
|
||||
|
||||
#include <sourcemod>
|
||||
|
||||
#pragma semicolon 1
|
||||
|
||||
public Plugin:myinfo =
|
||||
{
|
||||
name = "Rock The Vote",
|
||||
author = "AlliedModders LLC",
|
||||
description = "Provides RTV Map Voting",
|
||||
version = SOURCEMOD_VERSION,
|
||||
url = "http://www.sourcemod.net/"
|
||||
};
|
||||
|
||||
new Handle:g_Cvar_Needed = INVALID_HANDLE;
|
||||
new Handle:g_Cvar_File = INVALID_HANDLE;
|
||||
new Handle:g_Cvar_Maps = INVALID_HANDLE;
|
||||
new Handle:g_Cvar_Nominate = INVALID_HANDLE;
|
||||
new Handle:g_Cvar_MinPlayers = INVALID_HANDLE;
|
||||
|
||||
new Handle:g_MapList = INVALID_HANDLE;
|
||||
new Handle:g_RTVMapList = INVALID_HANDLE;
|
||||
new Handle:g_MapMenu = INVALID_HANDLE;
|
||||
new Handle:g_RetryTimer = INVALID_HANDLE;
|
||||
new g_mapFileTime;
|
||||
|
||||
new bool:g_CanRTV = false; // True if RTV loaded maps and is active.
|
||||
new bool:g_RTVAllowed = false; // True if RTV is available to players. Used to delay rtv votes.
|
||||
new bool:g_RTVStarted = false; // Indicates that the actual map vote has started
|
||||
new bool:g_RTVEnded = false; // Indicates that the actual map vote has concluded
|
||||
new g_Voters = 0; // Total voters connected. Doesn't include fake clients.
|
||||
new g_Votes = 0; // Total number of "say rtv" votes
|
||||
new g_VotesNeeded = 0; // Necessary votes before map vote begins. (voters * percent_needed)
|
||||
new bool:g_Voted[MAXPLAYERS+1] = {false, ...};
|
||||
new bool:g_Nominated[MAXPLAYERS+1] = {false, ...};
|
||||
|
||||
public OnPluginStart()
|
||||
{
|
||||
LoadTranslations("common.phrases");
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Rock The Vote Plugin
|
||||
* Creates a map vote when the required number of players have requested one.
|
||||
*
|
||||
* SourceMod (C)2004-2007 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$
|
||||
*/
|
||||
|
||||
#include <sourcemod>
|
||||
|
||||
#pragma semicolon 1
|
||||
|
||||
public Plugin:myinfo =
|
||||
{
|
||||
name = "Rock The Vote",
|
||||
author = "AlliedModders LLC",
|
||||
description = "Provides RTV Map Voting",
|
||||
version = SOURCEMOD_VERSION,
|
||||
url = "http://www.sourcemod.net/"
|
||||
};
|
||||
|
||||
new Handle:g_Cvar_Needed = INVALID_HANDLE;
|
||||
new Handle:g_Cvar_Maps = INVALID_HANDLE;
|
||||
new Handle:g_Cvar_Nominate = INVALID_HANDLE;
|
||||
new Handle:g_Cvar_MinPlayers = INVALID_HANDLE;
|
||||
|
||||
new Handle:g_MapList = INVALID_HANDLE;
|
||||
new Handle:g_RTVMapList = INVALID_HANDLE;
|
||||
new Handle:g_MapMenu = INVALID_HANDLE;
|
||||
new Handle:g_RetryTimer = INVALID_HANDLE;
|
||||
new g_mapFileSerial = -1;
|
||||
|
||||
new bool:g_CanRTV = false; // True if RTV loaded maps and is active.
|
||||
new bool:g_RTVAllowed = false; // True if RTV is available to players. Used to delay rtv votes.
|
||||
new bool:g_RTVStarted = false; // Indicates that the actual map vote has started
|
||||
new bool:g_RTVEnded = false; // Indicates that the actual map vote has concluded
|
||||
new g_Voters = 0; // Total voters connected. Doesn't include fake clients.
|
||||
new g_Votes = 0; // Total number of "say rtv" votes
|
||||
new g_VotesNeeded = 0; // Necessary votes before map vote begins. (voters * percent_needed)
|
||||
new bool:g_Voted[MAXPLAYERS+1] = {false, ...};
|
||||
new bool:g_Nominated[MAXPLAYERS+1] = {false, ...};
|
||||
|
||||
public OnPluginStart()
|
||||
{
|
||||
LoadTranslations("common.phrases");
|
||||
LoadTranslations("rockthevote.phrases");
|
||||
|
||||
new arraySize = ByteCountToCells(33);
|
||||
g_MapList = CreateArray(arraySize);
|
||||
g_RTVMapList = CreateArray(arraySize);
|
||||
|
||||
g_Cvar_Needed = CreateConVar("sm_rtv_needed", "0.60", "Percentage of players needed to rockthevote (Def 60%)", 0, true, 0.05, true, 1.0);
|
||||
g_Cvar_File = CreateConVar("sm_rtv_file", "configs/maps.ini", "Map file to use. (Def configs/maps.ini)");
|
||||
g_Cvar_Maps = CreateConVar("sm_rtv_maps", "4", "Number of maps to be voted on. 2 to 6. (Def 4)", 0, true, 2.0, true, 6.0);
|
||||
g_Cvar_Nominate = CreateConVar("sm_rtv_nominate", "1", "Enables nomination system.", 0, true, 0.0, true, 1.0);
|
||||
g_Cvar_MinPlayers = CreateConVar("sm_rtv_minplayers", "0", "Number of players required before RTV will be enabled.", 0, true, 0.0, true, float(MAXPLAYERS));
|
||||
|
||||
RegConsoleCmd("say", Command_Say);
|
||||
RegConsoleCmd("say_team", Command_Say);
|
||||
|
||||
g_RTVMapList = CreateArray(arraySize);
|
||||
|
||||
g_Cvar_Needed = CreateConVar("sm_rtv_needed", "0.60", "Percentage of players needed to rockthevote (Def 60%)", 0, true, 0.05, true, 1.0);
|
||||
g_Cvar_Maps = CreateConVar("sm_rtv_maps", "4", "Number of maps to be voted on. 2 to 6. (Def 4)", 0, true, 2.0, true, 6.0);
|
||||
g_Cvar_Nominate = CreateConVar("sm_rtv_nominate", "1", "Enables nomination system.", 0, true, 0.0, true, 1.0);
|
||||
g_Cvar_MinPlayers = CreateConVar("sm_rtv_minplayers", "0", "Number of players required before RTV will be enabled.", 0, true, 0.0, true, float(MAXPLAYERS));
|
||||
|
||||
RegConsoleCmd("say", Command_Say);
|
||||
RegConsoleCmd("say_team", Command_Say);
|
||||
|
||||
RegAdminCmd("sm_rtv_addmap", Command_Addmap, ADMFLAG_CHANGEMAP, "sm_rtv_addmap <mapname> - Forces a map to be on the RTV, and lowers the allowed nominations.");
|
||||
|
||||
AutoExecConfig(true, "rtv");
|
||||
}
|
||||
AutoExecConfig(true, "rtv");
|
||||
}
|
||||
|
||||
public OnMapStart()
|
||||
{
|
||||
@ -97,13 +95,13 @@ public OnMapStart()
|
||||
g_RTVStarted = false;
|
||||
g_RTVEnded = false;
|
||||
}
|
||||
|
||||
public OnMapEnd()
|
||||
|
||||
public OnMapEnd()
|
||||
{
|
||||
g_CanRTV = false;
|
||||
g_RTVAllowed = false;
|
||||
}
|
||||
|
||||
g_CanRTV = false;
|
||||
g_RTVAllowed = false;
|
||||
}
|
||||
|
||||
public OnConfigsExecuted()
|
||||
{
|
||||
if (g_RTVMapList != INVALID_HANDLE)
|
||||
@ -111,239 +109,248 @@ public OnConfigsExecuted()
|
||||
ClearArray(g_RTVMapList);
|
||||
}
|
||||
|
||||
if (LoadMaps(g_MapList, g_mapFileTime, g_Cvar_File))
|
||||
if (ReadMapList(g_MapList,
|
||||
g_mapFileSerial,
|
||||
"rockthevote",
|
||||
MAPLIST_FLAG_CLEARARRAY|MAPLIST_FLAG_MAPSFOLDER)
|
||||
== INVALID_HANDLE)
|
||||
{
|
||||
BuildMapMenu();
|
||||
g_CanRTV = true;
|
||||
CreateTimer(30.0, Timer_DelayRTV);
|
||||
if (g_mapFileSerial == -1)
|
||||
{
|
||||
LogError("Unable to create a valid map list.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool:OnClientConnect(client, String:rejectmsg[], maxlen)
|
||||
{
|
||||
if(!g_CanRTV || IsFakeClient(client))
|
||||
return true;
|
||||
|
||||
g_Voted[client] = false;
|
||||
g_Nominated[client] = false;
|
||||
|
||||
g_Voters++;
|
||||
g_VotesNeeded = RoundToFloor(float(g_Voters) * GetConVarFloat(g_Cvar_Needed));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public OnClientDisconnect(client)
|
||||
{
|
||||
if(!g_CanRTV || IsFakeClient(client))
|
||||
return;
|
||||
|
||||
if(g_Voted[client])
|
||||
{
|
||||
g_Votes--;
|
||||
}
|
||||
|
||||
g_Voters--;
|
||||
|
||||
g_VotesNeeded = RoundToFloor(float(g_Voters) * GetConVarFloat(g_Cvar_Needed));
|
||||
|
||||
if (g_Votes && g_Voters && g_Votes >= g_VotesNeeded && g_RTVAllowed && !g_RTVStarted)
|
||||
BuildMapMenu();
|
||||
g_CanRTV = true;
|
||||
CreateTimer(30.0, Timer_DelayRTV);
|
||||
}
|
||||
|
||||
public bool:OnClientConnect(client, String:rejectmsg[], maxlen)
|
||||
{
|
||||
if(!g_CanRTV || IsFakeClient(client))
|
||||
return true;
|
||||
|
||||
g_Voted[client] = false;
|
||||
g_Nominated[client] = false;
|
||||
|
||||
g_Voters++;
|
||||
g_VotesNeeded = RoundToFloor(float(g_Voters) * GetConVarFloat(g_Cvar_Needed));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public OnClientDisconnect(client)
|
||||
{
|
||||
if(!g_CanRTV || IsFakeClient(client))
|
||||
return;
|
||||
|
||||
if(g_Voted[client])
|
||||
{
|
||||
g_RTVStarted = true;
|
||||
CreateTimer(2.0, Timer_StartRTV, TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_Addmap(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_rtv_addmap <mapname>");
|
||||
return Plugin_Handled;
|
||||
g_Votes--;
|
||||
}
|
||||
|
||||
g_Voters--;
|
||||
|
||||
g_VotesNeeded = RoundToFloor(float(g_Voters) * GetConVarFloat(g_Cvar_Needed));
|
||||
|
||||
if (g_Votes && g_Voters && g_Votes >= g_VotesNeeded && g_RTVAllowed && !g_RTVStarted)
|
||||
{
|
||||
g_RTVStarted = true;
|
||||
CreateTimer(2.0, Timer_StartRTV, TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_Addmap(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_rtv_addmap <mapname>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (!g_CanRTV)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] RockTheVote is not available.");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:mapname[64];
|
||||
GetCmdArg(1, mapname, sizeof(mapname));
|
||||
|
||||
if (FindStringInArray(g_MapList, mapname) == -1)
|
||||
{
|
||||
ReplyToCommand(client, "%t", "Map was not found", mapname);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (GetArraySize(g_RTVMapList) > 0)
|
||||
}
|
||||
|
||||
decl String:mapname[64];
|
||||
GetCmdArg(1, mapname, sizeof(mapname));
|
||||
|
||||
if (FindStringInArray(g_MapList, mapname) == -1)
|
||||
{
|
||||
ReplyToCommand(client, "%t", "Map was not found", mapname);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (GetArraySize(g_RTVMapList) > 0)
|
||||
{
|
||||
if (FindStringInArray(g_RTVMapList, mapname) != -1)
|
||||
{
|
||||
ReplyToCommand(client, "%t", "Map Already In Vote", mapname);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
ShiftArrayUp(g_RTVMapList, 0);
|
||||
SetArrayString(g_RTVMapList, 0, mapname);
|
||||
|
||||
while (GetArraySize(g_RTVMapList) > GetConVarInt(g_Cvar_Maps))
|
||||
{
|
||||
RemoveFromArray(g_RTVMapList, GetConVarInt(g_Cvar_Maps));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PushArrayString(g_RTVMapList, mapname);
|
||||
}
|
||||
|
||||
decl String:item[64];
|
||||
for (new i = 0; i < GetMenuItemCount(g_MapMenu); i++)
|
||||
{
|
||||
GetMenuItem(g_MapMenu, i, item, sizeof(item));
|
||||
if (strcmp(item, mapname) == 0)
|
||||
{
|
||||
RemoveMenuItem(g_MapMenu, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ReplyToCommand(client, "%t", "Map Inserted", mapname);
|
||||
LogAction(client, -1, "\"%L\" inserted map \"%s\".", client, mapname);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Say(client, args)
|
||||
{
|
||||
if (!g_CanRTV || !client)
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
decl String:text[192];
|
||||
if (!GetCmdArgString(text, sizeof(text)))
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
new startidx = 0;
|
||||
if(text[strlen(text)-1] == '"')
|
||||
{
|
||||
text[strlen(text)-1] = '\0';
|
||||
startidx = 1;
|
||||
}
|
||||
|
||||
if (strcmp(text[startidx], "rtv", false) == 0 || strcmp(text[startidx], "rockthevote", false) == 0)
|
||||
{
|
||||
if (!g_RTVAllowed)
|
||||
{
|
||||
PrintToChat(client, "[SM] %t", "RTV Not Allowed");
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
if (g_RTVEnded)
|
||||
{
|
||||
PrintToChat(client, "[SM] %t", "RTV Ended");
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
if (g_RTVStarted)
|
||||
{
|
||||
PrintToChat(client, "[SM] %t", "RTV Started");
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
if (GetClientCount(true) < GetConVarInt(g_Cvar_MinPlayers) && g_Votes == 0) // Should we keep checking g_Votes here?
|
||||
{
|
||||
PrintToChat(client, "[SM] %t", "Minimal Players Not Met");
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
if (g_Voted[client])
|
||||
{
|
||||
PrintToChat(client, "[SM] %t", "Already Voted");
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
new String:name[64];
|
||||
GetClientName(client, name, sizeof(name));
|
||||
|
||||
g_Votes++;
|
||||
g_Voted[client] = true;
|
||||
|
||||
PrintToChatAll("[SM] %t", "RTV Requested", name, g_Votes, g_VotesNeeded);
|
||||
|
||||
if (g_Votes >= g_VotesNeeded)
|
||||
}
|
||||
|
||||
ShiftArrayUp(g_RTVMapList, 0);
|
||||
SetArrayString(g_RTVMapList, 0, mapname);
|
||||
|
||||
while (GetArraySize(g_RTVMapList) > GetConVarInt(g_Cvar_Maps))
|
||||
{
|
||||
g_RTVStarted = true;
|
||||
CreateTimer(2.0, Timer_StartRTV, TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
}
|
||||
else if (GetConVarBool(g_Cvar_Nominate) && strcmp(text[startidx], "nominate", false) == 0)
|
||||
{
|
||||
if (g_RTVEnded)
|
||||
{
|
||||
PrintToChat(client, "[SM] %t", "RTV Ended");
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
if (g_RTVStarted)
|
||||
{
|
||||
PrintToChat(client, "[SM] %t", "RTV Started");
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
if (g_Nominated[client])
|
||||
{
|
||||
PrintToChat(client, "[SM] %t", "Already Nominated");
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
if (GetArraySize(g_RTVMapList) >= GetConVarInt(g_Cvar_Maps))
|
||||
{
|
||||
PrintToChat(client, "[SM] %t", "Max Nominations");
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
DisplayMenu(g_MapMenu, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
public Action:Timer_DelayRTV(Handle:timer)
|
||||
{
|
||||
RemoveFromArray(g_RTVMapList, GetConVarInt(g_Cvar_Maps));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PushArrayString(g_RTVMapList, mapname);
|
||||
}
|
||||
|
||||
decl String:item[64];
|
||||
for (new i = 0; i < GetMenuItemCount(g_MapMenu); i++)
|
||||
{
|
||||
GetMenuItem(g_MapMenu, i, item, sizeof(item));
|
||||
if (strcmp(item, mapname) == 0)
|
||||
{
|
||||
RemoveMenuItem(g_MapMenu, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ReplyToCommand(client, "%t", "Map Inserted", mapname);
|
||||
LogAction(client, -1, "\"%L\" inserted map \"%s\".", client, mapname);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Say(client, args)
|
||||
{
|
||||
if (!g_CanRTV || !client)
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
decl String:text[192];
|
||||
if (!GetCmdArgString(text, sizeof(text)))
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
new startidx = 0;
|
||||
if(text[strlen(text)-1] == '"')
|
||||
{
|
||||
text[strlen(text)-1] = '\0';
|
||||
startidx = 1;
|
||||
}
|
||||
|
||||
if (strcmp(text[startidx], "rtv", false) == 0 || strcmp(text[startidx], "rockthevote", false) == 0)
|
||||
{
|
||||
if (!g_RTVAllowed)
|
||||
{
|
||||
PrintToChat(client, "[SM] %t", "RTV Not Allowed");
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
if (g_RTVEnded)
|
||||
{
|
||||
PrintToChat(client, "[SM] %t", "RTV Ended");
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
if (g_RTVStarted)
|
||||
{
|
||||
PrintToChat(client, "[SM] %t", "RTV Started");
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
if (GetClientCount(true) < GetConVarInt(g_Cvar_MinPlayers) && g_Votes == 0) // Should we keep checking g_Votes here?
|
||||
{
|
||||
PrintToChat(client, "[SM] %t", "Minimal Players Not Met");
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
if (g_Voted[client])
|
||||
{
|
||||
PrintToChat(client, "[SM] %t", "Already Voted");
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
new String:name[64];
|
||||
GetClientName(client, name, sizeof(name));
|
||||
|
||||
g_Votes++;
|
||||
g_Voted[client] = true;
|
||||
|
||||
PrintToChatAll("[SM] %t", "RTV Requested", name, g_Votes, g_VotesNeeded);
|
||||
|
||||
if (g_Votes >= g_VotesNeeded)
|
||||
{
|
||||
g_RTVStarted = true;
|
||||
CreateTimer(2.0, Timer_StartRTV, TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
}
|
||||
else if (GetConVarBool(g_Cvar_Nominate) && strcmp(text[startidx], "nominate", false) == 0)
|
||||
{
|
||||
if (g_RTVEnded)
|
||||
{
|
||||
PrintToChat(client, "[SM] %t", "RTV Ended");
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
if (g_RTVStarted)
|
||||
{
|
||||
PrintToChat(client, "[SM] %t", "RTV Started");
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
if (g_Nominated[client])
|
||||
{
|
||||
PrintToChat(client, "[SM] %t", "Already Nominated");
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
if (GetArraySize(g_RTVMapList) >= GetConVarInt(g_Cvar_Maps))
|
||||
{
|
||||
PrintToChat(client, "[SM] %t", "Max Nominations");
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
DisplayMenu(g_MapMenu, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
public Action:Timer_DelayRTV(Handle:timer)
|
||||
{
|
||||
g_RTVAllowed = true;
|
||||
g_RTVStarted = false;
|
||||
g_RTVEnded = false;
|
||||
}
|
||||
|
||||
public Action:Timer_StartRTV(Handle:timer)
|
||||
{
|
||||
if (timer == g_RetryTimer)
|
||||
{
|
||||
g_RetryTimer = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
if (g_RetryTimer != INVALID_HANDLE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsVoteInProgress())
|
||||
{
|
||||
// Can't start a vote, try again in 5 seconds.
|
||||
g_RetryTimer = CreateTimer(5.0, Timer_StartRTV, TIMER_FLAG_NO_MAPCHANGE);
|
||||
return;
|
||||
}
|
||||
|
||||
PrintToChatAll("[SM] %t", "RTV Vote Ready");
|
||||
|
||||
new Handle:MapVoteMenu = CreateMenu(Handler_MapMapVoteMenu, MenuAction:MENU_ACTIONS_ALL);
|
||||
SetMenuTitle(MapVoteMenu, "Rock The Vote");
|
||||
|
||||
g_RTVEnded = false;
|
||||
}
|
||||
|
||||
public Action:Timer_StartRTV(Handle:timer)
|
||||
{
|
||||
if (timer == g_RetryTimer)
|
||||
{
|
||||
g_RetryTimer = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
if (g_RetryTimer != INVALID_HANDLE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsVoteInProgress())
|
||||
{
|
||||
// Can't start a vote, try again in 5 seconds.
|
||||
g_RetryTimer = CreateTimer(5.0, Timer_StartRTV, TIMER_FLAG_NO_MAPCHANGE);
|
||||
return;
|
||||
}
|
||||
|
||||
PrintToChatAll("[SM] %t", "RTV Vote Ready");
|
||||
|
||||
new Handle:MapVoteMenu = CreateMenu(Handler_MapMapVoteMenu, MenuAction:MENU_ACTIONS_ALL);
|
||||
SetMenuTitle(MapVoteMenu, "Rock The Vote");
|
||||
|
||||
new Handle:tempMaps = CloneArray(g_MapList);
|
||||
decl String:map[32];
|
||||
|
||||
@ -383,44 +390,44 @@ public Action:Timer_StartRTV(Handle:timer)
|
||||
}
|
||||
|
||||
CloseHandle(tempMaps);
|
||||
|
||||
AddMenuItem(MapVoteMenu, "Don't Change", "Don't Change");
|
||||
|
||||
SetMenuExitButton(MapVoteMenu, false);
|
||||
VoteMenuToAll(MapVoteMenu, 20);
|
||||
|
||||
LogMessage("[SM] Rockthevote was successfully started.");
|
||||
}
|
||||
|
||||
public Action:Timer_ChangeMap(Handle:hTimer, Handle:dp)
|
||||
{
|
||||
new String:map[65];
|
||||
|
||||
ResetPack(dp);
|
||||
ReadPackString(dp, map, sizeof(map));
|
||||
|
||||
ServerCommand("changelevel \"%s\"", map);
|
||||
|
||||
return Plugin_Stop;
|
||||
}
|
||||
|
||||
public Handler_MapMapVoteMenu(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case MenuAction_End:
|
||||
{
|
||||
CloseHandle(menu);
|
||||
}
|
||||
|
||||
case MenuAction_Display:
|
||||
{
|
||||
|
||||
AddMenuItem(MapVoteMenu, "Don't Change", "Don't Change");
|
||||
|
||||
SetMenuExitButton(MapVoteMenu, false);
|
||||
VoteMenuToAll(MapVoteMenu, 20);
|
||||
|
||||
LogMessage("[SM] Rockthevote was successfully started.");
|
||||
}
|
||||
|
||||
public Action:Timer_ChangeMap(Handle:hTimer, Handle:dp)
|
||||
{
|
||||
new String:map[65];
|
||||
|
||||
ResetPack(dp);
|
||||
ReadPackString(dp, map, sizeof(map));
|
||||
|
||||
ServerCommand("changelevel \"%s\"", map);
|
||||
|
||||
return Plugin_Stop;
|
||||
}
|
||||
|
||||
public Handler_MapMapVoteMenu(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case MenuAction_End:
|
||||
{
|
||||
CloseHandle(menu);
|
||||
}
|
||||
|
||||
case MenuAction_Display:
|
||||
{
|
||||
decl String:oldTitle[255], String:buffer[255];
|
||||
GetMenuTitle(menu, oldTitle, sizeof(oldTitle));
|
||||
Format(buffer, sizeof(buffer), "%T", oldTitle, param1);
|
||||
|
||||
new Handle:panel = Handle:param2;
|
||||
SetPanelTitle(panel, buffer);
|
||||
GetMenuTitle(menu, oldTitle, sizeof(oldTitle));
|
||||
Format(buffer, sizeof(buffer), "%T", oldTitle, param1);
|
||||
|
||||
new Handle:panel = Handle:param2;
|
||||
SetPanelTitle(panel, buffer);
|
||||
}
|
||||
|
||||
case MenuAction_DisplayItem:
|
||||
@ -431,105 +438,105 @@ public Handler_MapMapVoteMenu(Handle:menu, MenuAction:action, param1, param2)
|
||||
Format(buffer, sizeof(buffer), "%T", "Don't Change", param1);
|
||||
return RedrawMenuItem(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
// Why am I commented out? Because BAIL hasn't decided yet if
|
||||
// vote notification will be built into the Vote API.
|
||||
/*case MenuAction_Select:
|
||||
{
|
||||
decl String:Name[32], String:Map[32];
|
||||
GetClientName(param1, Name, sizeof(Name));
|
||||
GetMenuItem(menu, param2, Map, sizeof(Map));
|
||||
|
||||
PrintToChatAll("[SM] %s has voted for map '%s'", Name, Map);
|
||||
}*/
|
||||
|
||||
case MenuAction_VoteCancel:
|
||||
{
|
||||
if (param1 == VoteCancel_NoVotes)
|
||||
{
|
||||
}
|
||||
|
||||
// Why am I commented out? Because BAIL hasn't decided yet if
|
||||
// vote notification will be built into the Vote API.
|
||||
/*case MenuAction_Select:
|
||||
{
|
||||
decl String:Name[32], String:Map[32];
|
||||
GetClientName(param1, Name, sizeof(Name));
|
||||
GetMenuItem(menu, param2, Map, sizeof(Map));
|
||||
|
||||
PrintToChatAll("[SM] %s has voted for map '%s'", Name, Map);
|
||||
}*/
|
||||
|
||||
case MenuAction_VoteCancel:
|
||||
{
|
||||
if (param1 == VoteCancel_NoVotes)
|
||||
{
|
||||
PrintToChatAll("[SM] %t", "No Votes");
|
||||
g_RTVEnded = true;
|
||||
}
|
||||
}
|
||||
|
||||
case MenuAction_VoteEnd:
|
||||
{
|
||||
new String:map[64];
|
||||
|
||||
GetMenuItem(menu, param1, map, sizeof(map));
|
||||
|
||||
if (GetMenuItemCount(menu) - 1 == param1) // This should always match the "Keep Current" option
|
||||
{
|
||||
PrintToChatAll("[SM] %t", "Current Map Stays");
|
||||
LogMessage("[SM] Rockthevote has ended, current map kept.");
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintToChatAll("[SM] %t", "Changing Maps", map);
|
||||
LogMessage("[SM] Rockthevote has ended, changing to map %s.", map);
|
||||
new Handle:dp;
|
||||
CreateDataTimer(5.0, Timer_ChangeMap, dp);
|
||||
WritePackString(dp, map);
|
||||
}
|
||||
|
||||
g_RTVEnded = true;
|
||||
}
|
||||
g_RTVEnded = true;
|
||||
}
|
||||
}
|
||||
|
||||
case MenuAction_VoteEnd:
|
||||
{
|
||||
new String:map[64];
|
||||
|
||||
GetMenuItem(menu, param1, map, sizeof(map));
|
||||
|
||||
if (GetMenuItemCount(menu) - 1 == param1) // This should always match the "Keep Current" option
|
||||
{
|
||||
PrintToChatAll("[SM] %t", "Current Map Stays");
|
||||
LogMessage("[SM] Rockthevote has ended, current map kept.");
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintToChatAll("[SM] %t", "Changing Maps", map);
|
||||
LogMessage("[SM] Rockthevote has ended, changing to map %s.", map);
|
||||
new Handle:dp;
|
||||
CreateDataTimer(5.0, Timer_ChangeMap, dp);
|
||||
WritePackString(dp, map);
|
||||
}
|
||||
|
||||
g_RTVEnded = true;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Handler_MapSelectMenu(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case MenuAction_Select:
|
||||
{
|
||||
if (GetArraySize(g_RTVMapList) >= GetConVarInt(g_Cvar_Maps))
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Max Nominations");
|
||||
return;
|
||||
}
|
||||
|
||||
decl String:map[64], String:name[64];
|
||||
GetMenuItem(menu, param2, map, sizeof(map));
|
||||
|
||||
if (FindStringInArray(g_RTVMapList, map) != -1)
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Map Already Nominated");
|
||||
return;
|
||||
}
|
||||
|
||||
GetClientName(param1, name, 64);
|
||||
|
||||
PushArrayString(g_RTVMapList, map);
|
||||
RemoveMenuItem(menu, param2);
|
||||
|
||||
g_Nominated[param1] = true;
|
||||
|
||||
PrintToChatAll("[SM] %t", "Map Nominated", name, map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BuildMapMenu()
|
||||
{
|
||||
if (g_MapMenu != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(g_MapMenu);
|
||||
g_MapMenu = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
g_MapMenu = CreateMenu(Handler_MapSelectMenu);
|
||||
SetMenuTitle(g_MapMenu, "%t", "Nominate Title");
|
||||
|
||||
decl String:map[64];
|
||||
for (new i = 0; i < GetArraySize(g_MapList); i++)
|
||||
{
|
||||
GetArrayString(g_MapList, i, map, sizeof(map));
|
||||
AddMenuItem(g_MapMenu, map, map);
|
||||
}
|
||||
|
||||
SetMenuExitButton(g_MapMenu, false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Handler_MapSelectMenu(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case MenuAction_Select:
|
||||
{
|
||||
if (GetArraySize(g_RTVMapList) >= GetConVarInt(g_Cvar_Maps))
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Max Nominations");
|
||||
return;
|
||||
}
|
||||
|
||||
decl String:map[64], String:name[64];
|
||||
GetMenuItem(menu, param2, map, sizeof(map));
|
||||
|
||||
if (FindStringInArray(g_RTVMapList, map) != -1)
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Map Already Nominated");
|
||||
return;
|
||||
}
|
||||
|
||||
GetClientName(param1, name, 64);
|
||||
|
||||
PushArrayString(g_RTVMapList, map);
|
||||
RemoveMenuItem(menu, param2);
|
||||
|
||||
g_Nominated[param1] = true;
|
||||
|
||||
PrintToChatAll("[SM] %t", "Map Nominated", name, map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BuildMapMenu()
|
||||
{
|
||||
if (g_MapMenu != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(g_MapMenu);
|
||||
g_MapMenu = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
g_MapMenu = CreateMenu(Handler_MapSelectMenu);
|
||||
SetMenuTitle(g_MapMenu, "%t", "Nominate Title");
|
||||
|
||||
decl String:map[64];
|
||||
for (new i = 0; i < GetArraySize(g_MapList); i++)
|
||||
{
|
||||
GetArrayString(g_MapList, i, map, sizeof(map));
|
||||
AddMenuItem(g_MapMenu, map, map);
|
||||
}
|
||||
|
||||
SetMenuExitButton(g_MapMenu, false);
|
||||
}
|
Loading…
Reference in New Issue
Block a user