Merge pull request #199 from alliedmodders/tr-convars

Port ConVars to transitional syntax.
This commit is contained in:
David Anderson 2014-11-19 22:38:56 -08:00
commit 08388de7dd
23 changed files with 883 additions and 670 deletions

View File

@ -1182,28 +1182,19 @@ static cell_t SendConVarValue(IPluginContext *pContext, const cell_t *params)
CPlayer *pPlayer = g_Players.GetPlayerByIndex(params[1]);
if (!pPlayer)
{
return pContext->ThrowNativeError("Client index %d is invalid", params[1]);
}
if (!pPlayer->IsConnected())
{
return pContext->ThrowNativeError("Client %d is not connected", params[1]);
}
if (pPlayer->IsFakeClient())
{
return pContext->ThrowNativeError("Client %d is fake and cannot be targeted", params[1]);
}
INetChannel *netchan = static_cast<INetChannel *>(engine->GetPlayerNetInfo(params[1]));
if (netchan == NULL)
{
return 0;
}
netchan->SendData(buffer);
return 1;
}
@ -1247,6 +1238,59 @@ static cell_t RemoveCommandListener(IPluginContext *pContext, const cell_t *para
return 1;
}
static cell_t ConVar_BoolValue_set(IPluginContext *pContext, const cell_t *params)
{
static cell_t new_params[5] = {
4,
params[1],
params[2],
0, /* Default replicate setting. */
0, /* Default replicate setting. */
};
return sm_SetConVarNum(pContext, new_params);
}
static cell_t ConVar_IntValue_set(IPluginContext *pContext, const cell_t *params)
{
static cell_t new_params[5] = {
4,
params[1],
params[2],
0, /* Default replicate setting. */
0, /* Default replicate setting. */
};
return sm_SetConVarNum(pContext, new_params);
}
static cell_t ConVar_FloatValue_set(IPluginContext *pContext, const cell_t *params)
{
static cell_t new_params[5] = {
4,
params[1],
params[2],
0, /* Default replicate setting. */
0, /* Default replicate setting. */
};
return sm_SetConVarFloat(pContext, new_params);
}
static cell_t ConVar_ReplicateToClient(IPluginContext *pContext, const cell_t *params)
{
// Old version is (client, handle, value).
// New version is (handle, client, value).
static cell_t new_params[4] = {
3,
params[2],
params[1],
params[3],
};
return SendConVarValue(pContext, new_params);
}
REGISTER_NATIVES(consoleNatives)
{
{"CreateConVar", sm_CreateConVar},
@ -1287,5 +1331,29 @@ REGISTER_NATIVES(consoleNatives)
{"SendConVarValue", SendConVarValue},
{"AddCommandListener", AddCommandListener},
{"RemoveCommandListener", RemoveCommandListener},
// Transitional syntax support.
{"ConVar.BoolValue.get", sm_GetConVarBool},
{"ConVar.BoolValue.set", ConVar_BoolValue_set},
{"ConVar.FloatValue.get", sm_GetConVarFloat},
{"ConVar.FloatValue.set", ConVar_FloatValue_set},
{"ConVar.IntValue.get", sm_GetConVarInt},
{"ConVar.IntValue.set", ConVar_IntValue_set},
{"ConVar.Flags.get", sm_GetConVarFlags},
{"ConVar.Flags.set", sm_SetConVarFlags},
{"ConVar.SetBool", sm_SetConVarNum},
{"ConVar.SetInt", sm_SetConVarNum},
{"ConVar.SetFloat", sm_SetConVarFloat},
{"ConVar.GetString", sm_GetConVarString},
{"ConVar.SetString", sm_SetConVarString},
{"ConVar.RestoreDefault", sm_ResetConVar},
{"ConVar.GetDefault", GetConVarDefault},
{"ConVar.GetBounds", sm_GetConVarBounds},
{"ConVar.SetBounds", sm_SetConVarBounds},
{"ConVar.GetName", sm_GetConVarName},
{"ConVar.ReplicateToClient", ConVar_ReplicateToClient},
{"ConVar.AddChangeHook", sm_HookConVarChange},
{"ConVar.RemoveChangeHook", sm_UnhookConVarChange},
{NULL, NULL}
};

View File

@ -47,7 +47,7 @@ public Plugin:myinfo =
new Float:g_LastTime[MAXPLAYERS + 1] = {0.0, ...}; /* Last time player used say or say_team */
new g_FloodTokens[MAXPLAYERS + 1] = {0, ...}; /* Number of flood tokens player has */
new Handle:sm_flood_time; /* Handle to sm_flood_time convar */
ConVar sm_flood_time; /* Handle to sm_flood_time convar */
public OnPluginStart()
{
@ -60,11 +60,11 @@ public OnClientPutInServer(client)
g_FloodTokens[client] = 0;
}
new Float:max_chat;
float max_chat;
public bool:OnClientFloodCheck(client)
public bool OnClientFloodCheck(int client)
{
max_chat = GetConVarFloat(sm_flood_time);
max_chat = sm_flood_time.FloatValue;
if (max_chat <= 0.0
|| CheckCommandAccess(client, "sm_flood_access", ADMFLAG_ROOT, true))

View File

@ -49,7 +49,7 @@ public Plugin:myinfo =
new String:g_ColorNames[13][10] = {"White", "Red", "Green", "Blue", "Yellow", "Purple", "Cyan", "Orange", "Pink", "Olive", "Lime", "Violet", "Lightblue"};
new g_Colors[13][3] = {{255,255,255},{255,0,0},{0,255,0},{0,0,255},{255,255,0},{255,0,255},{0,255,255},{255,128,0},{255,0,128},{128,255,0},{0,255,128},{128,0,255},{0,128,255}};
new Handle:g_Cvar_Chatmode = INVALID_HANDLE;
ConVar g_Cvar_Chatmode;
new EngineVersion:g_GameEngine = Engine_Unknown;
@ -136,7 +136,7 @@ public Action:OnClientSayCommand(client, const String:command[], const String:sA
}
else if (strcmp(command, "say_team", false) == 0 || strcmp(command, "say_squad", false) == 0)
{
if (!CheckCommandAccess(client, "sm_chat", ADMFLAG_CHAT) && !GetConVarBool(g_Cvar_Chatmode))
if (!CheckCommandAccess(client, "sm_chat", ADMFLAG_CHAT) && !g_Cvar_Chatmode.BoolValue)
{
return Plugin_Continue;
}

View File

@ -50,8 +50,8 @@ public Plugin:myinfo =
new bool:g_Muted[MAXPLAYERS+1]; // Is the player muted?
new bool:g_Gagged[MAXPLAYERS+1]; // Is the player gagged?
new Handle:g_Cvar_Deadtalk = INVALID_HANDLE; // Holds the handle for sm_deadtalk
new Handle:g_Cvar_Alltalk = INVALID_HANDLE; // Holds the handle for sv_alltalk
ConVar g_Cvar_Deadtalk; // Holds the handle for sm_deadtalk
ConVar g_Cvar_Alltalk; // Holds the handle for sv_alltalk
new bool:g_Hooked = false; // Tracks if we've hooked events for deadtalk
TopMenu hTopMenu;
@ -89,8 +89,8 @@ public OnPluginStart()
RegAdminCmd("sm_ungag", Command_Ungag, ADMFLAG_CHAT, "sm_ungag <player> - Restores a player's ability to use chat.");
RegAdminCmd("sm_unsilence", Command_Unsilence, ADMFLAG_CHAT, "sm_unsilence <player> - Restores a player's ability to use voice and chat.");
HookConVarChange(g_Cvar_Deadtalk, ConVarChange_Deadtalk);
HookConVarChange(g_Cvar_Alltalk, ConVarChange_Alltalk);
g_Cvar_Deadtalk.AddChangeHook(ConVarChange_Deadtalk);
g_Cvar_Alltalk.AddChangeHook(ConVarChange_Alltalk);
/* Account for late loading */
TopMenu topmenu;
@ -122,7 +122,7 @@ public OnAdminMenuReady(TopMenu topmenu)
public ConVarChange_Deadtalk(Handle:convar, const String:oldValue[], const String:newValue[])
{
if (GetConVarInt(g_Cvar_Deadtalk))
if (g_Cvar_Deadtalk.IntValue)
{
HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Post);
HookEvent("player_death", Event_PlayerDeath, EventHookMode_Post);
@ -155,11 +155,11 @@ public Action:OnClientSayCommand(client, const String:command[], const String:sA
return Plugin_Continue;
}
public ConVarChange_Alltalk(Handle:convar, const String:oldValue[], const String:newValue[])
public void ConVarChange_Alltalk(ConVar convar, const char[] oldValue, const char[] newValue)
{
new mode = GetConVarInt(g_Cvar_Deadtalk);
int mode = g_Cvar_Deadtalk.IntValue;
for (new i = 1; i <= MaxClients; i++)
for (int i = 1; i <= MaxClients; i++)
{
if (!IsClientInGame(i))
{
@ -170,7 +170,7 @@ public ConVarChange_Alltalk(Handle:convar, const String:oldValue[], const String
{
SetClientListeningFlags(i, VOICE_MUTED);
}
else if (GetConVarBool(g_Cvar_Alltalk))
else if (g_Cvar_Alltalk.BoolValue)
{
SetClientListeningFlags(i, VOICE_NORMAL);
}
@ -209,7 +209,7 @@ public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
int client = GetClientOfUserId(GetEventInt(event, "userid"));
if (!client)
{
@ -222,13 +222,13 @@ public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
return;
}
if (GetConVarBool(g_Cvar_Alltalk))
if (g_Cvar_Alltalk.BoolValue)
{
SetClientListeningFlags(client, VOICE_NORMAL);
return;
}
new mode = GetConVarInt(g_Cvar_Deadtalk);
int mode = g_Cvar_Deadtalk.IntValue;
if (mode == 1)
{
SetClientListeningFlags(client, VOICE_LISTENALL);

View File

@ -233,11 +233,11 @@ PerformMute(client, target, bool:silent=false)
PerformUnMute(client, target, bool:silent=false)
{
g_Muted[target] = false;
if (GetConVarInt(g_Cvar_Deadtalk) == 1 && !IsPlayerAlive(target))
if (g_Cvar_Deadtalk.IntValue == 1 && !IsPlayerAlive(target))
{
SetClientListeningFlags(target, VOICE_LISTENALL);
}
else if (GetConVarInt(g_Cvar_Deadtalk) == 2 && !IsPlayerAlive(target))
else if (g_Cvar_Deadtalk.IntValue == 2 && !IsPlayerAlive(target))
{
SetClientListeningFlags(target, VOICE_TEAM);
}
@ -306,11 +306,11 @@ PerformUnSilence(client, target)
{
g_Muted[target] = false;
if (GetConVarInt(g_Cvar_Deadtalk) == 1 && !IsPlayerAlive(target))
if (g_Cvar_Deadtalk.IntValue == 1 && !IsPlayerAlive(target))
{
SetClientListeningFlags(target, VOICE_LISTENALL);
}
else if (GetConVarInt(g_Cvar_Deadtalk) == 2 && !IsPlayerAlive(target))
else if (g_Cvar_Deadtalk.IntValue == 2 && !IsPlayerAlive(target))
{
SetClientListeningFlags(target, VOICE_TEAM);
}

View File

@ -85,7 +85,7 @@ public OnPluginStart()
SetMenuTitle(g_MapList, "%T", "Please select a map", LANG_SERVER);
SetMenuExitBackButton(g_MapList, true);
decl String:mapListPath[PLATFORM_MAX_PATH];
char mapListPath[PLATFORM_MAX_PATH];
BuildPath(Path_SM, mapListPath, sizeof(mapListPath), "configs/adminmenu_maplist.ini");
SetMapListCompatBind("sm_map menu", mapListPath);
@ -118,7 +118,7 @@ bool:IsVarProtected(const String:cvar[])
bool:IsClientAllowedToChangeCvar(client, const String:cvarname[])
{
new Handle:hndl = FindConVar(cvarname);
ConVar hndl = FindConVar(cvarname);
new bool:allowed = false;
new client_flags = client == 0 ? ADMFLAG_ROOT : GetUserFlagBits(client);
@ -129,7 +129,7 @@ bool:IsClientAllowedToChangeCvar(client, const String:cvarname[])
}
else
{
if (GetConVarFlags(hndl) & FCVAR_PROTECTED)
if (hndl.Flags & FCVAR_PROTECTED)
{
allowed = ((client_flags & ADMFLAG_PASSWORD) == ADMFLAG_PASSWORD);
}
@ -212,7 +212,7 @@ new String:g_FlagNames[FLAG_STRINGS][20] =
CustomFlagsToString(String:buffer[], maxlength, flags)
{
decl String:joins[6][6];
char joins[6][6];
new total;
for (new i=_:Admin_Custom1; i<=_:Admin_Custom6; i++)
@ -230,7 +230,7 @@ CustomFlagsToString(String:buffer[], maxlength, flags)
FlagsToString(String:buffer[], maxlength, flags)
{
decl String:joins[FLAG_STRINGS+1][32];
char joins[FLAG_STRINGS+1][32];
new total;
for (new i=0; i<FLAG_STRINGS; i++)
@ -241,7 +241,7 @@ FlagsToString(String:buffer[], maxlength, flags)
}
}
decl String:custom_flags[32];
char custom_flags[32];
if (CustomFlagsToString(custom_flags, sizeof(custom_flags), flags))
{
Format(joins[total++], 32, "custom(%s)", custom_flags);
@ -265,7 +265,7 @@ public Action:Command_Cvar(client, args)
return Plugin_Handled;
}
decl String:cvarname[64];
char cvarname[64];
GetCmdArg(1, cvarname, sizeof(cvarname));
if (client == 0 && StrEqual(cvarname, "protect"))
@ -281,7 +281,7 @@ public Action:Command_Cvar(client, args)
return Plugin_Handled;
}
new Handle:hndl = FindConVar(cvarname);
ConVar hndl = FindConVar(cvarname);
if (hndl == INVALID_HANDLE)
{
ReplyToCommand(client, "[SM] %t", "Unable to find cvar", cvarname);
@ -294,10 +294,10 @@ public Action:Command_Cvar(client, args)
return Plugin_Handled;
}
decl String:value[255];
char value[255];
if (args < 2)
{
GetConVarString(hndl, value, sizeof(value));
hndl.GetString(value, sizeof(value));
ReplyToCommand(client, "[SM] %t", "Value of cvar", cvarname, value);
return Plugin_Handled;
@ -305,7 +305,7 @@ public Action:Command_Cvar(client, args)
GetCmdArg(2, value, sizeof(value));
if ((GetConVarFlags(hndl) & FCVAR_PROTECTED) != FCVAR_PROTECTED)
if ((hndl.Flags & FCVAR_PROTECTED) != FCVAR_PROTECTED)
{
ShowActivity2(client, "[SM] ", "%t", "Cvar changed", cvarname, value);
}
@ -316,7 +316,7 @@ public Action:Command_Cvar(client, args)
LogAction(client, -1, "\"%L\" changed cvar (cvar \"%s\") (value \"%s\")", client, cvarname, value);
SetConVarString(hndl, value, true);
hndl.SetString(value, true);
return Plugin_Handled;
}
@ -330,10 +330,10 @@ public Action:Command_ResetCvar(client, args)
return Plugin_Handled;
}
decl String:cvarname[64];
char cvarname[64];
GetCmdArg(1, cvarname, sizeof(cvarname));
new Handle:hndl = FindConVar(cvarname);
ConVar hndl = FindConVar(cvarname);
if (hndl == INVALID_HANDLE)
{
ReplyToCommand(client, "[SM] %t", "Unable to find cvar", cvarname);
@ -346,12 +346,12 @@ public Action:Command_ResetCvar(client, args)
return Plugin_Handled;
}
ResetConVar(hndl);
hndl.RestoreDefault();
decl String:value[255];
GetConVarString(hndl, value, sizeof(value));
char value[255];
hndl.GetString(value, sizeof(value));
if ((GetConVarFlags(hndl) & FCVAR_PROTECTED) != FCVAR_PROTECTED)
if ((hndl.Flags & FCVAR_PROTECTED) != FCVAR_PROTECTED)
{
ShowActivity2(client, "[SM] ", "%t", "Cvar changed", cvarname, value);
}
@ -373,7 +373,7 @@ public Action:Command_Rcon(client, args)
return Plugin_Handled;
}
decl String:argstring[255];
char argstring[255];
GetCmdArgString(argstring, sizeof(argstring));
LogAction(client, -1, "\"%L\" console command (cmdline \"%s\")", client, argstring);

View File

@ -48,15 +48,15 @@ public Plugin:myinfo =
url = "http://www.sourcemod.net/"
};
new Handle:g_Cvar_TriggerShow = INVALID_HANDLE;
new Handle:g_Cvar_TimeleftInterval = INVALID_HANDLE;
new Handle:g_Cvar_FriendlyFire = INVALID_HANDLE;
ConVar g_Cvar_TriggerShow;
ConVar g_Cvar_TimeleftInterval;
ConVar g_Cvar_FriendlyFire;
new Handle:g_Timer_TimeShow = INVALID_HANDLE;
new Handle:g_Cvar_WinLimit = INVALID_HANDLE;
new Handle:g_Cvar_FragLimit = INVALID_HANDLE;
new Handle:g_Cvar_MaxRounds = INVALID_HANDLE;
ConVar g_Cvar_WinLimit;
ConVar g_Cvar_FragLimit;
ConVar g_Cvar_MaxRounds;
#define TIMELEFT_ALL_ALWAYS 0 /* Print to all players */
#define TIMELEFT_ALL_MAYBE 1 /* Print to all players if sm_trigger_show allows */
@ -80,7 +80,7 @@ public OnPluginStart()
RegConsoleCmd("motd", Command_Motd);
RegConsoleCmd("ff", Command_FriendlyFire);
HookConVarChange(g_Cvar_TimeleftInterval, ConVarChange_TimeleftInterval);
g_Cvar_TimeleftInterval.AddChangeHook(ConVarChange_TimeleftInterval);
decl String:folder[64];
GetGameFolderName(folder, sizeof(folder));
@ -257,10 +257,10 @@ public OnClientSayCommand_Post(client, const String:command[], const String:sArg
}
else if (strcmp(sArgs, "thetime", false) == 0)
{
decl String:ctime[64];
char ctime[64];
FormatTime(ctime, 64, NULL_STRING);
if(GetConVarInt(g_Cvar_TriggerShow))
if (g_Cvar_TriggerShow.IntValue)
{
PrintToChatAll("[SM] %t", "Thetime", ctime);
}
@ -275,10 +275,10 @@ public OnClientSayCommand_Post(client, const String:command[], const String:sArg
}
else if (strcmp(sArgs, "currentmap", false) == 0)
{
decl String:map[64];
char map[64];
GetCurrentMap(map, sizeof(map));
if(GetConVarInt(g_Cvar_TriggerShow))
if (g_Cvar_TriggerShow.IntValue)
{
PrintToChatAll("[SM] %t", "Current Map", map);
}
@ -289,10 +289,10 @@ public OnClientSayCommand_Post(client, const String:command[], const String:sArg
}
else if (strcmp(sArgs, "nextmap", false) == 0)
{
decl String:map[32];
char map[32];
GetNextMap(map, sizeof(map));
if(GetConVarInt(g_Cvar_TriggerShow))
if (g_Cvar_TriggerShow.IntValue)
{
if (mapchooser && EndOfMapVoteEnabled() && !HasEndOfMapVoteFinished())
{
@ -323,15 +323,14 @@ public OnClientSayCommand_Post(client, const String:command[], const String:sArg
ShowTimeLeft(client, who)
{
new bool:lastround = false;
new bool:written = false;
new bool:notimelimit = false;
bool lastround = false;
bool written = false;
bool notimelimit = false;
decl String:finalOutput[1024];
finalOutput[0] = 0;
char finalOutput[1024];
if (who == TIMELEFT_ALL_ALWAYS
|| (who == TIMELEFT_ALL_MAYBE && GetConVarInt(g_Cvar_TriggerShow)))
|| (who == TIMELEFT_ALL_MAYBE && g_Cvar_TriggerShow.IntValue))
{
client = 0;
}
@ -362,9 +361,9 @@ ShowTimeLeft(client, who)
if (!lastround)
{
if (g_Cvar_WinLimit != INVALID_HANDLE)
if (g_Cvar_WinLimit)
{
new winlimit = GetConVarInt(g_Cvar_WinLimit);
int winlimit = g_Cvar_WinLimit.IntValue;
if (winlimit > 0)
{
@ -399,9 +398,9 @@ ShowTimeLeft(client, who)
}
}
if (g_Cvar_FragLimit != INVALID_HANDLE)
if (g_Cvar_FragLimit)
{
new fraglimit = GetConVarInt(g_Cvar_FragLimit);
int fraglimit = g_Cvar_FragLimit.IntValue;
if (fraglimit > 0)
{
@ -436,9 +435,9 @@ ShowTimeLeft(client, who)
}
}
if (g_Cvar_MaxRounds != INVALID_HANDLE)
if (g_Cvar_MaxRounds)
{
new maxrounds = GetConVarInt(g_Cvar_MaxRounds);
int maxrounds = g_Cvar_MaxRounds.IntValue;
if (maxrounds > 0)
{
@ -486,7 +485,7 @@ ShowTimeLeft(client, who)
}
if (who == TIMELEFT_ALL_ALWAYS
|| (who == TIMELEFT_ALL_MAYBE && GetConVarInt(g_Cvar_TriggerShow)))
|| (who == TIMELEFT_ALL_MAYBE && g_Cvar_TriggerShow.IntValue))
{
PrintToChatAll("[SM] %s", finalOutput);
}
@ -503,10 +502,10 @@ ShowTimeLeft(client, who)
ShowFriendlyFire(client)
{
if (g_Cvar_FriendlyFire != INVALID_HANDLE)
if (g_Cvar_FriendlyFire)
{
decl String:phrase[24];
if (GetConVarBool(g_Cvar_FriendlyFire))
char phrase[24];
if (g_Cvar_FriendlyFire.BoolValue)
{
strcopy(phrase, sizeof(phrase), "Friendly Fire On");
}
@ -515,7 +514,7 @@ ShowFriendlyFire(client)
strcopy(phrase, sizeof(phrase), "Friendly Fire Off");
}
if(GetConVarInt(g_Cvar_TriggerShow))
if (g_Cvar_TriggerShow.IntValue)
{
PrintToChatAll("[SM] %t", phrase);
}

View File

@ -51,7 +51,7 @@ public Plugin:myinfo =
new Handle:g_hVoteMenu = INVALID_HANDLE;
new Handle:g_Cvar_Limits[3] = {INVALID_HANDLE, ...};
ConVar g_Cvar_Limits[3] = {null, ...};
//new Handle:g_Cvar_VoteSay = INVALID_HANDLE;
enum voteType
@ -262,8 +262,9 @@ public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2)
}
else if (action == MenuAction_VoteEnd)
{
decl String:item[64], String:display[64];
new Float:percent, Float:limit, votes, totalVotes;
char item[64], display[64];
float percent, limit;
int votes, totalVotes;
GetMenuVoteInfo(param2, votes, totalVotes);
GetMenuItem(menu, param1, item, sizeof(item), _, display, sizeof(display));
@ -277,7 +278,7 @@ public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2)
if (g_voteType != voteType:question)
{
limit = GetConVarFloat(g_Cvar_Limits[g_voteType]);
limit = g_Cvar_Limits[g_voteType].FloatValue;
}
/* :TODO: g_voteClient[userid] needs to be checked */

View File

@ -33,7 +33,7 @@
new g_BeaconSerial[MAXPLAYERS+1] = { 0, ... };
new Handle:g_Cvar_BeaconRadius = INVALID_HANDLE;
ConVar g_Cvar_BeaconRadius;
CreateBeacon(client)
{
@ -86,28 +86,28 @@ public Action:Timer_Beacon(Handle:timer, any:value)
return Plugin_Stop;
}
new team = GetClientTeam(client);
int team = GetClientTeam(client);
new Float:vec[3];
float vec[3];
GetClientAbsOrigin(client, vec);
vec[2] += 10;
if (g_BeamSprite > -1 && g_HaloSprite > -1)
{
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_BeaconRadius), g_BeamSprite, g_HaloSprite, 0, 15, 0.5, 5.0, 0.0, greyColor, 10, 0);
TE_SetupBeamRingPoint(vec, 10.0, g_Cvar_BeaconRadius.FloatValue, g_BeamSprite, g_HaloSprite, 0, 15, 0.5, 5.0, 0.0, greyColor, 10, 0);
TE_SendToAll();
if (team == 2)
{
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_BeaconRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, redColor, 10, 0);
TE_SetupBeamRingPoint(vec, 10.0, g_Cvar_BeaconRadius.FloatValue, g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, redColor, 10, 0);
}
else if (team == 3)
{
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_BeaconRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, blueColor, 10, 0);
TE_SetupBeamRingPoint(vec, 10.0, g_Cvar_BeaconRadius.FloatValue, g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, blueColor, 10, 0);
}
else
{
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_BeaconRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, greenColor, 10, 0);
TE_SetupBeamRingPoint(vec, 10.0, g_Cvar_BeaconRadius.FloatValue, g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, greenColor, 10, 0);
}
TE_SendToAll();

View File

@ -34,16 +34,16 @@
new g_FireBombSerial[MAXPLAYERS+1] = { 0, ... };
new g_FireBombTime[MAXPLAYERS+1] = { 0, ... };
new Handle:g_Cvar_BurnDuration = INVALID_HANDLE;
new Handle:g_Cvar_FireBombTicks = INVALID_HANDLE;
new Handle:g_Cvar_FireBombRadius = INVALID_HANDLE;
new Handle:g_Cvar_FireBombMode = INVALID_HANDLE;
ConVar g_Cvar_BurnDuration;
ConVar g_Cvar_FireBombTicks;
ConVar g_Cvar_FireBombRadius;
ConVar g_Cvar_FireBombMode;
CreateFireBomb(client)
{
g_FireBombSerial[client] = ++g_Serial_Gen;
CreateTimer(1.0, Timer_FireBomb, client | (g_Serial_Gen << 7), DEFAULT_TIMER_FLAGS);
g_FireBombTime[client] = GetConVarInt(g_Cvar_FireBombTicks);
g_FireBombTime[client] = g_Cvar_FireBombTicks.IntValue;
}
KillFireBomb(client)
@ -99,16 +99,16 @@ public Action:Timer_FireBomb(Handle:timer, any:value)
}
g_FireBombTime[client]--;
new Float:vec[3];
float vec[3];
GetClientEyePosition(client, vec);
if (g_FireBombTime[client] > 0)
{
new color;
int color;
if (g_FireBombTime[client] > 1)
{
color = RoundToFloor(g_FireBombTime[client] * (255.0 / GetConVarFloat(g_Cvar_FireBombTicks)));
color = RoundToFloor(g_FireBombTime[client] * (255.0 / g_Cvar_FireBombTicks.FloatValue));
if (g_BeepSound[0])
{
EmitAmbientSound(g_BeepSound, vec, client, SNDLEVEL_RAIDSIREN);
@ -125,7 +125,7 @@ public Action:Timer_FireBomb(Handle:timer, any:value)
SetEntityRenderColor(client, 255, color, color, 255);
decl String:name[64];
char name[64];
GetClientName(client, name, sizeof(name));
PrintCenterTextAll("%t", "Till Explodes", name, g_FireBombTime[client]);
@ -134,9 +134,9 @@ public Action:Timer_FireBomb(Handle:timer, any:value)
GetClientAbsOrigin(client, vec);
vec[2] += 10;
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_FireBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 15, 0.5, 5.0, 0.0, greyColor, 10, 0);
TE_SetupBeamRingPoint(vec, 10.0, g_Cvar_FireBombRadius.FloatValue / 3.0, g_BeamSprite, g_HaloSprite, 0, 15, 0.5, 5.0, 0.0, greyColor, 10, 0);
TE_SendToAll();
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_FireBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, whiteColor, 10, 0);
TE_SetupBeamRingPoint(vec, 10.0, g_Cvar_FireBombRadius.FloatValue / 3.0, g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, whiteColor, 10, 0);
TE_SendToAll();
}
return Plugin_Continue;
@ -145,7 +145,7 @@ public Action:Timer_FireBomb(Handle:timer, any:value)
{
if (g_ExplosionSprite > -1)
{
TE_SetupExplosion(vec, g_ExplosionSprite, 0.1, 1, 0, GetConVarInt(g_Cvar_FireBombRadius), 5000);
TE_SetupExplosion(vec, g_ExplosionSprite, 0.1, 1, 0, g_Cvar_FireBombRadius.IntValue, 5000);
TE_SendToAll();
}
@ -153,16 +153,16 @@ public Action:Timer_FireBomb(Handle:timer, any:value)
{
GetClientAbsOrigin(client, vec);
vec[2] += 10;
TE_SetupBeamRingPoint(vec, 50.0, GetConVarFloat(g_Cvar_FireBombRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.5, 30.0, 1.5, orangeColor, 5, 0);
TE_SetupBeamRingPoint(vec, 50.0, g_Cvar_FireBombRadius.FloatValue, g_BeamSprite, g_HaloSprite, 0, 10, 0.5, 30.0, 1.5, orangeColor, 5, 0);
TE_SendToAll();
vec[2] += 15;
TE_SetupBeamRingPoint(vec, 40.0, GetConVarFloat(g_Cvar_FireBombRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 30.0, 1.5, orangeColor, 5, 0);
TE_SetupBeamRingPoint(vec, 40.0, g_Cvar_FireBombRadius.FloatValue, g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 30.0, 1.5, orangeColor, 5, 0);
TE_SendToAll();
vec[2] += 15;
TE_SetupBeamRingPoint(vec, 30.0, GetConVarFloat(g_Cvar_FireBombRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.7, 30.0, 1.5, orangeColor, 5, 0);
TE_SetupBeamRingPoint(vec, 30.0, g_Cvar_FireBombRadius.FloatValue, g_BeamSprite, g_HaloSprite, 0, 10, 0.7, 30.0, 1.5, orangeColor, 5, 0);
TE_SendToAll();
vec[2] += 15;
TE_SetupBeamRingPoint(vec, 20.0, GetConVarFloat(g_Cvar_FireBombRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.8, 30.0, 1.5, orangeColor, 5, 0);
TE_SetupBeamRingPoint(vec, 20.0, g_Cvar_FireBombRadius.FloatValue, g_BeamSprite, g_HaloSprite, 0, 10, 0.8, 30.0, 1.5, orangeColor, 5, 0);
TE_SendToAll();
}
@ -171,13 +171,13 @@ public Action:Timer_FireBomb(Handle:timer, any:value)
EmitAmbientSound(g_BoomSound, vec, client, SNDLEVEL_RAIDSIREN);
}
IgniteEntity(client, GetConVarFloat(g_Cvar_BurnDuration));
IgniteEntity(client, g_Cvar_BurnDuration.FloatValue);
KillFireBomb(client);
SetEntityRenderColor(client, 255, 255, 255, 255);
if (GetConVarInt(g_Cvar_FireBombMode) > 0)
if (g_Cvar_FireBombMode.IntValue > 0)
{
new teamOnly = ((GetConVarInt(g_Cvar_FireBombMode) == 1) ? true : false);
int teamOnly = ((g_Cvar_FireBombMode.IntValue == 1) ? true : false);
for (new i = 1; i <= MaxClients; i++)
{
@ -191,18 +191,18 @@ public Action:Timer_FireBomb(Handle:timer, any:value)
continue;
}
new Float:pos[3];
float pos[3];
GetClientAbsOrigin(i, pos);
new Float:distance = GetVectorDistance(vec, pos);
float distance = GetVectorDistance(vec, pos);
if (distance > GetConVarFloat(g_Cvar_FireBombRadius))
if (distance > g_Cvar_FireBombRadius.FloatValue)
{
continue;
}
new Float:duration = GetConVarFloat(g_Cvar_BurnDuration);
duration *= (GetConVarFloat(g_Cvar_FireBombRadius) - distance) / GetConVarFloat(g_Cvar_FireBombRadius);
float duration = g_Cvar_BurnDuration.FloatValue;
duration *= (g_Cvar_FireBombRadius.FloatValue - distance) / g_Cvar_FireBombRadius.FloatValue;
IgniteEntity(i, duration);
}
@ -372,14 +372,14 @@ public Action:Command_Burn(client, args)
return Plugin_Handled;
}
decl String:arg[65];
char arg[65];
GetCmdArg(1, arg, sizeof(arg));
new Float:seconds = GetConVarFloat(g_Cvar_BurnDuration);
float seconds = g_Cvar_BurnDuration.FloatValue;
if (args > 1)
{
decl String:time[20];
char time[20];
GetCmdArg(2, time, sizeof(time));
if (StringToFloatEx(time, seconds) == 0)
{
@ -388,8 +388,9 @@ public Action:Command_Burn(client, args)
}
}
decl String:target_name[MAX_TARGET_LENGTH];
decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
char target_name[MAX_TARGET_LENGTH];
int target_list[MAXPLAYERS], target_count;
bool tn_is_ml;
if ((target_count = ProcessTargetString(
arg,
@ -430,11 +431,12 @@ public Action:Command_FireBomb(client, args)
return Plugin_Handled;
}
decl String:arg[65];
char arg[65];
GetCmdArg(1, arg, sizeof(arg));
decl String:target_name[MAX_TARGET_LENGTH];
decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
char target_name[MAX_TARGET_LENGTH];
int target_list[MAXPLAYERS], target_count;
bool tn_is_ml;
if ((target_count = ProcessTargetString(
arg,

View File

@ -36,10 +36,10 @@ new g_FreezeBombSerial[MAXPLAYERS+1] = { 0, ... };
new g_FreezeTime[MAXPLAYERS+1] = { 0, ... };
new g_FreezeBombTime[MAXPLAYERS+1] = { 0, ... };
new Handle:g_Cvar_FreezeDuration = INVALID_HANDLE;
new Handle:g_Cvar_FreezeBombTicks = INVALID_HANDLE;
new Handle:g_Cvar_FreezeBombRadius = INVALID_HANDLE;
new Handle:g_Cvar_FreezeBombMode = INVALID_HANDLE;
ConVar g_Cvar_FreezeDuration;
ConVar g_Cvar_FreezeBombTicks;
ConVar g_Cvar_FreezeBombRadius;
ConVar g_Cvar_FreezeBombMode;
FreezeClient(client, time)
{
@ -93,7 +93,7 @@ CreateFreezeBomb(client)
KillFreezeBomb(client);
return;
}
g_FreezeBombTime[client] = GetConVarInt(g_Cvar_FreezeBombTicks);
g_FreezeBombTime[client] = g_Cvar_FreezeBombTicks.IntValue;
g_FreezeBombSerial[client] = ++g_Serial_Gen;
CreateTimer(1.0, Timer_FreezeBomb, client | (g_Serial_Gen << 7), DEFAULT_TIMER_FLAGS);
}
@ -229,7 +229,7 @@ public Action:Timer_FreezeBomb(Handle:timer, any:value)
if (g_FreezeBombTime[client] > 1)
{
color = RoundToFloor(g_FreezeBombTime[client] * (255.0 / GetConVarFloat(g_Cvar_FreezeBombTicks)));
color = RoundToFloor(g_FreezeBombTime[client] * (255.0 / g_Cvar_FreezeBombTicks.FloatValue));
if (g_BeepSound[0])
{
EmitAmbientSound(g_BeepSound, vec, client, SNDLEVEL_RAIDSIREN);
@ -246,7 +246,7 @@ public Action:Timer_FreezeBomb(Handle:timer, any:value)
SetEntityRenderColor(client, color, color, 255, 255);
decl String:name[64];
char name[64];
GetClientName(client, name, sizeof(name));
PrintCenterTextAll("%t", "Till Explodes", name, g_FreezeBombTime[client]);
@ -255,9 +255,9 @@ public Action:Timer_FreezeBomb(Handle:timer, any:value)
GetClientAbsOrigin(client, vec);
vec[2] += 10;
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_FreezeBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 15, 0.5, 5.0, 0.0, greyColor, 10, 0);
TE_SetupBeamRingPoint(vec, 10.0, g_Cvar_FreezeBombRadius.FloatValue / 3.0, g_BeamSprite, g_HaloSprite, 0, 15, 0.5, 5.0, 0.0, greyColor, 10, 0);
TE_SendToAll();
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_FreezeBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, whiteColor, 10, 0);
TE_SetupBeamRingPoint(vec, 10.0, g_Cvar_FreezeBombRadius.FloatValue / 3.0, g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, whiteColor, 10, 0);
TE_SendToAll();
}
return Plugin_Continue;
@ -266,7 +266,7 @@ public Action:Timer_FreezeBomb(Handle:timer, any:value)
{
if (g_ExplosionSprite > -1)
{
TE_SetupExplosion(vec, g_ExplosionSprite, 5.0, 1, 0, GetConVarInt(g_Cvar_FreezeBombRadius), 5000);
TE_SetupExplosion(vec, g_ExplosionSprite, 5.0, 1, 0, g_Cvar_FreezeBombRadius.IntValue, 5000);
TE_SendToAll();
}
@ -276,13 +276,13 @@ public Action:Timer_FreezeBomb(Handle:timer, any:value)
}
KillFreezeBomb(client);
FreezeClient(client, GetConVarInt(g_Cvar_FreezeDuration));
FreezeClient(client, g_Cvar_FreezeDuration.IntValue);
if (GetConVarInt(g_Cvar_FreezeBombMode) > 0)
if (g_Cvar_FreezeBombMode.IntValue > 0)
{
new bool:teamOnly = ((GetConVarInt(g_Cvar_FreezeBombMode) == 1) ? true : false);
bool teamOnly = ((g_Cvar_FreezeBombMode.IntValue == 1) ? true : false);
for (new i = 1; i <= MaxClients; i++)
for (int i = 1; i <= MaxClients; i++)
{
if (!IsClientInGame(i) || !IsPlayerAlive(i) || i == client)
{
@ -294,12 +294,12 @@ public Action:Timer_FreezeBomb(Handle:timer, any:value)
continue;
}
new Float:pos[3];
float pos[3];
GetClientEyePosition(i, pos);
new Float:distance = GetVectorDistance(vec, pos);
float distance = GetVectorDistance(vec, pos);
if (distance > GetConVarFloat(g_Cvar_FreezeBombRadius))
if (distance > g_Cvar_FreezeBombRadius.FloatValue)
{
continue;
}
@ -318,7 +318,7 @@ public Action:Timer_FreezeBomb(Handle:timer, any:value)
}
}
FreezeClient(i, GetConVarInt(g_Cvar_FreezeDuration));
FreezeClient(i, g_Cvar_FreezeDuration.IntValue);
}
}
return Plugin_Stop;
@ -421,7 +421,7 @@ public MenuHandler_Freeze(Handle:menu, MenuAction:action, param1, param2)
new String:name[32];
GetClientName(target, name, sizeof(name));
PerformFreeze(param1, target, GetConVarInt(g_Cvar_FreezeDuration));
PerformFreeze(param1, target, g_Cvar_FreezeDuration.IntValue);
ShowActivity2(param1, "[SM] ", "%t", "Froze target", "_s", name);
}
@ -479,7 +479,7 @@ public MenuHandler_FreezeBomb(Handle:menu, MenuAction:action, param1, param2)
}
}
public Action:Command_Freeze(client, args)
public Action Command_Freeze(int client, int args)
{
if (args < 1)
{
@ -487,10 +487,10 @@ public Action:Command_Freeze(client, args)
return Plugin_Handled;
}
decl String:arg[65];
char arg[65];
GetCmdArg(1, arg, sizeof(arg));
new seconds = GetConVarInt(g_Cvar_FreezeDuration);
int seconds = g_Cvar_FreezeDuration.IntValue;
if (args > 1)
{

View File

@ -34,15 +34,15 @@
new g_TimeBombSerial[MAXPLAYERS+1] = { 0, ... };
new g_TimeBombTime[MAXPLAYERS+1] = { 0, ... };
new Handle:g_Cvar_TimeBombTicks = INVALID_HANDLE;
new Handle:g_Cvar_TimeBombRadius = INVALID_HANDLE;
new Handle:g_Cvar_TimeBombMode = INVALID_HANDLE;
ConVar g_Cvar_TimeBombTicks;
ConVar g_Cvar_TimeBombRadius;
ConVar g_Cvar_TimeBombMode;
CreateTimeBomb(client)
{
g_TimeBombSerial[client] = ++g_Serial_Gen;
CreateTimer(1.0, Timer_TimeBomb, client | (g_Serial_Gen << 7), DEFAULT_TIMER_FLAGS);
g_TimeBombTime[client] = GetConVarInt(g_Cvar_TimeBombTicks);
g_TimeBombTime[client] = g_Cvar_TimeBombTicks.IntValue;
}
KillTimeBomb(client)
@ -80,8 +80,8 @@ PerformTimeBomb(client, target)
public Action:Timer_TimeBomb(Handle:timer, any:value)
{
new client = value & 0x7f;
new serial = value >> 7;
int client = value & 0x7f;
int serial = value >> 7;
if (!IsClientInGame(client)
|| !IsPlayerAlive(client)
@ -92,16 +92,16 @@ public Action:Timer_TimeBomb(Handle:timer, any:value)
}
g_TimeBombTime[client]--;
new Float:vec[3];
float vec[3];
GetClientEyePosition(client, vec);
if (g_TimeBombTime[client] > 0)
{
new color;
int color;
if (g_TimeBombTime[client] > 1)
{
color = RoundToFloor(g_TimeBombTime[client] * (128.0 / GetConVarFloat(g_Cvar_TimeBombTicks)));
color = RoundToFloor(g_TimeBombTime[client] * (128.0 / g_Cvar_TimeBombTicks.FloatValue));
if (g_BeepSound[0])
{
EmitAmbientSound(g_BeepSound, vec, client, SNDLEVEL_RAIDSIREN);
@ -118,7 +118,7 @@ public Action:Timer_TimeBomb(Handle:timer, any:value)
SetEntityRenderColor(client, 255, 128, color, 255);
decl String:name[64];
char name[64];
GetClientName(client, name, sizeof(name));
PrintCenterTextAll("%t", "Till Explodes", name, g_TimeBombTime[client]);
@ -127,9 +127,9 @@ public Action:Timer_TimeBomb(Handle:timer, any:value)
GetClientAbsOrigin(client, vec);
vec[2] += 10;
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_TimeBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 15, 0.5, 5.0, 0.0, greyColor, 10, 0);
TE_SetupBeamRingPoint(vec, 10.0, g_Cvar_TimeBombRadius.FloatValue / 3.0, g_BeamSprite, g_HaloSprite, 0, 15, 0.5, 5.0, 0.0, greyColor, 10, 0);
TE_SendToAll();
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_TimeBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, whiteColor, 10, 0);
TE_SetupBeamRingPoint(vec, 10.0, g_Cvar_TimeBombRadius.FloatValue / 3.0, g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, whiteColor, 10, 0);
TE_SendToAll();
}
return Plugin_Continue;
@ -138,7 +138,7 @@ public Action:Timer_TimeBomb(Handle:timer, any:value)
{
if (g_ExplosionSprite > -1)
{
TE_SetupExplosion(vec, g_ExplosionSprite, 5.0, 1, 0, GetConVarInt(g_Cvar_TimeBombRadius), 5000);
TE_SetupExplosion(vec, g_ExplosionSprite, 5.0, 1, 0, g_Cvar_TimeBombRadius.IntValue, 5000);
TE_SendToAll();
}
@ -151,9 +151,9 @@ public Action:Timer_TimeBomb(Handle:timer, any:value)
KillTimeBomb(client);
SetEntityRenderColor(client, 255, 255, 255, 255);
if (GetConVarInt(g_Cvar_TimeBombMode) > 0)
if (g_Cvar_TimeBombMode.IntValue > 0)
{
new teamOnly = ((GetConVarInt(g_Cvar_TimeBombMode) == 1) ? true : false);
int teamOnly = ((g_Cvar_TimeBombMode.IntValue == 1) ? true : false);
for (new i = 1; i <= MaxClients; i++)
{
@ -167,18 +167,18 @@ public Action:Timer_TimeBomb(Handle:timer, any:value)
continue;
}
new Float:pos[3];
float pos[3];
GetClientEyePosition(i, pos);
new Float:distance = GetVectorDistance(vec, pos);
float distance = GetVectorDistance(vec, pos);
if (distance > GetConVarFloat(g_Cvar_TimeBombRadius))
if (distance > g_Cvar_TimeBombRadius.FloatValue)
{
continue;
}
new damage = 220;
damage = RoundToFloor(damage * ((GetConVarFloat(g_Cvar_TimeBombRadius) - distance) / GetConVarFloat(g_Cvar_TimeBombRadius)));
damage = RoundToFloor(damage * ((g_Cvar_TimeBombRadius.FloatValue - distance) / g_Cvar_TimeBombRadius.FloatValue));
SlapPlayer(i, damage, false);
@ -189,14 +189,14 @@ public Action:Timer_TimeBomb(Handle:timer, any:value)
}
/* ToDo
new Float:dir[3];
float dir[3];
SubtractVectors(vec, pos, dir);
TR_TraceRayFilter(vec, dir, MASK_SOLID, RayType_Infinite, TR_Filter_Client);
if (i == TR_GetEntityIndex())
{
new damage = 100;
new radius = GetConVarInt(g_Cvar_TimeBombRadius) / 2;
new radius = g_Cvar_TimeBombRadius.IntValue / 2;
if (distance > radius)
{

View File

@ -53,10 +53,10 @@ public Plugin:myinfo =
new Handle:g_hVoteMenu = INVALID_HANDLE;
new Handle:g_Cvar_Limits[5] = {INVALID_HANDLE, ...};
new Handle:g_Cvar_Gravity = INVALID_HANDLE;
new Handle:g_Cvar_Alltalk = INVALID_HANDLE;
new Handle:g_Cvar_FF = INVALID_HANDLE;
ConVar g_Cvar_Limits[5] = {null, ...};
ConVar g_Cvar_Gravity;
ConVar g_Cvar_Alltalk;
ConVar g_Cvar_FF;
// new Handle:g_Cvar_Show = INVALID_HANDLE;
@ -199,8 +199,9 @@ public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2)
}
else if (action == MenuAction_VoteEnd)
{
decl String:item[64];
new Float:percent, Float:limit, votes, totalVotes;
char item[64];
float percent, limit;
int votes, totalVotes;
GetMenuVoteInfo(param2, votes, totalVotes);
GetMenuItem(menu, param1, item, sizeof(item));
@ -212,7 +213,7 @@ public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2)
percent = GetVotePercent(votes, totalVotes);
limit = GetConVarFloat(g_Cvar_Limits[g_voteType]);
limit = g_Cvar_Limits[g_voteType].FloatValue;
/* :TODO: g_voteClient[userid] needs to be checked.
*/
@ -235,7 +236,7 @@ public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2)
{
PrintToChatAll("[SM] %t", "Cvar changed", "sv_gravity", item);
LogAction(-1, -1, "Changing gravity to %s due to vote.", item);
SetConVarInt(g_Cvar_Gravity, StringToInt(item));
g_Cvar_Gravity.IntValue = StringToInt(item);
}
case (voteType:burn):
@ -257,16 +258,16 @@ public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2)
case (voteType:alltalk):
{
PrintToChatAll("[SM] %t", "Cvar changed", "sv_alltalk", (GetConVarBool(g_Cvar_Alltalk) ? "0" : "1"));
LogAction(-1, -1, "Changing alltalk to %s due to vote.", (GetConVarBool(g_Cvar_Alltalk) ? "0" : "1"));
SetConVarBool(g_Cvar_Alltalk, !GetConVarBool(g_Cvar_Alltalk));
PrintToChatAll("[SM] %t", "Cvar changed", "sv_alltalk", (g_Cvar_Alltalk.BoolValue ? "0" : "1"));
LogAction(-1, -1, "Changing alltalk to %s due to vote.", (g_Cvar_Alltalk.BoolValue ? "0" : "1"));
g_Cvar_Alltalk.BoolValue = !g_Cvar_Alltalk.BoolValue;
}
case (voteType:ff):
{
PrintToChatAll("[SM] %t", "Cvar changed", "mp_friendlyfire", (GetConVarBool(g_Cvar_FF) ? "0" : "1"));
LogAction(-1, -1, "Changing friendly fire to %s due to vote.", (GetConVarBool(g_Cvar_FF) ? "0" : "1"));
SetConVarBool(g_Cvar_FF, !GetConVarBool(g_Cvar_FF));
PrintToChatAll("[SM] %t", "Cvar changed", "mp_friendlyfire", (g_Cvar_FF.BoolValue ? "0" : "1"));
LogAction(-1, -1, "Changing friendly fire to %s due to vote.", (g_Cvar_FF.BoolValue ? "0" : "1"));
g_Cvar_FF.BoolValue = !g_Cvar_FF.BoolValue;
}
}
}

View File

@ -52,7 +52,7 @@ DisplayVoteAllTalkMenu(client)
g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
if (GetConVarBool(g_Cvar_Alltalk))
if (g_Cvar_Alltalk.BoolValue)
{
SetMenuTitle(g_hVoteMenu, "Votealltalk Off");
}
@ -101,4 +101,4 @@ public Action:Command_VoteAlltalk(client, args)
DisplayVoteAllTalkMenu(client);
return Plugin_Handled;
}
}

View File

@ -52,7 +52,7 @@ DisplayVoteFFMenu(client)
g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
if (GetConVarBool(g_Cvar_FF))
if (g_Cvar_FF.BoolValue)
{
SetMenuTitle(g_hVoteMenu, "Voteff Off");
}
@ -100,4 +100,4 @@ public Action:Command_VoteFF(client, args)
DisplayVoteFFMenu(client);
return Plugin_Handled;
}
}

View File

@ -37,15 +37,6 @@
#define INVALID_FCVAR_FLAGS (-1)
/**
* Console variable bound values used with Get/SetConVarBounds()
*/
enum ConVarBounds
{
ConVarBound_Upper = 0,
ConVarBound_Lower
};
/**
* Console variable query helper values.
*/
@ -63,17 +54,6 @@ enum ReplySource
SM_REPLY_TO_CHAT = 1,
};
/**
* Console variable query result values.
*/
enum ConVarQueryResult
{
ConVarQuery_Okay = 0, /**< Retrieval of client convar value was successful. */
ConVarQuery_NotFound, /**< Client convar was not found. */
ConVarQuery_NotValid, /**< A console command with the same name was found, but there is no convar. */
ConVarQuery_Protected /**< Client convar was found, but it is protected. The server cannot retrieve its value. */
};
/**
* @section Flags for console commands and console variables. The descriptions
* for each constant come directly from the Source SDK.
@ -424,293 +404,6 @@ native GetCmdArg(argnum, String:buffer[], maxlength);
*/
native GetCmdArgString(String:buffer[], maxlength);
/**
* Creates a new console variable.
*
* @param name Name of new convar.
* @param defaultValue String containing the default value of new convar.
* @param description Optional description of the convar.
* @param flags Optional bitstring of flags determining how the convar should be handled. See FCVAR_* constants for more details.
* @param hasMin Optional boolean that determines if the convar has a minimum value.
* @param min Minimum floating point value that the convar can have if hasMin is true.
* @param hasMax Optional boolean that determines if the convar has a maximum value.
* @param max Maximum floating point value that the convar can have if hasMax is true.
* @return A handle to the newly created convar. If the convar already exists, a handle to it will still be returned.
* @error Convar name is blank or is the same as an existing console command.
*/
native ConVar:CreateConVar(const String:name[], const String:defaultValue[], const String:description[]="", flags=0, bool:hasMin=false, Float:min=0.0, bool:hasMax=false, Float:max=0.0);
/**
* Searches for a console variable.
*
* @param name Name of convar to find.
* @return A handle to the convar if it is found. INVALID_HANDLE otherwise.
*/
native ConVar:FindConVar(const String:name[]);
/**
* Called when a console variable's value is changed.
*
* @param convar Handle to the convar that was changed.
* @param oldValue String containing the value of the convar before it was changed.
* @param newValue String containing the new value of the convar.
* @noreturn
*/
typedef ConVarChanged = function void (ConVar convar, const char[] oldValue, const char[] newValue);
/**
* Creates a hook for when a console variable's value is changed.
*
* @param convar Handle to the convar.
* @param callback An OnConVarChanged function pointer.
* @noreturn
* @error Invalid or corrupt Handle or invalid callback function.
*/
native HookConVarChange(Handle:convar, ConVarChanged:callback);
/**
* Removes a hook for when a console variable's value is changed.
*
* @param convar Handle to the convar.
* @param callback An OnConVarChanged function pointer.
* @noreturn
* @error Invalid or corrupt Handle, invalid callback function, or no active hook on convar.
*/
native UnhookConVarChange(Handle:convar, ConVarChanged:callback);
/**
* Returns the boolean value of a console variable.
*
* @param convar Handle to the convar.
* @return The boolean value of the convar.
* @error Invalid or corrupt Handle.
*/
native bool:GetConVarBool(Handle:convar);
/**
* Sets the boolean value of a console variable.
*
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
*
* @param convar Handle to the convar.
* @param value New boolean value.
* @param replicate If set to true, the new convar value will be set on all clients.
* This will only work if the convar has the FCVAR_REPLICATED flag
* and actually exists on clients.
* @param notify If set to true, clients will be notified that the convar has changed.
* This will only work if the convar has the FCVAR_NOTIFY flag.
* @noreturn
* @error Invalid or corrupt Handle.
*/
native SetConVarBool(Handle:convar, bool:value, bool:replicate=false, bool:notify=false);
/**
* Returns the integer value of a console variable.
*
* @param convar Handle to the convar.
* @return The integer value of the convar.
* @error Invalid or corrupt Handle.
*/
native GetConVarInt(Handle:convar);
/**
* Sets the integer value of a console variable.
*
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
*
* @param convar Handle to the convar.
* @param value New integer value.
* @param replicate If set to true, the new convar value will be set on all clients.
* This will only work if the convar has the FCVAR_REPLICATED flag
* and actually exists on clients.
* @param notify If set to true, clients will be notified that the convar has changed.
* This will only work if the convar has the FCVAR_NOTIFY flag.
* @noreturn
* @error Invalid or corrupt Handle.
*/
native SetConVarInt(Handle:convar, value, bool:replicate=false, bool:notify=false);
/**
* Returns the floating point value of a console variable.
*
* @param convar Handle to the convar.
* @return The floating point value of the convar.
* @error Invalid or corrupt Handle.
*/
native Float:GetConVarFloat(Handle:convar);
/**
* Sets the floating point value of a console variable.
*
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
*
* @param convar Handle to the convar.
* @param value New floating point value.
* @param replicate If set to true, the new convar value will be set on all clients.
* This will only work if the convar has the FCVAR_REPLICATED flag
* and actually exists on clients.
* @param notify If set to true, clients will be notified that the convar has changed.
* This will only work if the convar has the FCVAR_NOTIFY flag.
* @noreturn
* @error Invalid or corrupt Handle.
*/
native SetConVarFloat(Handle:convar, Float:value, bool:replicate=false, bool:notify=false);
/**
* Retrieves the string value of a console variable.
*
* @param convar Handle to the convar.
* @param value Buffer to store the value of the convar.
* @param maxlength Maximum length of string buffer.
* @noreturn
* @error Invalid or corrupt Handle.
*/
native GetConVarString(Handle:convar, String:value[], maxlength);
/**
* Sets the string value of a console variable.
*
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
*
* @param convar Handle to the convar.
* @param value New string value.
* @param replicate If set to true, the new convar value will be set on all clients.
* This will only work if the convar has the FCVAR_REPLICATED flag
* and actually exists on clients.
* @param notify If set to true, clients will be notified that the convar has changed.
* This will only work if the convar has the FCVAR_NOTIFY flag.
* @noreturn
* @error Invalid or corrupt Handle.
*/
native SetConVarString(Handle:convar, const String:value[], bool:replicate=false, bool:notify=false);
/**
* Resets the console variable to its default value.
*
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
*
* @param convar Handle to the convar.
* @param replicate If set to true, the new convar value will be set on all clients.
* This will only work if the convar has the FCVAR_REPLICATED flag
* and actually exists on clients.
* @param notify If set to true, clients will be notified that the convar has changed.
* This will only work if the convar has the FCVAR_NOTIFY flag.
* @noreturn
* @error Invalid or corrupt Handle.
*/
native ResetConVar(Handle:convar, bool:replicate=false, bool:notify=false);
/**
* Retrieves the default string value of a console variable.
*
* @param convar Handle to the convar.
* @param value Buffer to store the default value of the convar.
* @param maxlength Maximum length of string buffer.
* @return Number of bytes written to the buffer (UTF-8 safe).
* @error Invalid or corrupt Handle.
*/
native GetConVarDefault(Handle:convar, String:value[], maxlength);
/**
* Returns the bitstring of flags on a console variable.
*
* @param convar Handle to the convar.
* @return A bitstring containing the FCVAR_* flags that are enabled.
* @error Invalid or corrupt Handle.
*/
native GetConVarFlags(Handle:convar);
/**
* Sets the bitstring of flags on a console variable.
*
* @param convar Handle to the convar.
* @param flags A bitstring containing the FCVAR_* flags to enable.
* @noreturn
* @error Invalid or corrupt Handle.
*/
native SetConVarFlags(Handle:convar, flags);
/**
* Retrieves the specified bound of a console variable.
*
* @param convar Handle to the convar.
* @param type Type of bound to retrieve, ConVarBound_Lower or ConVarBound_Upper.
* @param value By-reference cell to store the specified floating point bound value.
* @return True if the convar has the specified bound set, false otherwise.
* @error Invalid or corrupt Handle.
*/
native bool:GetConVarBounds(Handle:convar, ConVarBounds:type, &Float:value);
/**
* Sets the specified bound of a console variable.
*
* @param convar Handle to the convar.
* @param type Type of bound to set, ConVarBound_Lower or ConVarBound_Upper
* @param set If set to true, convar will use specified bound. If false, bound will be removed.
* @param value Floating point value to use as the specified bound.
* @noreturn
* @error Invalid or corrupt Handle.
*/
native SetConVarBounds(Handle:convar, ConVarBounds:type, bool:set, Float:value=0.0);
/**
* Retrieves the name of a console variable.
*
* @param convar Handle to the convar.
* @param name Buffer to store the name of the convar.
* @param maxlength Maximum length of string buffer.
* @noreturn
* @error Invalid or corrupt Handle.
*/
native GetConVarName(Handle:convar, String:name[], maxlength);
union ConVarQueryFinished
{
/**
* Called when a query to retrieve a client's console variable has finished.
*
* @param cookie Unique identifier of query.
* @param client Player index.
* @param result Result of query that tells one whether or not query was successful.
* See ConVarQueryResult enum for more details.
* @param convarName Name of client convar that was queried.
* @param convarValue Value of client convar that was queried if successful. This will be "" if it was not.
* @param value Value that was passed when query was started.
* @noreturn
*/
function void (QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue, any value);
/**
* Called when a query to retrieve a client's console variable has finished.
*
* @param cookie Unique identifier of query.
* @param client Player index.
* @param result Result of query that tells one whether or not query was successful.
* See ConVarQueryResult enum for more details.
* @param convarName Name of client convar that was queried.
* @param convarValue Value of client convar that was queried if successful. This will be "" if it was not.
* @noreturn
*/
function void (QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue);
};
/**
* Starts a query to retrieve the value of a client's console variable.
*
* @param client Player index.
* @param cvarName Name of client convar to query.
* @param callback A function to use as a callback when the query has finished.
* @param value Optional value to pass to the callback function.
* @return A cookie that uniquely identifies the query.
* Returns QUERYCOOKIE_FAILED on failure, such as when used on a bot.
*/
native QueryCookie:QueryClientConVar(client, const String:cvarName[], ConVarQueryFinished:callback, any:value=0);
/**
* Gets a command iterator. Must be freed with CloseHandle().
*
@ -781,17 +474,6 @@ native bool:CheckAccess(AdminId:id,
flags,
bool:override_only=false);
/**
* Returns true if the supplied character is valid in a ConVar name.
*
* @param c Character to validate.
* @return True is valid for ConVars, false otherwise
*/
stock bool:IsValidConVarChar(c)
{
return (c == '_' || IsCharAlpha(c) || IsCharNumeric(c));
}
/**
* Returns the bitstring of flags of a command.
*
@ -850,17 +532,6 @@ native Handle:FindFirstConCommand(String:buffer[], max_size, &bool:isCommand, &f
*/
native bool:FindNextConCommand(Handle:search, String:buffer[], max_size, &bool:isCommand, &flags=0, String:description[]="", descrmax_size=0);
/**
* Replicates a convar value to a specific client. This does not change the actual convar value.
*
* @param client Client index
* @param convar ConVar handle
* @param value String value to send
* @return True on success, false on failure
* @error Invalid client index, client not in game, or client is fake
*/
native bool:SendConVarValue(client, Handle:convar, const String:value[]);
/**
* Adds an informational string to the server's public "tags".
* This string should be a short, unique identifier.
@ -969,26 +640,3 @@ forward Action:OnClientSayCommand(client, const String:command[], const String:s
*
*/
forward void OnClientSayCommand_Post(int client, const char[] command, const char[] sArgs);
// Most of these aren't properties because they're more complex
methodmap ConVar < Handle
{
public ConVar() = CreateConVar;
public GetBool() = GetConVarBool;
public SetBool() = SetConVarBool;
public GetInt() = GetConVarInt;
public SetInt() = SetConVarInt;
public GetFloat() = GetConVarFloat;
public SetFloat() = SetConVarFloat;
public GetString() = GetConVarString;
public SetString() = SetConVarString;
public RestoreDefaultValue() = ResetConVar;
public GetFlags() = GetConVarFlags;
public SetFlags() = SetConVarFlags;
public GetBounds() = GetConVarBounds;
public SetBounds() = SetConVarBounds;
public GetDefaultValue() = GetConVarDefault;
public GetName() = GetConVarName;
public AddChangeHook() = HookConVarChange;
public RemoveChangeHook() = UnhookConVarChange;
}

493
plugins/include/convars.inc Normal file
View File

@ -0,0 +1,493 @@
/**
* vim: set ts=4 sw=4 tw=99 noet :
* =============================================================================
* SourceMod (C)2004-2014 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This file is part of the SourceMod/SourcePawn SDK.
*
* 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$
*/
/**
* Console variable bound values used with Get/SetConVarBounds()
*/
enum ConVarBounds
{
ConVarBound_Upper = 0,
ConVarBound_Lower
};
/**
* Console variable query result values.
*/
enum ConVarQueryResult
{
ConVarQuery_Okay = 0, //< Retrieval of client convar value was successful. */
ConVarQuery_NotFound, //< Client convar was not found. */
ConVarQuery_NotValid, //< A console command with the same name was found, but there is no convar. */
ConVarQuery_Protected //< Client convar was found, but it is protected. The server cannot retrieve its value. */
};
// Called when a console variable's value is changed.
//
// @param convar Handle to the convar that was changed.
// @param oldValue String containing the value of the convar before it was changed.
// @param newValue String containing the new value of the convar.
typedef ConVarChanged = function void (ConVar convar, const char[] oldValue, const char[] newValue);
// Creates a new console variable.
//
// @param name Name of new convar.
// @param defaultValue String containing the default value of new convar.
// @param description Optional description of the convar.
// @param flags Optional bitstring of flags determining how the convar should be handled. See FCVAR_* constants for more details.
// @param hasMin Optional boolean that determines if the convar has a minimum value.
// @param min Minimum floating point value that the convar can have if hasMin is true.
// @param hasMax Optional boolean that determines if the convar has a maximum value.
// @param max Maximum floating point value that the convar can have if hasMax is true.
// @return A handle to the newly created convar. If the convar already exists, a handle to it will still be returned.
// @error Convar name is blank or is the same as an existing console command.
native ConVar CreateConVar(
const char[] name,
const char[] defaultValue,
const char[] description="",
int flags=0,
bool hasMin=false, float min=0.0,
bool hasMax=false, float max=0.0);
// Searches for a console variable.
//
// @param name Name of convar to find.
// @return A ConVar object if found; null otherwise.
native ConVar FindConVar(const char[] name);
// A ConVar is a configurable, named setting in the srcds console.
methodmap ConVar < Handle
{
// Retrieves or sets a boolean value for the convar.
property bool BoolValue {
public native get();
public native set(bool b);
}
// Retrieves or sets an integer value for the convar.
property int IntValue {
public native get();
public native set(int value);
}
// Retrieves or sets a float value for the convar.
property float FloatValue {
public native get();
public native set(float value);
}
// Gets or sets the flag bits (FCVAR_*) on the convar.
property int Flags {
public native get();
public native set(int flags);
}
// Sets the boolean value of a console variable.
//
// Note: The replicate and notify params are only relevant for the
// original, Dark Messiah, and Episode 1 engines. Newer engines
// automatically do these things when the convar value is changed.
//
// @param value New boolean value.
// @param replicate If set to true, the new convar value will be set on all clients.
// This will only work if the convar has the FCVAR_REPLICATED flag
// and actually exists on clients.
// @param notify If set to true, clients will be notified that the convar has changed.
// This will only work if the convar has the FCVAR_NOTIFY flag.
public native void SetBool(bool value, bool replicate=false, bool notify=false);
// Sets the integer value of a console variable.
//
// Note: The replicate and notify params are only relevant for the
// original, Dark Messiah, and Episode 1 engines. Newer engines
// automatically do these things when the convar value is changed.
//
// @param value New integer value.
// @param replicate If set to true, the new convar value will be set on all clients.
// This will only work if the convar has the FCVAR_REPLICATED flag
// and actually exists on clients.
// @param notify If set to true, clients will be notified that the convar has changed.
// This will only work if the convar has the FCVAR_NOTIFY flag.
public native void SetInt(int value, bool replicate=false, bool notify=false);
// Sets the floating point value of a console variable.
//
// Note: The replicate and notify params are only relevant for the
// original, Dark Messiah, and Episode 1 engines. Newer engines
// automatically do these things when the convar value is changed.
//
// @param value New floating point value.
// @param replicate If set to true, the new convar value will be set on all clients.
// This will only work if the convar has the FCVAR_REPLICATED flag
// and actually exists on clients.
// @param notify If set to true, clients will be notified that the convar has changed.
// This will only work if the convar has the FCVAR_NOTIFY flag.
public native void SetFloat(float value, bool replicate=false, bool notify=false);
// Retrieves the string value of a console variable.
//
// @param convar Handle to the convar.
// @param value Buffer to store the value of the convar.
// @param maxlength Maximum length of string buffer.
public native void GetString(char[] value, int maxlength);
// Sets the string value of a console variable.
//
// Note: The replicate and notify params are only relevant for the
// original, Dark Messiah, and Episode 1 engines. Newer engines
// automatically do these things when the convar value is changed.
//
// @param value New string value.
// @param replicate If set to true, the new convar value will be set on all clients.
// This will only work if the convar has the FCVAR_REPLICATED flag
// and actually exists on clients.
// @param notify If set to true, clients will be notified that the convar has changed.
// This will only work if the convar has the FCVAR_NOTIFY flag.
public native void SetString(const char[] value, bool replicate=false, bool notify=false);
// Resets the console variable to its default value.
//
// Note: The replicate and notify params are only relevant for the
// original, Dark Messiah, and Episode 1 engines. Newer engines
// automatically do these things when the convar value is changed.
//
// @param replicate If set to true, the new convar value will be set on all clients.
// This will only work if the convar has the FCVAR_REPLICATED flag
// and actually exists on clients.
// @param notify If set to true, clients will be notified that the convar has changed.
// This will only work if the convar has the FCVAR_NOTIFY flag.
public native void RestoreDefault(bool replicate=false, bool notify=false);
// Retrieves the default string value of a console variable.
//
// @param value Buffer to store the default value of the convar.
// @param maxlength Maximum length of string buffer.
// @return Number of bytes written to the buffer (UTF-8 safe).
public native int GetDefault(char[] value, int maxlength);
// Retrieves the specified bound of a console variable.
//
// @param type Type of bound to retrieve, ConVarBound_Lower or ConVarBound_Upper.
// @param value By-reference cell to store the specified floating point bound value.
// @return True if the convar has the specified bound set, false otherwise.
public native bool GetBounds(ConVarBounds type, float &value);
// Sets the specified bound of a console variable.
//
// @param type Type of bound to set, ConVarBound_Lower or ConVarBound_Upper
// @param set If set to true, convar will use specified bound. If false, bound will be removed.
// @param value Floating point value to use as the specified bound.
public native void SetBounds(ConVarBounds type, bool set, float value=0.0);
// Retrieves the name of a console variable.
//
// @param name Buffer to store the name of the convar.
// @param maxlength Maximum length of string buffer.
public native void GetName(char[] name, maxlength);
// Replicates a convar value to a specific client. This does not change the actual convar value.
//
// @param client Client index
// @param value String value to send
// @return True on success, false on failure
// @error Invalid client index, client not in game, or client is fake
public native bool ReplicateToClient(int client, const char[] value);
// Creates a hook for when a console variable's value is changed.
//
// @param callback An OnConVarChanged function pointer.
public native void AddChangeHook(ConVarChanged callback);
// Removes a hook for when a console variable's value is changed.
//
// @param convar Handle to the convar.
// @param callback An OnConVarChanged function pointer.
// @error No active hook on convar.
public native void RemoveChangeHook(ConVarChanged callback);
}
/**
* Creates a hook for when a console variable's value is changed.
*
* @param convar Handle to the convar.
* @param callback An OnConVarChanged function pointer.
* @error Invalid or corrupt Handle or invalid callback function.
*/
native void HookConVarChange(Handle convar, ConVarChanged callback);
/**
* Removes a hook for when a console variable's value is changed.
*
* @param convar Handle to the convar.
* @param callback An OnConVarChanged function pointer.
* @error Invalid or corrupt Handle, invalid callback function, or no active hook on convar.
*/
native void UnhookConVarChange(Handle convar, ConVarChanged callback);
/**
* Returns the boolean value of a console variable.
*
* @param convar Handle to the convar.
* @return The boolean value of the convar.
* @error Invalid or corrupt Handle.
*/
native bool GetConVarBool(Handle convar);
/**
* Sets the boolean value of a console variable.
*
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
*
* @param convar Handle to the convar.
* @param value New boolean value.
* @param replicate If set to true, the new convar value will be set on all clients.
* This will only work if the convar has the FCVAR_REPLICATED flag
* and actually exists on clients.
* @param notify If set to true, clients will be notified that the convar has changed.
* This will only work if the convar has the FCVAR_NOTIFY flag.
* @error Invalid or corrupt Handle.
*/
native void SetConVarBool(Handle convar, bool value, bool replicate=false, bool notify=false);
/**
* Returns the integer value of a console variable.
*
* @param convar Handle to the convar.
* @return The integer value of the convar.
* @error Invalid or corrupt Handle.
*/
native int GetConVarInt(Handle convar);
/**
* Sets the integer value of a console variable.
*
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
*
* @param convar Handle to the convar.
* @param value New integer value.
* @param replicate If set to true, the new convar value will be set on all clients.
* This will only work if the convar has the FCVAR_REPLICATED flag
* and actually exists on clients.
* @param notify If set to true, clients will be notified that the convar has changed.
* This will only work if the convar has the FCVAR_NOTIFY flag.
* @error Invalid or corrupt Handle.
*/
native void SetConVarInt(Handle convar, int value, bool replicate=false, bool notify=false);
/**
* Returns the floating point value of a console variable.
*
* @param convar Handle to the convar.
* @return The floating point value of the convar.
* @error Invalid or corrupt Handle.
*/
native float GetConVarFloat(Handle convar);
/**
* Sets the floating point value of a console variable.
*
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
*
* @param convar Handle to the convar.
* @param value New floating point value.
* @param replicate If set to true, the new convar value will be set on all clients.
* This will only work if the convar has the FCVAR_REPLICATED flag
* and actually exists on clients.
* @param notify If set to true, clients will be notified that the convar has changed.
* This will only work if the convar has the FCVAR_NOTIFY flag.
* @error Invalid or corrupt Handle.
*/
native void SetConVarFloat(Handle convar, float value, bool replicate=false, bool notify=false);
/**
* Retrieves the string value of a console variable.
*
* @param convar Handle to the convar.
* @param value Buffer to store the value of the convar.
* @param maxlength Maximum length of string buffer.
* @error Invalid or corrupt Handle.
*/
native void GetConVarString(Handle convar, char[] value, int maxlength);
/**
* Sets the string value of a console variable.
*
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
*
* @param convar Handle to the convar.
* @param value New string value.
* @param replicate If set to true, the new convar value will be set on all clients.
* This will only work if the convar has the FCVAR_REPLICATED flag
* and actually exists on clients.
* @param notify If set to true, clients will be notified that the convar has changed.
* This will only work if the convar has the FCVAR_NOTIFY flag.
* @error Invalid or corrupt Handle.
*/
native void SetConVarString(Handle convar, const char[] value, bool replicate=false, bool notify=false);
/**
* Resets the console variable to its default value.
*
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
*
* @param convar Handle to the convar.
* @param replicate If set to true, the new convar value will be set on all clients.
* This will only work if the convar has the FCVAR_REPLICATED flag
* and actually exists on clients.
* @param notify If set to true, clients will be notified that the convar has changed.
* This will only work if the convar has the FCVAR_NOTIFY flag.
* @error Invalid or corrupt Handle.
*/
native void ResetConVar(Handle convar, bool replicate=false, bool notify=false);
/**
* Retrieves the default string value of a console variable.
*
* @param convar Handle to the convar.
* @param value Buffer to store the default value of the convar.
* @param maxlength Maximum length of string buffer.
* @return Number of bytes written to the buffer (UTF-8 safe).
* @error Invalid or corrupt Handle.
*/
native int GetConVarDefault(Handle convar, char[] value, int maxlength);
/**
* Returns the bitstring of flags on a console variable.
*
* @param convar Handle to the convar.
* @return A bitstring containing the FCVAR_* flags that are enabled.
* @error Invalid or corrupt Handle.
*/
native int GetConVarFlags(Handle convar);
/**
* Sets the bitstring of flags on a console variable.
*
* @param convar Handle to the convar.
* @param flags A bitstring containing the FCVAR_* flags to enable.
* @error Invalid or corrupt Handle.
*/
native void SetConVarFlags(Handle convar, flags);
/**
* Retrieves the specified bound of a console variable.
*
* @param convar Handle to the convar.
* @param type Type of bound to retrieve, ConVarBound_Lower or ConVarBound_Upper.
* @param value By-reference cell to store the specified floating point bound value.
* @return True if the convar has the specified bound set, false otherwise.
* @error Invalid or corrupt Handle.
*/
native bool GetConVarBounds(Handle convar, ConVarBounds type, float &value);
/**
* Sets the specified bound of a console variable.
*
* @param convar Handle to the convar.
* @param type Type of bound to set, ConVarBound_Lower or ConVarBound_Upper
* @param set If set to true, convar will use specified bound. If false, bound will be removed.
* @param value Floating point value to use as the specified bound.
* @error Invalid or corrupt Handle.
*/
native void SetConVarBounds(Handle convar, ConVarBounds type, bool set, float value=0.0);
/**
* Retrieves the name of a console variable.
*
* @param convar Handle to the convar.
* @param name Buffer to store the name of the convar.
* @param maxlength Maximum length of string buffer.
* @error Invalid or corrupt Handle.
*/
native void GetConVarName(Handle convar, char[] name, maxlength);
/**
* Replicates a convar value to a specific client. This does not change the actual convar value.
*
* @param client Client index
* @param convar ConVar handle
* @param value String value to send
* @return True on success, false on failure
* @error Invalid client index, client not in game, or client is fake
*/
native bool SendConVarValue(int client, Handle convar, const char[] value);
union ConVarQueryFinished
{
// Called when a query to retrieve a client's console variable has finished.
//
// @param cookie Unique identifier of query.
// @param client Player index.
// @param result Result of query that tells one whether or not query was successful.
// See ConVarQueryResult enum for more details.
// @param convarName Name of client convar that was queried.
// @param convarValue Value of client convar that was queried if successful. This will be "" if it was not.
// @param value Value that was passed when query was started.
function void (QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue, any value);
// Called when a query to retrieve a client's console variable has finished.
//
// @param cookie Unique identifier of query.
// @param client Player index.
// @param result Result of query that tells one whether or not query was successful.
// See ConVarQueryResult enum for more details.
// @param convarName Name of client convar that was queried.
// @param convarValue Value of client convar that was queried if successful. This will be "" if it was not.
function void (QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue);
};
/**
* Starts a query to retrieve the value of a client's console variable.
*
* @param client Player index.
* @param cvarName Name of client convar to query.
* @param callback A function to use as a callback when the query has finished.
* @param value Optional value to pass to the callback function.
* @return A cookie that uniquely identifies the query.
* Returns QUERYCOOKIE_FAILED on failure, such as when used on a bot.
*/
native QueryCookie QueryClientConVar(int client, const char[] cvarName, ConVarQueryFinished callback, any value=0);
/**
* Returns true if the supplied character is valid in a ConVar name.
*
* @param c Character to validate.
* @return True is valid for ConVars, false otherwise
*/
stock bool IsValidConVarChar(int c)
{
return (c == '_' || IsCharAlpha(c) || IsCharNumeric(c));
}

View File

@ -64,6 +64,7 @@ struct Plugin
#include <textparse>
#include <clients>
#include <console>
#include <convars>
#include <events>
#include <bitbuffer>
#include <protobuf>

View File

@ -47,27 +47,27 @@ public Plugin:myinfo =
};
/* Valve ConVars */
new Handle:g_Cvar_Winlimit = INVALID_HANDLE;
new Handle:g_Cvar_Maxrounds = INVALID_HANDLE;
new Handle:g_Cvar_Fraglimit = INVALID_HANDLE;
new Handle:g_Cvar_Bonusroundtime = INVALID_HANDLE;
ConVar g_Cvar_Winlimit;
ConVar g_Cvar_Maxrounds;
ConVar g_Cvar_Fraglimit;
ConVar g_Cvar_Bonusroundtime;
/* Plugin ConVars */
new Handle:g_Cvar_StartTime = INVALID_HANDLE;
new Handle:g_Cvar_StartRounds = INVALID_HANDLE;
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_ExcludeMaps = INVALID_HANDLE;
new Handle:g_Cvar_IncludeMaps = INVALID_HANDLE;
new Handle:g_Cvar_NoVoteMode = INVALID_HANDLE;
new Handle:g_Cvar_Extend = INVALID_HANDLE;
new Handle:g_Cvar_DontChange = INVALID_HANDLE;
new Handle:g_Cvar_EndOfMapVote = INVALID_HANDLE;
new Handle:g_Cvar_VoteDuration = INVALID_HANDLE;
new Handle:g_Cvar_RunOff = INVALID_HANDLE;
new Handle:g_Cvar_RunOffPercent = INVALID_HANDLE;
ConVar g_Cvar_StartTime;
ConVar g_Cvar_StartRounds;
ConVar g_Cvar_StartFrags;
ConVar g_Cvar_ExtendTimeStep;
ConVar g_Cvar_ExtendRoundStep;
ConVar g_Cvar_ExtendFragStep;
ConVar g_Cvar_ExcludeMaps;
ConVar g_Cvar_IncludeMaps;
ConVar g_Cvar_NoVoteMode;
ConVar g_Cvar_Extend;
ConVar g_Cvar_DontChange;
ConVar g_Cvar_EndOfMapVote;
ConVar g_Cvar_VoteDuration;
ConVar g_Cvar_RunOff;
ConVar g_Cvar_RunOffPercent;
new Handle:g_VoteTimer = INVALID_HANDLE;
new Handle:g_RetryTimer = INVALID_HANDLE;
@ -138,9 +138,9 @@ public OnPluginStart()
g_Cvar_Fraglimit = FindConVar("mp_fraglimit");
g_Cvar_Bonusroundtime = FindConVar("mp_bonusroundtime");
if (g_Cvar_Winlimit != INVALID_HANDLE || g_Cvar_Maxrounds != INVALID_HANDLE)
if (g_Cvar_Winlimit || g_Cvar_Maxrounds)
{
decl String:folder[64];
char folder[64];
GetGameFolderName(folder, sizeof(folder));
if (strcmp(folder, "tf") == 0)
@ -159,7 +159,7 @@ public OnPluginStart()
}
}
if (g_Cvar_Fraglimit != INVALID_HANDLE)
if (g_Cvar_Fraglimit)
{
HookEvent("player_death", Event_PlayerDeath);
}
@ -168,9 +168,9 @@ public OnPluginStart()
//Change the mp_bonusroundtime max so that we have time to display the vote
//If you display a vote during bonus time good defaults are 17 vote duration and 19 mp_bonustime
if (g_Cvar_Bonusroundtime != INVALID_HANDLE)
if (g_Cvar_Bonusroundtime)
{
SetConVarBounds(g_Cvar_Bonusroundtime, ConVarBound_Upper, true, 30.0);
g_Cvar_Bonusroundtime.SetBounds(ConVarBound_Upper, true, 30.0);
}
g_NominationsResetForward = CreateGlobalForward("OnNominationRemoved", ET_Ignore, Param_String, Param_Cell);
@ -228,9 +228,9 @@ public OnConfigsExecuted()
/* Check if mapchooser will attempt to start mapvote during bonus round time - TF2 Only */
if ((g_Cvar_Bonusroundtime != INVALID_HANDLE) && !GetConVarInt(g_Cvar_StartRounds))
if (g_Cvar_Bonusroundtime && !g_Cvar_StartRounds.IntValue)
{
if (GetConVarFloat(g_Cvar_Bonusroundtime) <= GetConVarFloat(g_Cvar_VoteDuration))
if (g_Cvar_Bonusroundtime.FloatValue <= g_Cvar_VoteDuration.FloatValue)
{
LogError("Warning - Bonus Round Time shorter than Vote Time. Votes during bonus round may not have time to complete");
}
@ -251,7 +251,7 @@ public OnMapEnd()
GetCurrentMap(map, sizeof(map));
PushArrayString(g_OldMapList, map);
if (GetArraySize(g_OldMapList) > GetConVarInt(g_Cvar_ExcludeMaps))
if (GetArraySize(g_OldMapList) > g_Cvar_ExcludeMaps.IntValue)
{
RemoveFromArray(g_OldMapList, 0);
}
@ -316,8 +316,8 @@ SetupTimeleftTimer()
new time;
if (GetMapTimeLeft(time) && time > 0)
{
new startTime = GetConVarInt(g_Cvar_StartTime) * 60;
if (time - startTime < 0 && GetConVarBool(g_Cvar_EndOfMapVote) && !g_MapVoteCompleted && !g_HasVoteStarted)
new startTime = g_Cvar_StartTime.IntValue * 60;
if (time - startTime < 0 && g_Cvar_EndOfMapVote.BoolValue && !g_MapVoteCompleted && !g_HasVoteStarted)
{
InitiateVote(MapChange_MapEnd, INVALID_HANDLE);
}
@ -351,7 +351,7 @@ public Action:Timer_StartMapVote(Handle:timer, Handle:data)
g_VoteTimer = INVALID_HANDLE;
}
if (!GetArraySize(g_MapList) || !GetConVarBool(g_Cvar_EndOfMapVote) || g_MapVoteCompleted || g_HasVoteStarted)
if (!GetArraySize(g_MapList) || !g_Cvar_EndOfMapVote.BoolValue || g_MapVoteCompleted || g_HasVoteStarted)
{
return Plugin_Stop;
}
@ -386,7 +386,7 @@ public Event_TeamPlayWinPanel(Handle:event, const String:name[], bool:dontBroadc
{
g_TotalRounds++;
if (!GetArraySize(g_MapList) || g_HasVoteStarted || g_MapVoteCompleted || !GetConVarBool(g_Cvar_EndOfMapVote))
if (!GetArraySize(g_MapList) || g_HasVoteStarted || g_MapVoteCompleted || !g_Cvar_EndOfMapVote.BoolValue)
{
return;
}
@ -432,7 +432,7 @@ public Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
winner = GetEventInt(event, "winner");
}
if (winner == 0 || winner == 1 || !GetConVarBool(g_Cvar_EndOfMapVote))
if (winner == 0 || winner == 1 || !g_Cvar_EndOfMapVote.BoolValue)
{
return;
}
@ -457,12 +457,12 @@ public Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
public CheckWinLimit(winner_score)
{
if (g_Cvar_Winlimit != INVALID_HANDLE)
if (g_Cvar_Winlimit)
{
new winlimit = GetConVarInt(g_Cvar_Winlimit);
int winlimit = g_Cvar_Winlimit.IntValue;
if (winlimit)
{
if (winner_score >= (winlimit - GetConVarInt(g_Cvar_StartRounds)))
if (winner_score >= (winlimit - g_Cvar_StartRounds.IntValue))
{
InitiateVote(MapChange_MapEnd, INVALID_HANDLE);
}
@ -472,12 +472,12 @@ public CheckWinLimit(winner_score)
public CheckMaxRounds(roundcount)
{
if (g_Cvar_Maxrounds != INVALID_HANDLE)
if (g_Cvar_Maxrounds)
{
new maxrounds = GetConVarInt(g_Cvar_Maxrounds);
int maxrounds = g_Cvar_Maxrounds.IntValue;
if (maxrounds)
{
if (roundcount >= (maxrounds - GetConVarInt(g_Cvar_StartRounds)))
if (roundcount >= (maxrounds - g_Cvar_StartRounds.IntValue))
{
InitiateVote(MapChange_MapEnd, INVALID_HANDLE);
}
@ -487,12 +487,12 @@ public CheckMaxRounds(roundcount)
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
if (!GetArraySize(g_MapList) || g_Cvar_Fraglimit == INVALID_HANDLE || g_HasVoteStarted)
if (!GetArraySize(g_MapList) || !g_Cvar_Fraglimit || g_HasVoteStarted)
{
return;
}
if (!GetConVarInt(g_Cvar_Fraglimit) || !GetConVarBool(g_Cvar_EndOfMapVote))
if (!g_Cvar_Fraglimit.IntValue || !g_Cvar_EndOfMapVote.BoolValue)
{
return;
}
@ -509,7 +509,7 @@ public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
return;
}
if (GetClientFrags(fragger) >= (GetConVarInt(g_Cvar_Fraglimit) - GetConVarInt(g_Cvar_StartFrags)))
if (GetClientFrags(fragger) >= (g_Cvar_Fraglimit.IntValue - g_Cvar_StartFrags.IntValue))
{
InitiateVote(MapChange_MapEnd, INVALID_HANDLE);
}
@ -572,16 +572,16 @@ InitiateVote(MapChange:when, Handle:inputlist=INVALID_HANDLE)
* like sm_mapvote from the adminmenu in the future.
*/
decl String:map[PLATFORM_MAX_PATH];
char map[PLATFORM_MAX_PATH];
/* No input given - User our internal nominations and maplist */
if (inputlist == INVALID_HANDLE)
{
new nominateCount = GetArraySize(g_NominateList);
new voteSize = GetConVarInt(g_Cvar_IncludeMaps);
int nominateCount = GetArraySize(g_NominateList);
int voteSize = g_Cvar_IncludeMaps.IntValue;
/* Smaller of the two - It should be impossible for nominations to exceed the size though (cvar changed mid-map?) */
new nominationsToAdd = nominateCount >= voteSize ? voteSize : nominateCount;
int nominationsToAdd = nominateCount >= voteSize ? voteSize : nominateCount;
for (new i=0; i<nominationsToAdd; i++)
@ -652,11 +652,11 @@ InitiateVote(MapChange:when, Handle:inputlist=INVALID_HANDLE)
}
/* Do we add any special items? */
if ((when == MapChange_Instant || when == MapChange_RoundEnd) && GetConVarBool(g_Cvar_DontChange))
if ((when == MapChange_Instant || when == MapChange_RoundEnd) && g_Cvar_DontChange.BoolValue)
{
AddMenuItem(g_VoteMenu, VOTE_DONTCHANGE, "Don't Change");
}
else if (GetConVarBool(g_Cvar_Extend) && g_Extends < GetConVarInt(g_Cvar_Extend))
else if (g_Cvar_Extend.BoolValue && g_Extends < g_Cvar_Extend.IntValue)
{
AddMenuItem(g_VoteMenu, VOTE_EXTEND, "Extend Map");
}
@ -670,7 +670,7 @@ InitiateVote(MapChange:when, Handle:inputlist=INVALID_HANDLE)
return;
}
new voteDuration = GetConVarInt(g_Cvar_VoteDuration);
int voteDuration = g_Cvar_VoteDuration.IntValue;
SetMenuExitButton(g_VoteMenu, false);
VoteMenuToAll(g_VoteMenu, voteDuration);
@ -686,46 +686,46 @@ public Handler_VoteFinishedGeneric(Handle:menu,
num_items,
const item_info[][2])
{
decl String:map[PLATFORM_MAX_PATH];
char map[PLATFORM_MAX_PATH];
GetMenuItem(menu, item_info[0][VOTEINFO_ITEM_INDEX], map, sizeof(map));
if (strcmp(map, VOTE_EXTEND, false) == 0)
{
g_Extends++;
new time;
int time;
if (GetMapTimeLimit(time))
{
if (time > 0)
{
ExtendMapTimeLimit(GetConVarInt(g_Cvar_ExtendTimeStep)*60);
ExtendMapTimeLimit(g_Cvar_ExtendTimeStep.IntValue * 60);
}
}
if (g_Cvar_Winlimit != INVALID_HANDLE)
if (g_Cvar_Winlimit)
{
new winlimit = GetConVarInt(g_Cvar_Winlimit);
int winlimit = g_Cvar_Winlimit.IntValue;
if (winlimit)
{
SetConVarInt(g_Cvar_Winlimit, winlimit + GetConVarInt(g_Cvar_ExtendRoundStep));
g_Cvar_Winlimit.IntValue = winlimit + g_Cvar_ExtendRoundStep.IntValue;
}
}
if (g_Cvar_Maxrounds != INVALID_HANDLE)
if (g_Cvar_Maxrounds)
{
new maxrounds = GetConVarInt(g_Cvar_Maxrounds);
new maxrounds = g_Cvar_Maxrounds.IntValue;
if (maxrounds)
{
SetConVarInt(g_Cvar_Maxrounds, maxrounds + GetConVarInt(g_Cvar_ExtendRoundStep));
g_Cvar_Maxrounds.IntValue = maxrounds + g_Cvar_ExtendRoundStep.IntValue;
}
}
if (g_Cvar_Fraglimit != INVALID_HANDLE)
if (g_Cvar_Fraglimit)
{
new fraglimit = GetConVarInt(g_Cvar_Fraglimit);
int fraglimit = g_Cvar_Fraglimit.IntValue;
if (fraglimit)
{
SetConVarInt(g_Cvar_Fraglimit, fraglimit + GetConVarInt(g_Cvar_ExtendFragStep));
g_Cvar_Fraglimit.IntValue = fraglimit + g_Cvar_ExtendFragStep.IntValue;
}
}
@ -781,10 +781,10 @@ public Handler_MapVoteFinished(Handle:menu,
num_items,
const item_info[][2])
{
if (GetConVarBool(g_Cvar_RunOff) && num_items > 1)
if (g_Cvar_RunOff.BoolValue && num_items > 1)
{
new Float:winningvotes = float(item_info[0][VOTEINFO_ITEM_VOTES]);
new Float:required = num_votes * (GetConVarFloat(g_Cvar_RunOffPercent) / 100.0);
float winningvotes = float(item_info[0][VOTEINFO_ITEM_VOTES]);
float required = num_votes * (g_Cvar_RunOffPercent.FloatValue / 100.0);
if (winningvotes < required)
{
@ -793,16 +793,16 @@ public Handler_MapVoteFinished(Handle:menu,
SetMenuTitle(g_VoteMenu, "Runoff Vote Nextmap");
SetVoteResultCallback(g_VoteMenu, Handler_VoteFinishedGeneric);
decl String:map[PLATFORM_MAX_PATH];
decl String:info1[PLATFORM_MAX_PATH];
decl String:info2[PLATFORM_MAX_PATH];
char map[PLATFORM_MAX_PATH];
char info1[PLATFORM_MAX_PATH];
char info2[PLATFORM_MAX_PATH];
GetMenuItem(menu, item_info[0][VOTEINFO_ITEM_INDEX], map, sizeof(map), _, info1, sizeof(info1));
AddMenuItem(g_VoteMenu, map, info1);
GetMenuItem(menu, item_info[1][VOTEINFO_ITEM_INDEX], map, sizeof(map), _, info2, sizeof(info2));
AddMenuItem(g_VoteMenu, map, info2);
new voteDuration = GetConVarInt(g_Cvar_VoteDuration);
int voteDuration = g_Cvar_VoteDuration.IntValue;
SetMenuExitButton(g_VoteMenu, false);
VoteMenuToAll(g_VoteMenu, voteDuration);
@ -811,7 +811,7 @@ public Handler_MapVoteFinished(Handle:menu,
new Float:map2percent = float(item_info[1][VOTEINFO_ITEM_VOTES])/ float(num_votes) * 100;
PrintToChatAll("[SM] %t", "Starting Runoff", GetConVarFloat(g_Cvar_RunOffPercent), info1, map1percent, info2, map2percent);
PrintToChatAll("[SM] %t", "Starting Runoff", g_Cvar_RunOffPercent.FloatValue, info1, map1percent, info2, map2percent);
LogMessage("Voting for next map was indecisive, beginning runoff vote");
return;
@ -862,7 +862,7 @@ public Handler_MapVoteMenu(Handle:menu, MenuAction:action, param1, param2)
case MenuAction_VoteCancel:
{
// If we receive 0 votes, pick at random.
if (param1 == VoteCancel_NoVotes && GetConVarBool(g_Cvar_NoVoteMode))
if (param1 == VoteCancel_NoVotes && g_Cvar_NoVoteMode.BoolValue)
{
new count = GetMenuItemCount(menu);
decl String:map[PLATFORM_MAX_PATH];
@ -940,13 +940,13 @@ CreateNextVote()
{
ClearArray(g_NextMapList);
decl String:map[PLATFORM_MAX_PATH];
char map[PLATFORM_MAX_PATH];
new Handle:tempMaps = CloneArray(g_MapList);
GetCurrentMap(map, sizeof(map));
RemoveStringFromArray(tempMaps, map);
if (GetConVarInt(g_Cvar_ExcludeMaps) && GetArraySize(tempMaps) > GetConVarInt(g_Cvar_ExcludeMaps))
if (g_Cvar_ExcludeMaps.IntValue && GetArraySize(tempMaps) > g_Cvar_ExcludeMaps.IntValue)
{
for (new i = 0; i < GetArraySize(g_OldMapList); i++)
{
@ -955,10 +955,10 @@ CreateNextVote()
}
}
new limit = (GetConVarInt(g_Cvar_IncludeMaps) < GetArraySize(tempMaps) ? GetConVarInt(g_Cvar_IncludeMaps) : GetArraySize(tempMaps));
for (new i = 0; i < limit; i++)
int limit = (g_Cvar_IncludeMaps.IntValue < GetArraySize(tempMaps) ? g_Cvar_IncludeMaps.IntValue : GetArraySize(tempMaps));
for (int i = 0; i < limit; i++)
{
new b = GetRandomInt(0, GetArraySize(tempMaps) - 1);
int b = GetRandomInt(0, GetArraySize(tempMaps) - 1);
GetArrayString(tempMaps, b, map, sizeof(map));
PushArrayString(g_NextMapList, map);
RemoveFromArray(tempMaps, b);
@ -1007,7 +1007,7 @@ NominateResult:InternalNominateMap(String:map[], bool:force, owner)
}
/* Too many nominated maps. */
if (GetArraySize(g_NominateList) >= GetConVarInt(g_Cvar_IncludeMaps) && !force)
if (GetArraySize(g_NominateList) >= g_Cvar_IncludeMaps.IntValue && !force)
{
return Nominate_VoteFull;
}
@ -1015,9 +1015,9 @@ NominateResult:InternalNominateMap(String:map[], bool:force, owner)
PushArrayString(g_NominateList, map);
PushArrayCell(g_NominateOwners, owner);
while (GetArraySize(g_NominateList) > GetConVarInt(g_Cvar_IncludeMaps))
while (GetArraySize(g_NominateList) > g_Cvar_IncludeMaps.IntValue)
{
new String:oldmap[PLATFORM_MAX_PATH];
char oldmap[PLATFORM_MAX_PATH];
GetArrayString(g_NominateList, 0, oldmap, sizeof(oldmap));
Call_StartForward(g_NominationsResetForward);
Call_PushString(oldmap);
@ -1142,7 +1142,7 @@ public Native_CheckVoteDone(Handle:plugin, numParams)
public Native_EndOfMapVoteEnabled(Handle:plugin, numParams)
{
return GetConVarBool(g_Cvar_EndOfMapVote);
return g_Cvar_EndOfMapVote.BoolValue;
}
public Native_GetExcludeMapList(Handle:plugin, numParams)

View File

@ -46,8 +46,8 @@ public Plugin myinfo =
url = "http://www.sourcemod.net/"
};
Handle g_Cvar_ExcludeOld = null;
Handle g_Cvar_ExcludeCurrent = null;
ConVar g_Cvar_ExcludeOld;
ConVar g_Cvar_ExcludeCurrent;
Menu g_MapMenu = null;
Handle g_MapList = null;
@ -262,13 +262,13 @@ void BuildMapMenu()
ArrayList excludeMaps;
char currentMap[32];
if (GetConVarBool(g_Cvar_ExcludeOld))
if (g_Cvar_ExcludeOld.BoolValue)
{
excludeMaps = ArrayList(ByteCountToCells(33));
GetExcludeMapList(excludeMaps);
}
if (GetConVarBool(g_Cvar_ExcludeCurrent))
if (g_Cvar_ExcludeCurrent.BoolValue)
{
GetCurrentMap(currentMap, sizeof(currentMap));
}
@ -280,7 +280,7 @@ void BuildMapMenu()
GetArrayString(g_MapList, i, map, sizeof(map));
if (GetConVarBool(g_Cvar_ExcludeCurrent))
if (g_Cvar_ExcludeCurrent.BoolValue)
{
if (StrEqual(map, currentMap))
{
@ -289,7 +289,7 @@ void BuildMapMenu()
}
/* Dont bother with this check if the current map check passed */
if (GetConVarBool(g_Cvar_ExcludeOld) && status == MAPSTATUS_ENABLED)
if (g_Cvar_ExcludeOld.BoolValue && status == MAPSTATUS_ENABLED)
{
if (excludeMaps.FindString(map) != -1)
{

View File

@ -43,7 +43,7 @@ public Plugin:myinfo =
url = "http://www.sourcemod.net/"
};
new Handle:g_Cvar_ExcludeMaps = INVALID_HANDLE;
ConVar g_Cvar_ExcludeMaps;
new Handle:g_MapList = INVALID_HANDLE;
new Handle:g_OldMapList = INVALID_HANDLE;
@ -82,7 +82,7 @@ public Action:Timer_RandomizeNextmap(Handle:timer)
decl String:map[32];
new bool:oldMaps = false;
if (GetConVarInt(g_Cvar_ExcludeMaps) && GetArraySize(g_MapList) > GetConVarInt(g_Cvar_ExcludeMaps))
if (g_Cvar_ExcludeMaps.IntValue && GetArraySize(g_MapList) > g_Cvar_ExcludeMaps.IntValue)
{
oldMaps = true;
}
@ -99,7 +99,7 @@ public Action:Timer_RandomizeNextmap(Handle:timer)
PushArrayString(g_OldMapList, map);
SetNextMap(map);
if (GetArraySize(g_OldMapList) > GetConVarInt(g_Cvar_ExcludeMaps))
if (GetArraySize(g_OldMapList) > g_Cvar_ExcludeMaps.IntValue)
{
RemoveFromArray(g_OldMapList, 0);
}
@ -107,4 +107,4 @@ public Action:Timer_RandomizeNextmap(Handle:timer)
LogAction(-1, -1, "RandomCycle has chosen %s for the nextmap.", map);
return Plugin_Stop;
}
}

View File

@ -48,12 +48,12 @@ new g_adminCount = 0;
new bool:g_isAdmin[MAXPLAYERS+1];
/* Handles to convars used by plugin */
new Handle:sm_reserved_slots;
new Handle:sm_hide_slots;
new Handle:sv_visiblemaxplayers;
new Handle:sm_reserve_type;
new Handle:sm_reserve_maxadmins;
new Handle:sm_reserve_kicktype;
ConVar sm_reserved_slots;
ConVar sm_hide_slots;
ConVar sv_visiblemaxplayers;
ConVar sm_reserve_type;
ConVar sm_reserve_maxadmins;
ConVar sm_reserve_kicktype;
enum KickType
{
@ -73,8 +73,8 @@ public OnPluginStart()
sm_reserve_maxadmins = CreateConVar("sm_reserve_maxadmins", "1", "Maximum amount of admins to let in the server with reserve type 2", 0, true, 0.0);
sm_reserve_kicktype = CreateConVar("sm_reserve_kicktype", "0", "How to select a client to kick (if appropriate)", 0, true, 0.0, true, 2.0);
HookConVarChange(sm_reserved_slots, SlotCountChanged);
HookConVarChange(sm_hide_slots, SlotHideChanged);
sm_reserved_slots.AddChangeHook(SlotCountChanged);
sm_hide_slots.AddChangeHook(SlotHideChanged);
}
public OnPluginEnd()
@ -85,17 +85,17 @@ public OnPluginEnd()
public OnMapStart()
{
if (GetConVarBool(sm_hide_slots))
{
SetVisibleMaxSlots(GetClientCount(false), GetMaxHumanPlayers() - GetConVarInt(sm_reserved_slots));
if (sm_hide_slots.BoolValue)
{
SetVisibleMaxSlots(GetClientCount(false), GetMaxHumanPlayers() - sm_reserved_slots.IntValue);
}
}
public OnConfigsExecuted()
{
if (GetConVarBool(sm_hide_slots))
if (sm_hide_slots.BoolValue)
{
SetVisibleMaxSlots(GetClientCount(false), GetMaxHumanPlayers() - GetConVarInt(sm_reserved_slots));
SetVisibleMaxSlots(GetClientCount(false), GetMaxHumanPlayers() - sm_reserved_slots.IntValue);
}
}
@ -108,9 +108,9 @@ public Action:OnTimedKick(Handle:timer, any:client)
KickClient(client, "%T", "Slot reserved", client);
if (GetConVarBool(sm_hide_slots))
if (sm_hide_slots.BoolValue)
{
SetVisibleMaxSlots(GetClientCount(false), GetMaxHumanPlayers() - GetConVarInt(sm_reserved_slots));
SetVisibleMaxSlots(GetClientCount(false), GetMaxHumanPlayers() - sm_reserved_slots.IntValue);
}
return Plugin_Handled;
@ -118,7 +118,7 @@ public Action:OnTimedKick(Handle:timer, any:client)
public OnClientPostAdminCheck(client)
{
new reserved = GetConVarInt(sm_reserved_slots);
new reserved = sm_reserved_slots.IntValue;
if (reserved > 0)
{
@ -126,13 +126,13 @@ public OnClientPostAdminCheck(client)
new limit = GetMaxHumanPlayers() - reserved;
new flags = GetUserFlagBits(client);
new type = GetConVarInt(sm_reserve_type);
new type = sm_reserve_type.IntValue;
if (type == 0)
{
if (clients <= limit || IsFakeClient(client) || flags & ADMFLAG_ROOT || flags & ADMFLAG_RESERVATION)
{
if (GetConVarBool(sm_hide_slots))
if (sm_hide_slots.BoolValue)
{
SetVisibleMaxSlots(clients, limit);
}
@ -172,7 +172,7 @@ public OnClientPostAdminCheck(client)
g_isAdmin[client] = true;
}
if (clients > limit && g_adminCount < GetConVarInt(sm_reserve_maxadmins))
if (clients > limit && g_adminCount < sm_reserve_maxadmins.IntValue)
{
/* Server is full, reserved slots aren't and client doesn't have reserved slots access */
@ -198,9 +198,9 @@ public OnClientPostAdminCheck(client)
public OnClientDisconnect_Post(client)
{
if (GetConVarBool(sm_hide_slots))
if (sm_hide_slots.BoolValue)
{
SetVisibleMaxSlots(GetClientCount(false), GetMaxHumanPlayers() - GetConVarInt(sm_reserved_slots));
SetVisibleMaxSlots(GetClientCount(false), GetMaxHumanPlayers() - sm_reserved_slots.IntValue);
}
if (g_isAdmin[client])
@ -210,30 +210,30 @@ public OnClientDisconnect_Post(client)
}
}
public SlotCountChanged(Handle:convar, const String:oldValue[], const String:newValue[])
public SlotCountChanged(ConVar convar, const String:oldValue[], const String:newValue[])
{
/* Reserved slots or hidden slots have been disabled - reset sv_visiblemaxplayers */
new slotcount = GetConVarInt(convar);
new slotcount = convar.IntValue;
if (slotcount == 0)
{
ResetVisibleMax();
}
else if (GetConVarBool(sm_hide_slots))
else if (sm_hide_slots.BoolValue)
{
SetVisibleMaxSlots(GetClientCount(false), GetMaxHumanPlayers() - slotcount);
}
}
public SlotHideChanged(Handle:convar, const String:oldValue[], const String:newValue[])
public SlotHideChanged(ConVar convar, const String:oldValue[], const String:newValue[])
{
/* Reserved slots or hidden slots have been disabled - reset sv_visiblemaxplayers */
if (!GetConVarBool(convar))
if (!convar.BoolValue)
{
ResetVisibleMax();
}
else
{
SetVisibleMaxSlots(GetClientCount(false), GetMaxHumanPlayers() - GetConVarInt(sm_reserved_slots));
SetVisibleMaxSlots(GetClientCount(false), GetMaxHumanPlayers() - sm_reserved_slots.IntValue);
}
}
@ -248,17 +248,17 @@ SetVisibleMaxSlots(clients, limit)
num = limit;
}
SetConVarInt(sv_visiblemaxplayers, num);
sv_visiblemaxplayers.IntValue = num;
}
ResetVisibleMax()
{
SetConVarInt(sv_visiblemaxplayers, -1);
sv_visiblemaxplayers.IntValue = -1;
}
SelectKickClient()
{
new KickType:type = KickType:GetConVarInt(sm_reserve_kicktype);
new KickType:type = KickType:sm_reserve_kicktype.IntValue;
new Float:highestValue;
new highestValueId;
@ -326,4 +326,4 @@ SelectKickClient()
}
return highestValueId;
}
}

View File

@ -46,12 +46,12 @@ public Plugin:myinfo =
url = "http://www.sourcemod.net/"
};
new Handle:g_Cvar_Needed = INVALID_HANDLE;
new Handle:g_Cvar_MinPlayers = INVALID_HANDLE;
new Handle:g_Cvar_InitialDelay = INVALID_HANDLE;
new Handle:g_Cvar_Interval = INVALID_HANDLE;
new Handle:g_Cvar_ChangeTime = INVALID_HANDLE;
new Handle:g_Cvar_RTVPostVoteAction = INVALID_HANDLE;
ConVar g_Cvar_Needed;
ConVar g_Cvar_MinPlayers;
ConVar g_Cvar_InitialDelay;
ConVar g_Cvar_Interval;
ConVar g_Cvar_ChangeTime;
ConVar g_Cvar_RTVPostVoteAction;
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.
@ -106,7 +106,7 @@ public OnConfigsExecuted()
{
g_CanRTV = true;
g_RTVAllowed = false;
CreateTimer(GetConVarFloat(g_Cvar_InitialDelay), Timer_DelayRTV, _, TIMER_FLAG_NO_MAPCHANGE);
CreateTimer(g_Cvar_InitialDelay.FloatValue, Timer_DelayRTV, _, TIMER_FLAG_NO_MAPCHANGE);
}
public OnClientConnected(client)
@ -117,7 +117,7 @@ public OnClientConnected(client)
g_Voted[client] = false;
g_Voters++;
g_VotesNeeded = RoundToFloor(float(g_Voters) * GetConVarFloat(g_Cvar_Needed));
g_VotesNeeded = RoundToFloor(float(g_Voters) * g_Cvar_Needed.FloatValue);
return;
}
@ -134,7 +134,7 @@ public OnClientDisconnect(client)
g_Voters--;
g_VotesNeeded = RoundToFloor(float(g_Voters) * GetConVarFloat(g_Cvar_Needed));
g_VotesNeeded = RoundToFloor(float(g_Voters) * g_Cvar_Needed.FloatValue);
if (!g_CanRTV)
{
@ -146,7 +146,7 @@ public OnClientDisconnect(client)
g_Votes >= g_VotesNeeded &&
g_RTVAllowed )
{
if (GetConVarInt(g_Cvar_RTVPostVoteAction) == 1 && HasEndOfMapVoteFinished())
if (g_Cvar_RTVPostVoteAction.IntValue == 1 && HasEndOfMapVoteFinished())
{
return;
}
@ -186,7 +186,7 @@ public Action:Command_RTV(client, args)
AttemptRTV(client)
{
if (!g_RTVAllowed || (GetConVarInt(g_Cvar_RTVPostVoteAction) == 1 && HasEndOfMapVoteFinished()))
if (!g_RTVAllowed || (g_Cvar_RTVPostVoteAction.IntValue == 1 && HasEndOfMapVoteFinished()))
{
ReplyToCommand(client, "[SM] %t", "RTV Not Allowed");
return;
@ -198,7 +198,7 @@ AttemptRTV(client)
return;
}
if (GetClientCount(true) < GetConVarInt(g_Cvar_MinPlayers))
if (GetClientCount(true) < g_Cvar_MinPlayers.IntValue)
{
ReplyToCommand(client, "[SM] %t", "Minimal Players Not Met");
return;
@ -255,13 +255,13 @@ StartRTV()
if (CanMapChooserStartVote())
{
new MapChange:when = MapChange:GetConVarInt(g_Cvar_ChangeTime);
new MapChange:when = MapChange:g_Cvar_ChangeTime.IntValue;
InitiateMapChooserVote(when);
ResetRTV();
g_RTVAllowed = false;
CreateTimer(GetConVarFloat(g_Cvar_Interval), Timer_DelayRTV, _, TIMER_FLAG_NO_MAPCHANGE);
CreateTimer(g_Cvar_Interval.FloatValue, Timer_DelayRTV, _, TIMER_FLAG_NO_MAPCHANGE);
}
}
@ -288,4 +288,4 @@ public Action:Timer_ChangeMap(Handle:hTimer)
}
return Plugin_Stop;
}
}