This should work for TF2, DoD:S and all non-OB games. It's a slight modification of bl4nk's code.
Just a side note, my version of the plugin requires the 1.1.0 snapshots.
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
// Global Definitions
#define PLUGIN_VERSION "1.0.0"
new Handle:cvarTag;
new Handle:cvarLoc;
new bool:CanName;
// Functions
public Plugin:myinfo =
{
name = "TagMe",
author = "bl4nk",
description = "Adds a tag to the beginning of a player's name when they say '!tagme'",
version = PLUGIN_VERSION,
url = "http://forums.alliedmods.net"
};
public OnPluginStart()
{
CreateConVar("sm_tagme_version", PLUGIN_VERSION, "TagMe Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
cvarTag = CreateConVar("sm_tagme_tag", "[TAG] ", "The tag that will be added to the player's name", FCVAR_PLUGIN);
cvarLoc = CreateConVar("sm_tagme_loc", "1", "Where in the name to place the tag (1 = Beginning, 2 = End)", FCVAR_PLUGIN, true, 1.0, true, 2.0);
RegConsoleCmd("say", Command_Say);
RegConsoleCmd("say_team", Command_Say);
new String:gamename[31];
GetGameFolderName(gamename, sizeof(gamename));
CanName = !(StrEqual(gamename,"tf",false) || StrEqual(gamename,"dod",false));
}
public Action:Command_Say(client, args)
{
decl String:text[192];
GetCmdArgString(text, sizeof(text));
new startidx = 0;
if (text[0] == '"')
{
startidx = 1;
new len = strlen(text);
if (text[len-1] == '"')
{
text[len-1] = '\0';
}
}
if (strcmp(text[startidx], "!tagme") == 0)
{
decl String:name[32], String:tag[16], String:buffer[48];
GetClientName(client, name, sizeof(name));
GetConVarString(cvarTag, tag, sizeof(tag));
switch (GetConVarInt(cvarLoc))
{
case 1:
{
Format(buffer, sizeof(buffer), "%s%s", tag, name);
}
case 2:
{
Format(buffer, sizeof(buffer), "%s%s", name, tag);
}
}
if(CanName)
{
ClientCommand(client, "name \"%s\"", buffer);
}
else
{
SetClientInfo(client, "name", buffer);
}
PrintToChat(client, "[SM] You have been tagged!");
return Plugin_Handled;
}
return Plugin_Continue;
}