Add ConVarSuppression
This commit is contained in:
parent
2549a5e5aa
commit
83c05dc81e
118
ConVarSuppression/scripting/ConVarSuppression.sp
Normal file
118
ConVarSuppression/scripting/ConVarSuppression.sp
Normal file
@ -0,0 +1,118 @@
|
||||
#pragma semicolon 1
|
||||
#include <sourcemod>
|
||||
|
||||
#define PLUGIN_PREFIX "\x04[ConVar Suppression]\x03 "
|
||||
#define PLUGIN_VERSION "1.0"
|
||||
|
||||
new Handle:g_hGlobalTrie = INVALID_HANDLE;
|
||||
|
||||
public Plugin:myinfo =
|
||||
{
|
||||
name = "ConVar Suppression", /* https://www.youtube.com/watch?v=ZhjtChtUmBE&hd=1 */
|
||||
author = "Kyle Sanderson",
|
||||
description = "Atleast we have candy.",
|
||||
version = PLUGIN_VERSION,
|
||||
url = "http://www.SourceMod.net/"
|
||||
};
|
||||
|
||||
public OnPluginStart()
|
||||
{
|
||||
g_hGlobalTrie = CreateTrie();
|
||||
HookEvent("server_cvar", Event_ServerCvar, EventHookMode_Pre);
|
||||
RegAdminCmd("sm_suppressconvar", OnSupressConVar, ADMFLAG_ROOT, "Supress a ConVar from displaying changes to Clients.");
|
||||
|
||||
CreateConVar("sm_convarsuppression_version", PLUGIN_VERSION, "Version string for ConVar Supression.", FCVAR_REPLICATED|FCVAR_DONTRECORD|FCVAR_NOTIFY);
|
||||
|
||||
AutoExecConfig(true, "plugin.ConVarSupression");
|
||||
}
|
||||
|
||||
public Action:OnSupressConVar(client, argc)
|
||||
{
|
||||
if (client && !IsClientInGame(client)) /* Isn't needed, but makes me feel safe inside. */
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:sCommand[256];
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
if (!GetCmdArg(0, sCommand, sizeof(sCommand)))
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
ReplyToCommand(client, "%s%s <convar> <enabled|disabled>", PLUGIN_PREFIX, sCommand);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (!GetCmdArg(2, sCommand, sizeof(sCommand)))
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
TrimString(sCommand);
|
||||
new iValue = -1;
|
||||
|
||||
if (!IsCharNumeric(sCommand[0]))
|
||||
{
|
||||
switch (CharToLower(sCommand[0]))
|
||||
{
|
||||
case 'd':
|
||||
{
|
||||
iValue = 0;
|
||||
}
|
||||
|
||||
case 'e':
|
||||
{
|
||||
iValue = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
iValue = StringToInt(sCommand);
|
||||
}
|
||||
|
||||
if (!GetCmdArg(1, sCommand, sizeof(sCommand)))
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
switch (iValue)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
RemoveFromTrie(g_hGlobalTrie, sCommand);
|
||||
if (client)
|
||||
{
|
||||
ReplyToCommand(client, "%sRemoved ConVar: %s", PLUGIN_PREFIX, sCommand);
|
||||
}
|
||||
}
|
||||
|
||||
case 1:
|
||||
{
|
||||
SetTrieValue(g_hGlobalTrie, sCommand, 1, true);
|
||||
if (client)
|
||||
{
|
||||
ReplyToCommand(client, "%sAdded Hook for ConVar: %s", PLUGIN_PREFIX, sCommand);
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
ReplyToCommand(client, "%sIllegal Input for Enabled/Disabled with ConVar: %s", PLUGIN_PREFIX, sCommand);
|
||||
}
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Event_ServerCvar(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
decl String:sConVarName[64];
|
||||
new iValue;
|
||||
|
||||
GetEventString(event, "cvarname", sConVarName, sizeof(sConVarName));
|
||||
return (GetTrieValue(g_hGlobalTrie, sConVarName, iValue) && iValue) ? Plugin_Handled : Plugin_Continue;
|
||||
}
|
@ -29,7 +29,7 @@
|
||||
* Returns true if the player is a zombie, false if not.
|
||||
*
|
||||
* @param client The client index.
|
||||
*
|
||||
*
|
||||
* @return True if zombie, false if not.
|
||||
* @error Invalid client index, not connected or not alive.
|
||||
*/
|
||||
@ -39,7 +39,7 @@ native bool ZR_IsClientZombie(int client);
|
||||
* Returns true if the player is a human, false if not.
|
||||
*
|
||||
* @param client The client index.
|
||||
*
|
||||
*
|
||||
* @return True if human, false if not.
|
||||
* @error Invalid client index, not connected or not alive.
|
||||
*/
|
||||
@ -77,13 +77,13 @@ native int ZR_HumanClient(int client, bool respawn = false, bool protect = false
|
||||
/**
|
||||
* Called when a player is about to become a zombie.
|
||||
* Here you can modify any variable or block the infection entirely.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param attacker The the infecter. (-1 if there is no infecter)
|
||||
* @param motherInfect If the client is becoming a mother zombie.
|
||||
* @param respawnOverride True if the respawn cvar is being overridden.
|
||||
* @param respawn The value that respawn is being overridden with.
|
||||
*
|
||||
*
|
||||
* @return Plugin_Handled to block infection. Anything else
|
||||
* (like Plugin_Continue) to allow infection.
|
||||
*/
|
||||
@ -91,7 +91,7 @@ forward Action ZR_OnClientInfect(int &client, int &attacker, bool &motherInfect,
|
||||
|
||||
/**
|
||||
* Called after a player has become a zombie.
|
||||
*
|
||||
*
|
||||
* @param client The client that was infected.
|
||||
* @param attacker The the infecter. (-1 if there is no infecter)
|
||||
* @param motherInfect If the client is a mother zombie.
|
||||
@ -103,11 +103,11 @@ forward void ZR_OnClientInfected(int client, int attacker, bool motherInfect, bo
|
||||
/**
|
||||
* Called when a player is about to become a human. (Through an admin command).
|
||||
* Here you can modify any variable or block the action entirely.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param respawn True if the client was respawned, false if not.
|
||||
* @param protect True if the client spawn protected, false if not.
|
||||
*
|
||||
*
|
||||
* @return Plugin_Handled to block infection. Anything else
|
||||
* (like Plugin_Continue) to allow acion.
|
||||
*/
|
||||
@ -115,7 +115,7 @@ forward Action ZR_OnClientHuman(int &client, bool &respawn, bool &protect);
|
||||
|
||||
/**
|
||||
* Called after a player has become a human. (Through an admin command.)
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param respawn Whether the client was respawned.
|
||||
* @param protect Whether the client has spawn protection.
|
||||
|
@ -38,7 +38,7 @@ enum ZR_RespawnCondition
|
||||
|
||||
/**
|
||||
* Spawns a player into the round.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param condition Optional. Set respawn condition, defaults to current
|
||||
* ZR settings. See ZR_RespawnCondition for details.
|
||||
@ -49,7 +49,7 @@ native void ZR_RespawnClient(int client, ZR_RespawnCondition condition = ZR_Reps
|
||||
/**
|
||||
* Called right before ZR is about to respawn a player.
|
||||
* Here you can modify any variable or stop the action entirely.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param condition Respawn condition. See ZR_RespawnCondition for
|
||||
* details.
|
||||
@ -60,7 +60,7 @@ forward Action ZR_OnClientRespawn(int &client, ZR_RespawnCondition &condition);
|
||||
|
||||
/**
|
||||
* Called after ZR respawned a player.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param condition Current condition of the respawned player. See
|
||||
* ZR_RespawnCondition for details.
|
||||
@ -69,10 +69,10 @@ forward void ZR_OnClientRespawned(int client, ZR_RespawnCondition condition);
|
||||
|
||||
/**
|
||||
* Set if a player died by a suicide or world damage.
|
||||
|
||||
|
||||
* Note: This will change the respawn condition.
|
||||
* Note: This value is reset to default by ZR when a zombie player dies.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param suicide True to say the player suicided, false if killed by another
|
||||
* player.
|
||||
@ -85,9 +85,9 @@ native void ZR_SetKilledByWorld(int client, bool suicide);
|
||||
* Get whether the player died by a suicide or world damage.
|
||||
*
|
||||
* Note: This value is only valid after death event, and before respawn.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
*
|
||||
*
|
||||
* @return True if the player died by suicide, false if killed by
|
||||
* another player.
|
||||
* @error Invalid client index or not connected.
|
||||
|
Loading…
Reference in New Issue
Block a user