Added a way to quiet any sayhook if it wasn't successfully executed, fixed double-ztele'ing. (Note: Linux can't compile the plugin anymore.)

This commit is contained in:
Greyscale 2009-05-06 05:31:48 +02:00
parent cec31406d0
commit a89f98cc38
5 changed files with 35 additions and 8 deletions

View File

@ -393,7 +393,12 @@
"ZTele max" "ZTele max"
{ {
"#format" "{1:d}" "#format" "{1:d}"
"en" "You have reached your max of {1} teleports per round." "en" "You have reached your max of {1} teleport(s) per round."
}
"ZTele in progress"
{
"en" "You are currently pending teleportation."
} }
"ZTele autocancel text" "ZTele autocancel text"

View File

@ -47,6 +47,7 @@ enum CvarsList
Handle:CVAR_DAMAGE_SUICIDE_HUMAN, Handle:CVAR_DAMAGE_SUICIDE_HUMAN,
Handle:CVAR_DAMAGE_SUICIDE_CMDS, Handle:CVAR_DAMAGE_SUICIDE_CMDS,
Handle:CVAR_SAYHOOKS_QUIET, Handle:CVAR_SAYHOOKS_QUIET,
Handle:CVAR_SAYHOOKS_QUIET_FILTER,
Handle:CVAR_SAYHOOKS_QUIET_FLAGS, Handle:CVAR_SAYHOOKS_QUIET_FLAGS,
Handle:CVAR_ROUNDEND_OVERLAY, Handle:CVAR_ROUNDEND_OVERLAY,
Handle:CVAR_ROUNDEND_OVERLAY_ZOMBIE, Handle:CVAR_ROUNDEND_OVERLAY_ZOMBIE,
@ -315,6 +316,8 @@ CvarsCreate()
// =========================== // ===========================
g_hCvarsList[CVAR_SAYHOOKS_QUIET] = CreateConVar("zr_sayhooks_quiet", "1", ""); g_hCvarsList[CVAR_SAYHOOKS_QUIET] = CreateConVar("zr_sayhooks_quiet", "1", "");
g_hCvarsList[CVAR_SAYHOOKS_QUIET_FILTER] = CreateConVar("zr_sayhooks_quiet_filter", "1", "");
// when enabled it filters out failed sayhooks
g_hCvarsList[CVAR_SAYHOOKS_QUIET_FLAGS] = CreateConVar("zr_sayhooks_quiet_flags", "58", ""); g_hCvarsList[CVAR_SAYHOOKS_QUIET_FLAGS] = CreateConVar("zr_sayhooks_quiet_flags", "58", "");
// Flags (default: 2 + 8 + 16 + 32) // Flags (default: 2 + 8 + 16 + 32)
// 0 Allow all. // 0 Allow all.

View File

@ -78,6 +78,9 @@ public Action:SayHooksCmdSay(client, argc)
return Plugin_Continue; return Plugin_Continue;
} }
// Define success as true until otherwise changed.
new bool:success = true;
switch(chatflag) switch(chatflag)
{ {
// Client triggered ZMenu flag. // Client triggered ZMenu flag.
@ -89,7 +92,7 @@ public Action:SayHooksCmdSay(client, argc)
// Client triggered ZAdmin flag. // Client triggered ZAdmin flag.
case SAYHOOKS_KEYWORD_FLAG_ZADMIN: case SAYHOOKS_KEYWORD_FLAG_ZADMIN:
{ {
ZRAdminMenu(client); success = ZRAdminMenu(client);
} }
// Client triggered ZClass flag. // Client triggered ZClass flag.
case SAYHOOKS_KEYWORD_FLAG_ZCLASS: case SAYHOOKS_KEYWORD_FLAG_ZCLASS:
@ -101,24 +104,24 @@ public Action:SayHooksCmdSay(client, argc)
case SAYHOOKS_KEYWORD_FLAG_ZSPAWN: case SAYHOOKS_KEYWORD_FLAG_ZSPAWN:
{ {
// Spawns a late-joining client into the game. // Spawns a late-joining client into the game.
ZSpawnClient(client); success = ZSpawnClient(client);
} }
// Client triggered ZTele flag. // Client triggered ZTele flag.
case SAYHOOKS_KEYWORD_FLAG_ZTELE: case SAYHOOKS_KEYWORD_FLAG_ZTELE:
{ {
ZTeleClient(client); success = ZTeleClient(client);
} }
// Client triggered ZHP flag. // Client triggered ZHP flag.
case SAYHOOKS_KEYWORD_FLAG_ZHP: case SAYHOOKS_KEYWORD_FLAG_ZHP:
{ {
// Toggle ZHP. // Toggle ZHP.
ZHPToggle(client); success = ZHPToggle(client);
} }
// Client triggered ZMarket flag. // Client triggered ZMarket flag.
case SAYHOOKS_KEYWORD_FLAG_ZMARKET: case SAYHOOKS_KEYWORD_FLAG_ZMARKET:
{ {
// Send market menu. // Send market menu.
ZMarketMenu(client); success = ZMarketMenu(client);
} }
} }
@ -129,6 +132,13 @@ public Action:SayHooksCmdSay(client, argc)
return Plugin_Continue; return Plugin_Continue;
} }
// If filter is enabled, and the command failed to be executed, then stop.
new bool:filter = GetConVarBool(g_hCvarsList[CVAR_SAYHOOKS_QUIET_FILTER]);
if (filter && !success)
{
return Plugin_Handled;
}
// If word is flagged to be quieted, then stop. // If word is flagged to be quieted, then stop.
new quietflags = GetConVarInt(g_hCvarsList[CVAR_SAYHOOKS_QUIET_FLAGS]); new quietflags = GetConVarInt(g_hCvarsList[CVAR_SAYHOOKS_QUIET_FLAGS]);
if (quietflags & chatflag) if (quietflags & chatflag)

View File

@ -125,7 +125,7 @@ ZHPOnHealthInfectGain(client)
* *
* @param client The client index. * @param client The client index.
*/ */
ZHPToggle(client) bool:ZHPToggle(client)
{ {
// If ZHP is disabled, then stop. // If ZHP is disabled, then stop.
new bool:zhp = GetConVarBool(g_hCvarsList[CVAR_ZHP]); new bool:zhp = GetConVarBool(g_hCvarsList[CVAR_ZHP]);
@ -135,7 +135,7 @@ ZHPToggle(client)
ZR_PrintToChat(client, "Feature is disabled"); ZR_PrintToChat(client, "Feature is disabled");
// Stop. // Stop.
return; return false;
} }
// If ZHP is enabled, then tell client it's being disabled. // If ZHP is enabled, then tell client it's being disabled.
@ -154,6 +154,8 @@ ZHPToggle(client)
// Toggle ZHP flag. // Toggle ZHP flag.
pZHP[client] = !pZHP[client]; pZHP[client] = !pZHP[client];
return true;
} }
/** /**

View File

@ -147,6 +147,13 @@ bool:ZTeleClient(client)
return false; return false;
} }
// If teleport is already in progress, then stop.
if (tZTele[client] != INVALID_HANDLE)
{
ZR_PrintToChat(client, "ZTele in progress");
return false;
}
// Get current location. // Get current location.
GetClientAbsOrigin(client, g_vecZTeleOrigin[client]); GetClientAbsOrigin(client, g_vecZTeleOrigin[client]);