- updated basecommands and basefuncommands to use ProcessTargetString() and ShowActivity2()

- moved a bunch of translation phrases around
- ShowActivity2() no longer prints to console
- fixed a memory corruption bug in the translation parser

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401630
This commit is contained in:
David Anderson
2007-10-21 23:50:37 +00:00
parent 04b2845b0d
commit 53156446d4
15 changed files with 362 additions and 137 deletions
+1 -1
View File
@@ -20,7 +20,7 @@
* 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
* code of this program (as well as its derivative 1works) 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
+2 -2
View File
@@ -77,7 +77,7 @@ public MenuHandler_Kick(Handle:menu, MenuAction:action, param1, param2)
{
decl String:name[MAX_NAME_LENGTH];
GetClientName(target, name, sizeof(name));
ShowActivity2(param1, "[SM] ", "%t", "Kicked target", "_S", name);
ShowActivity2(param1, "[SM] ", "%t", "Kicked target", "_s", name);
PerformKick(param1, target, "");
}
@@ -129,7 +129,7 @@ public Action:Command_Kick(client, args)
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Kicked target", "_S", target_name);
ShowActivity2(client, "[SM] ", "%t", "Kicked target", "_s", target_name);
}
new kick_self = 0;
+33 -13
View File
@@ -58,6 +58,7 @@ new g_SlapDamage[MAXPLAYERS+1];
public OnPluginStart()
{
LoadTranslations("common.phrases");
LoadTranslations("basefuncommands.phrases");
RegAdminCmd("sm_burn", Command_Burn, ADMFLAG_SLAY, "sm_burn <#userid|name> [time]");
RegAdminCmd("sm_slap", Command_Slap, ADMFLAG_SLAY, "sm_slap <#userid|name> [damage]");
@@ -127,12 +128,6 @@ public Action:Command_Play(client, args)
decl String:Arg[65];
new len = BreakString(Arguments, Arg, sizeof(Arg));
new target = FindTarget(client, Arg);
if (target == -1)
{
return Plugin_Handled;
}
/* Make sure it does not go out of bound by doing "sm_play user "*/
if (len == -1)
{
@@ -151,13 +146,38 @@ public Action:Command_Play(client, args)
Arguments[FileLen - 1] = '\0';
}
}
GetClientName(target, Arg, sizeof(Arg));
ShowActivity(client, "%t", "Played Sound", Arg);
LogAction(client, target, "\"%L\" played sound on \"%L\" (file \"%s\")", client, target, Arguments[len]);
ClientCommand(target, "playgamesound \"%s\"", Arguments[len]);
decl String:target_name[MAX_TARGET_LENGTH];
decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
if ((target_count = ProcessTargetString(
Arg,
client,
target_list,
MAXPLAYERS,
COMMAND_FILTER_NO_BOTS,
target_name,
sizeof(target_name),
tn_is_ml)) <= 0)
{
ReplyToTargetError(client, target_count);
return Plugin_Handled;
}
for (new i = 0; i < target_count; i++)
{
ClientCommand(target_list[i], "playgamesound \"%s\"", Arguments[len]);
LogAction(client, target_list[i], "\"%L\" played sound on \"%L\" (file \"%s\")", client, target_list[i], Arguments[len]);
}
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Played sound to target", target_name);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Played sound to target", "_s", target_name);
}
return Plugin_Handled;
}
+34 -19
View File
@@ -1,16 +1,5 @@
PerformBurn(client, target, Float:seconds)
{
new String:name[32];
GetClientName(target, name, sizeof(name));
if (!IsPlayerAlive(target))
{
ReplyToCommand(client, "[SM] %t", "Cannot be performed on dead", name);
return;
}
ShowActivity(client, "%t", "Ignited player", name);
LogAction(client, target, "\"%L\" ignited \"%L\" (seconds \"%f\")", client, target, seconds);
IgniteEntity(target, seconds);
}
@@ -77,7 +66,10 @@ public MenuHandler_Burn(Handle:menu, MenuAction:action, param1, param2)
}
else
{
new String:name[32];
GetClientName(target, name, sizeof(name));
PerformBurn(param1, target, 20.0);
ShowActivity2(param1, "[SM] ", "%t", "Set target on fire", "_s", name);
}
/* Re-draw the menu if they're still valid */
@@ -99,12 +91,6 @@ public Action:Command_Burn(client, args)
decl String:arg[65];
GetCmdArg(1, arg, sizeof(arg));
new target = FindTarget(client, arg);
if (target == -1)
{
return Plugin_Handled;
}
new Float:seconds = 20.0;
if (args > 1)
@@ -118,7 +104,36 @@ public Action:Command_Burn(client, args)
}
}
PerformBurn(client, target, seconds);
decl String:target_name[MAX_TARGET_LENGTH];
decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
if ((target_count = ProcessTargetString(
arg,
client,
target_list,
MAXPLAYERS,
COMMAND_FILTER_NO_BOTS,
target_name,
sizeof(target_name),
tn_is_ml)) <= 0)
{
ReplyToTargetError(client, target_count);
return Plugin_Handled;
}
for (new i = 0; i < target_count; i++)
{
PerformBurn(client, target_list[i], seconds);
}
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Set target on fire", target_name);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Set target on fire", "_s", target_name);
}
return Plugin_Handled;
}
}
+39 -24
View File
@@ -1,16 +1,5 @@
PerformSlap(client, target, damage)
{
new String:name[32];
GetClientName(target, name, sizeof(name));
if (!IsPlayerAlive(target))
{
ReplyToCommand(client, "[SM] %t", "Cannot be performed on dead", name);
return;
}
ShowActivity(client, "%t", "Slapped player", name);
LogAction(client, target, "\"%L\" slapped \"%L\" (damage \"%d\")", client, target, damage);
SlapPlayer(target, damage, true);
}
@@ -119,16 +108,19 @@ public MenuHandler_Slap(Handle:menu, MenuAction:action, param1, param2)
{
PrintToChat(param1, "[SM] %t", "Unable to target");
}
else if (!IsPlayerAlive(target))
{
ReplyToCommand(param1, "[SM] %t", "Player has since died");
}
else
{
decl String:name[32];
GetClientName(target, name, sizeof(name));
PerformSlap(param1, target, g_SlapDamage[param1]);
ShowActivity2(param1, "[SM] ", "%t", "Slapped target", "_s", name);
}
/* Re-draw the menu if they're still valid */
if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
{
DisplaySlapTargetMenu(param1);
}
DisplaySlapTargetMenu(param1);
}
}
@@ -143,12 +135,6 @@ public Action:Command_Slap(client, args)
decl String:arg[65];
GetCmdArg(1, arg, sizeof(arg));
new target = FindTarget(client, arg);
if (target == -1)
{
return Plugin_Handled;
}
new damage = 0;
if (args > 1)
{
@@ -160,8 +146,37 @@ public Action:Command_Slap(client, args)
return Plugin_Handled;
}
}
decl String:target_name[MAX_TARGET_LENGTH];
decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
if ((target_count = ProcessTargetString(
arg,
client,
target_list,
MAXPLAYERS,
COMMAND_FILTER_NO_BOTS,
target_name,
sizeof(target_name),
tn_is_ml)) <= 0)
{
ReplyToTargetError(client, target_count);
return Plugin_Handled;
}
for (new i = 0; i < target_count; i++)
{
PerformSlap(client, target_list[i], damage);
}
PerformSlap(client, target, damage);
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Slapped target", target_name);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Slapped target", "_s", target_name);
}
return Plugin_Handled;
}
}
+34 -19
View File
@@ -1,17 +1,6 @@
PerformSlay(client, target)
{
decl String:name[32];
GetClientName(target, name, sizeof(name));
if (!IsPlayerAlive(target))
{
ReplyToCommand(client, "[SM] %t", "Cannot be performed on dead", name);
return;
}
ShowActivity(client, "%t", "Slayed player", name);
LogAction(client, target, "\"%L\" slayed \"%L\"", client, target);
ForcePlayerSuicide(target);
}
@@ -76,16 +65,19 @@ public MenuHandler_Slay(Handle:menu, MenuAction:action, param1, param2)
{
PrintToChat(param1, "[SM] %t", "Unable to target");
}
else if (!IsPlayerAlive(target))
{
ReplyToCommand(param1, "[SM] %t", "Player has since died");
}
else
{
decl String:name[32];
GetClientName(target, name, sizeof(name));
PerformSlay(param1, target);
ShowActivity2(param1, "[SM] ", "%t", "Slayed target", "_s", name);
}
/* Re-draw the menu if they're still valid */
if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
{
DisplaySlayMenu(param1);
}
DisplaySlayMenu(param1);
}
}
@@ -100,13 +92,36 @@ public Action:Command_Slay(client, args)
decl String:arg[65];
GetCmdArg(1, arg, sizeof(arg));
new target = FindTarget(client, arg);
if (target == -1)
decl String:target_name[MAX_TARGET_LENGTH];
decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
if ((target_count = ProcessTargetString(
arg,
client,
target_list,
MAXPLAYERS,
COMMAND_FILTER_NO_BOTS,
target_name,
sizeof(target_name),
tn_is_ml)) <= 0)
{
ReplyToTargetError(client, target_count);
return Plugin_Handled;
}
PerformSlay(client, target);
for (new i = 0; i < target_count; i++)
{
PerformSlay(client, target_list[i]);
}
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Slayed target", target_name);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Slayed target", "_s", target_name);
}
return Plugin_Handled;
}
+1
View File
@@ -96,6 +96,7 @@ public OnPluginStart()
LoadTranslations("common.phrases");
LoadTranslations("basevotes.phrases");
LoadTranslations("basefunvotes.phrases");
LoadTranslations("basefuncommands.phrases");
RegAdminCmd("sm_votegravity", Command_VoteGravity, ADMFLAG_VOTE, "sm_votegravity <amount> [amount2] ... [amount5]");
RegAdminCmd("sm_voteburn", Command_VoteBurn, ADMFLAG_VOTE|ADMFLAG_SLAY, "sm_voteburn <player>");
+1 -2
View File
@@ -246,8 +246,7 @@ native bool:IsChatTrigger();
* the message based on the current ReplySource.
*
* @param client Client index doing the action, or 0 for server.
* @param tag Tag to display before the message string. For example,
* "[SM] " would show "[SM] <message>".
* @param tag Tag to prepend to the message.
* @param format Formatting rules.
* @param ... Variable number of format parameters.
* @noreturn