Minor improvements

Logging changes to Teleport.sp
Add sm_querycvar command to ExtraCommands + logging changes
Fix some stupid devel bugs in SprayManager
This commit is contained in:
Obuss 2017-01-29 01:44:35 -06:00
parent d5c49349e8
commit 643dcbcfa3
3 changed files with 96 additions and 28 deletions

View File

@ -28,10 +28,10 @@ public Plugin myinfo =
name = "Advanced Commands", name = "Advanced Commands",
author = "BotoX + Obus", author = "BotoX + Obus",
description = "Adds extra commands for admins.", description = "Adds extra commands for admins.",
version = "2.1.0", version = "2.1.2",
url = "https://github.com/CSSZombieEscape/sm-plugins/tree/master/ExtraCommands/" url = "https://github.com/CSSZombieEscape/sm-plugins/tree/master/ExtraCommands/"
}; };
public void OnPluginStart() public void OnPluginStart()
{ {
LoadTranslations("common.phrases"); LoadTranslations("common.phrases");
@ -51,13 +51,14 @@ public void OnPluginStart()
RegAdminCmd("sm_resize", Command_ModelScale, ADMFLAG_GENERIC, "sm_resize <#userid|name> <scale>"); RegAdminCmd("sm_resize", Command_ModelScale, ADMFLAG_GENERIC, "sm_resize <#userid|name> <scale>");
RegAdminCmd("sm_setmodel", Command_SetModel, ADMFLAG_GENERIC, "sm_setmodel <#userid|name> <modelpath>"); RegAdminCmd("sm_setmodel", Command_SetModel, ADMFLAG_GENERIC, "sm_setmodel <#userid|name> <modelpath>");
RegAdminCmd("sm_setscore", Command_SetScore, ADMFLAG_GENERIC, "sm_setscore <#userid|name> <value>"); RegAdminCmd("sm_setscore", Command_SetScore, ADMFLAG_GENERIC, "sm_setscore <#userid|name> <value>");
RegAdminCmd("sm_setdeath", Command_SetDeath, ADMFLAG_GENERIC, "sm_setdeath <#userid|name> <value>"); RegAdminCmd("sm_setdeaths", Command_SetDeaths, ADMFLAG_GENERIC, "sm_setdeaths <#userid|name> <value>");
RegAdminCmd("sm_setteamscore", Command_SetTeamScore, ADMFLAG_GENERIC, "sm_setteamscore <team> <value>"); RegAdminCmd("sm_setteamscore", Command_SetTeamScore, ADMFLAG_GENERIC, "sm_setteamscore <team> <value>");
RegAdminCmd("sm_waila", Command_WAILA, ADMFLAG_GENERIC); RegAdminCmd("sm_waila", Command_WAILA, ADMFLAG_GENERIC);
RegAdminCmd("sm_info", Command_WAILA, ADMFLAG_GENERIC); RegAdminCmd("sm_info", Command_WAILA, ADMFLAG_GENERIC);
RegAdminCmd("sm_fcvar", Command_ForceCVar, ADMFLAG_CHEATS, "sm_fcvar <#userid|name> <cvar> <value>"); RegAdminCmd("sm_fcvar", Command_ForceCVar, ADMFLAG_CHEATS, "sm_fcvar <#userid|name> <cvar> <value>");
RegAdminCmd("sm_setclantag", Command_SetClanTag, ADMFLAG_CHEATS, "sm_setclantag <#userid|name> [text]"); RegAdminCmd("sm_setclantag", Command_SetClanTag, ADMFLAG_CHEATS, "sm_setclantag <#userid|name> [text]");
RegAdminCmd("sm_fakecommand", Command_FakeCommand, ADMFLAG_CHEATS, "sm_fakecommand <#userid|name> [command] [args]"); RegAdminCmd("sm_fakecommand", Command_FakeCommand, ADMFLAG_CHEATS, "sm_fakecommand <#userid|name> [command] [args]");
RegAdminCmd("sm_querycvar", Command_QueryCVar, ADMFLAG_GENERIC, "sm_querycvar <#userid|name> [cvar]");
HookEvent("bomb_planted", Event_BombPlanted, EventHookMode_Pre); HookEvent("bomb_planted", Event_BombPlanted, EventHookMode_Pre);
HookEvent("bomb_defused", Event_BombDefused, EventHookMode_Pre); HookEvent("bomb_defused", Event_BombDefused, EventHookMode_Pre);
@ -935,11 +936,11 @@ public Action Command_SetScore(int client, int argc)
return Plugin_Handled; return Plugin_Handled;
} }
public Action Command_SetDeath(int client, int argc) public Action Command_SetDeaths(int client, int argc)
{ {
if(argc < 2) if(argc < 2)
{ {
ReplyToCommand(client, "[SM] Usage: sm_setdeath <#userid|name> <value>"); ReplyToCommand(client, "[SM] Usage: sm_setdeaths <#userid|name> <value>");
return Plugin_Handled; return Plugin_Handled;
} }
@ -968,13 +969,13 @@ public Action Command_SetDeath(int client, int argc)
if(bIsML) if(bIsML)
{ {
ShowActivity2(client, "\x01[SM] \x04", "\x01Set death to \x04%d\x01 on target \x04%s", iVal, sTargetName); ShowActivity2(client, "\x01[SM] \x04", "\x01Set deaths to \x04%d\x01 on target \x04%s", iVal, sTargetName);
LogAction(client, -1, "\"%L\" set death to \"%d\" on target \"%s\"", client, iVal, sTargetName); LogAction(client, -1, "\"%L\" set deaths to \"%d\" on target \"%s\"", client, iVal, sTargetName);
} }
else else
{ {
ShowActivity2(client, "\x01[SM] \x04", "\x01Set death to \x04%d\x01 on target \x04%s", iVal, sTargetName); ShowActivity2(client, "\x01[SM] \x04", "\x01Set deaths to \x04%d\x01 on target \x04%s", iVal, sTargetName);
LogAction(client, iTargets[0], "\"%L\" set death to \"%d\" on target \"%L\"", client, iVal, iTargets[0]); LogAction(client, iTargets[0], "\"%L\" set deaths to \"%d\" on target \"%L\"", client, iVal, iTargets[0]);
} }
return Plugin_Handled; return Plugin_Handled;
@ -1206,6 +1207,54 @@ public Action Command_FakeCommand(int client, int argc)
return Plugin_Handled; return Plugin_Handled;
} }
public Action Command_QueryCVar(int client, int argc)
{
if(argc < 2)
{
ReplyToCommand(client, "[SM] Usage: sm_querycvar <#userid|name> [cvar]");
return Plugin_Handled;
}
char sArg[64];
char sArg2[64];
int iTarget;
GetCmdArg(1, sArg, sizeof(sArg));
GetCmdArg(2, sArg2, sizeof(sArg2));
if((iTarget = FindTarget(client, sArg, true)) <= 0)
return Plugin_Handled;
if(QueryClientConVar(iTarget, sArg2, ConVarQueryFinished_QueryCVar, client) == QUERYCOOKIE_FAILED)
ReplyToCommand(client, "[SM] Failed to query cvar \"%s\"", sArg2);
return Plugin_Handled;
}
public void ConVarQueryFinished_QueryCVar(QueryCookie hCookie, int client, ConVarQueryResult res, const char[] sCVarName, const char[] sCVarValue, int admin)
{
switch(res)
{
case ConVarQuery_NotFound:
{
ReplyToCommand(admin, "[SM] No such cvar.");
return;
}
case ConVarQuery_NotValid:
{
ReplyToCommand(admin, "[SM] Commands can not be queried.");
return;
}
case ConVarQuery_Protected:
{
ReplyToCommand(admin, "[SM] That cvar is protected and can not be queried.");
return;
}
}
ReplyToCommand(admin, "[SM] Value for cvar \"%s\" on client \"%N\" is \"%s\".", sCVarName, client, sCVarValue);
}
stock any clamp(any input, any min, any max) stock any clamp(any input, any min, any max)
{ {
any retval = input < min ? min : input; any retval = input < min ? min : input;

View File

@ -73,7 +73,7 @@ public Plugin myinfo =
name = "Spray Manager", name = "Spray Manager",
description = "A plugin to help manage player sprays.", description = "A plugin to help manage player sprays.",
author = "Obus", author = "Obus",
version = "2.0.0", version = "2.0.5",
url = "https://github.com/CSSZombieEscape/sm-plugins/tree/master/SprayManager" url = "https://github.com/CSSZombieEscape/sm-plugins/tree/master/SprayManager"
} }
@ -124,7 +124,7 @@ public void OnPluginStart()
g_cvarMaxSprayLifetime = CreateConVar("sm_spraymanager_maxspraylifetime", "2", "If not using persistent sprays, remove sprays after their global lifetime (in rounds) exceeds this number"); g_cvarMaxSprayLifetime = CreateConVar("sm_spraymanager_maxspraylifetime", "2", "If not using persistent sprays, remove sprays after their global lifetime (in rounds) exceeds this number");
AutoExecConfig(true, "plugin.spraymanager"); AutoExecConfig(true, "plugin.SprayManager");
g_hTraceTimer = CreateTimer(0.25, Timer_PerformPlayerTraces, _, TIMER_REPEAT); g_hTraceTimer = CreateTimer(0.25, Timer_PerformPlayerTraces, _, TIMER_REPEAT);
@ -158,6 +158,7 @@ public void OnPluginEnd()
RemoveTempEntHook("Player Decal", HookDecal); RemoveTempEntHook("Player Decal", HookDecal);
RemoveNormalSoundHook(HookSprayer); RemoveNormalSoundHook(HookSprayer);
UnhookConVarChange(g_cvarHookedDecalFrequency, ConVarChanged_DecalFrequency);
if (g_hDatabase != null) if (g_hDatabase != null)
{ {
@ -232,8 +233,9 @@ public void OnClientDisconnect(int client)
{ {
if (IsValidClient(client)) if (IsValidClient(client))
{ {
g_iAllowSpray = client; g_bSkipDecalHook = true;
SprayClientDecalToAll(client, 0, ACTUAL_NULL_VECTOR); SprayClientDecalToAll(client, 0, ACTUAL_NULL_VECTOR);
g_bSkipDecalHook = false;
} }
ClearPlayerInfo(client); ClearPlayerInfo(client);
@ -556,7 +558,7 @@ int MenuHandler_Menu_Trace(Menu hMenu, MenuAction action, int iParam1, int iPara
case 5: case 5:
{ {
if (BanClientSpray(target, iParam1)) if (BanClientSpray(iParam1, target))
{ {
ShowActivity2(iParam1, "\x01\x04[SprayManager] ", "\x01Banned \x04%N\x01's spray", target); ShowActivity2(iParam1, "\x01\x04[SprayManager] ", "\x01Banned \x04%N\x01's spray", target);
LogAction(iParam1, target, "\"%L\" banned \"%L\"'s spray", iParam1, target); LogAction(iParam1, target, "\"%L\" banned \"%L\"'s spray", iParam1, target);
@ -639,7 +641,7 @@ int MenuHandler_Menu_Trace_SprayBan(Menu hMenu, MenuAction action, int iParam1,
if (SprayBanClient(iParam1, target, StringToInt(sOption), "Inappropriate Spray")) if (SprayBanClient(iParam1, target, StringToInt(sOption), "Inappropriate Spray"))
{ {
ShowActivity2(iParam1, "\x01\x04[SprayManager] ", "\x01Spray banned \x04%N", target); ShowActivity2(iParam1, "\x01\x04[SprayManager] ", "\x01Spray banned \x04%N", target);
LogAction(iParam1, target, "\"%L\" spray banned \"%L\"", iParam1, target); LogAction(iParam1, target, "\"%L\" spray banned \"%L\" (Hash: \"%s\")", iParam1, target, g_sSprayHash[target]);
} }
g_iSprayBanTarget[iParam1] = 0; g_iSprayBanTarget[iParam1] = 0;
@ -917,7 +919,7 @@ int MenuHandler_Menu_SprayBan_Length(Menu hMenu, MenuAction action, int iParam1,
if (SprayBanClient(iParam1, target, StringToInt(sOption), "Inappropriate Spray")) if (SprayBanClient(iParam1, target, StringToInt(sOption), "Inappropriate Spray"))
{ {
ShowActivity2(iParam1, "\x01\x04[SprayManager] ", "\x01Spray banned \x04%N", target); ShowActivity2(iParam1, "\x01\x04[SprayManager] ", "\x01Spray banned \x04%N", target);
LogAction(iParam1, target, "\"%L\" spray banned \"%L\"", iParam1, target); LogAction(iParam1, target, "\"%L\" spray banned \"%L\" (Hash: \"%s\")", iParam1, target, g_sSprayHash[target]);
} }
g_iSprayBanTarget[iParam1] = 0; g_iSprayBanTarget[iParam1] = 0;
@ -990,7 +992,7 @@ int MenuHandler_Menu_BanSpray(Menu hMenu, MenuAction action, int iParam1, int iP
} }
else else
{ {
if (BanClientSpray(target, iParam1)) if (BanClientSpray(iParam1, target))
{ {
ShowActivity2(iParam1, "\x01\x04[SprayManager] ", "\x01Banned \x04%N\x01's spray", target); ShowActivity2(iParam1, "\x01\x04[SprayManager] ", "\x01Banned \x04%N\x01's spray", target);
LogAction(iParam1, target, "\"%L\" banned \"%L\"'s spray", iParam1, target); LogAction(iParam1, target, "\"%L\" banned \"%L\"'s spray", iParam1, target);
@ -1422,7 +1424,7 @@ public Action Command_SprayBan(int client, int argc)
return Plugin_Handled; return Plugin_Handled;
ShowActivity2(client, "\x01\x04[SprayManager] ", "\x01Spray banned \x04%N", iTarget); ShowActivity2(client, "\x01\x04[SprayManager] ", "\x01Spray banned \x04%N", iTarget);
LogAction(client, iTarget, "\"%L\" spray banned \"%L\"", client, iTarget); LogAction(client, iTarget, "\"%L\" spray banned \"%L\" (Hash: \"%s\")", client, iTarget, g_sSprayHash[iTarget]);
return Plugin_Handled; return Plugin_Handled;
} }
@ -1813,14 +1815,14 @@ public Action Timer_ProcessPersistentSprays(Handle hThis)
if (!IsValidClient(x) || IsFakeClient(x)) if (!IsValidClient(x) || IsFakeClient(x))
continue; continue;
if (!IsVectorZero(g_vecSprayOrigin[i])) if (!IsVectorZero(g_vecSprayOrigin[x]))
g_iClientToClientSprayLifetime[x][i]++; g_iClientToClientSprayLifetime[i][x]++;
if (g_iClientToClientSprayLifetime[x][i] >= g_iClientSprayLifetime[x]) if (g_iClientToClientSprayLifetime[i][x] >= g_iClientSprayLifetime[i])
{ {
g_bSkipDecalHook = true; g_bSkipDecalHook = true;
SprayClientDecalToOne(i, x, g_iDecalEntity[i], g_vecSprayOrigin[i]); SprayClientDecalToOne(x, i, g_iDecalEntity[x], g_vecSprayOrigin[x]);
g_iClientToClientSprayLifetime[x][i] = 0; g_iClientToClientSprayLifetime[i][x] = 0;
g_bSkipDecalHook = false; g_bSkipDecalHook = false;
} }
} }
@ -2450,6 +2452,7 @@ void ClearPlayerInfo(int client)
g_iSprayUnbanTimestamp[client] = -1; g_iSprayUnbanTimestamp[client] = -1;
g_fNextSprayTime[client] = 0.0; g_fNextSprayTime[client] = 0.0;
g_vecSprayOrigin[client] = ACTUAL_NULL_VECTOR; g_vecSprayOrigin[client] = ACTUAL_NULL_VECTOR;
g_SprayAABB[client] = view_as<float>({ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }); //???
} }
void UpdateClientToClientSprayLifeTime(int client, int iLifeTime) void UpdateClientToClientSprayLifeTime(int client, int iLifeTime)

View File

@ -10,8 +10,8 @@ public Plugin myinfo =
name = "Teleport Commands", name = "Teleport Commands",
author = "Obus", author = "Obus",
description = "Adds commands to teleport clients.", description = "Adds commands to teleport clients.",
version = "1.2", version = "1.3.1",
url = "https://github.com/CSSZombieEscape/sm-plugins/blob/master/Teleport/" url = "https://github.com/CSSZombieEscape/sm-plugins/blob/master/Teleport/"
} }
public void OnPluginStart() public void OnPluginStart()
@ -62,7 +62,11 @@ public Action Command_Bring(int client, int argc)
} }
ShowActivity2(client, "\x01[SM] \x04", "\x01Brought \x04%s\x01", sTargetName); ShowActivity2(client, "\x01[SM] \x04", "\x01Brought \x04%s\x01", sTargetName);
LogAction(client, -1, "\"%L\" brought \"%s\"", client, sTargetName);
if (iTargetCount > 1)
LogAction(client, -1, "\"%L\" brought \"%s\"", client, sTargetName);
else
LogAction(client, iTargets[0], "\"%L\" brought \"%L\"", client, iTargets[0]);
return Plugin_Handled; return Plugin_Handled;
} }
@ -199,7 +203,11 @@ public Action Command_Send(int client, int argc)
ShowActivity3(client, "\x01[SM] \x04", "\x01Teleported \x04%s\x01 to their aimpoint.", sTargetName); ShowActivity3(client, "\x01[SM] \x04", "\x01Teleported \x04%s\x01 to their aimpoint.", sTargetName);
ReplyToCommand(client, "\x01[SM] Teleported \x04%s\x01 to your aimpoint.", sTargetName); ReplyToCommand(client, "\x01[SM] Teleported \x04%s\x01 to your aimpoint.", sTargetName);
LogAction(client, -1, "\"%L\" teleported target \"%s\" to their aimpoint", client, sTargetName);
if (iTargetCount > 1)
LogAction(client, -1, "\"%L\" teleported target \"%s\" to their aimpoint", client, sTargetName);
else
LogAction(client, iTargets[0], "\"%L\" teleported target \"%L\" to their aimpoint", client, iTargets[0]);
return Plugin_Handled; return Plugin_Handled;
} }
@ -217,7 +225,11 @@ public Action Command_Send(int client, int argc)
} }
ShowActivity2(client, "\x01[SM] \x04", "\x01Teleported \x04%s\x01 to \x04%N\x01.", sTargetName, iTarget); ShowActivity2(client, "\x01[SM] \x04", "\x01Teleported \x04%s\x01 to \x04%N\x01.", sTargetName, iTarget);
LogAction(client, iTarget, "\"%L\" teleported target \"%s\" to \"%L\"", client, sTargetName, iTarget);
if (iTargetCount > 1)
LogAction(client, -1, "\"%L\" teleported target \"%s\" to \"%L\"", client, sTargetName, iTarget);
else
LogAction(client, iTargets[0], "\"%L\" teleported target \"%L\" to \"%L\"", client, iTargets[0], iTarget);
return Plugin_Handled; return Plugin_Handled;
} }
@ -255,7 +267,11 @@ public Action Command_TpAim(int client, int argc)
ShowActivity3(client, "\x01[SM] \x04", "\x01Teleported \x04%s\x01 to their aimpoint.", sTargetName); ShowActivity3(client, "\x01[SM] \x04", "\x01Teleported \x04%s\x01 to their aimpoint.", sTargetName);
ReplyToCommand(client, "\x01[SM] Teleported \x04%s\x01 to your aimpoint.", sTargetName); ReplyToCommand(client, "\x01[SM] Teleported \x04%s\x01 to your aimpoint.", sTargetName);
LogAction(client, -1, "\"%L\" teleported \"%s\" to their aimpoint", client, sTargetName);
if (iTargetCount > 1)
LogAction(client, -1, "\"%L\" teleported \"%s\" to their aimpoint", client, sTargetName);
else
LogAction(client, iTargets[0], "\"%L\" teleported \"%L\" to their aimpoint", client, iTargets[0]);
return Plugin_Handled; return Plugin_Handled;
} }