Thread: [REQ] !Tagme
View Single Post
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 07-27-2008 , 20:19   Re: [REQ] !Tagme
Reply With Quote #8

This should work with non-OB mods (TF2/DOD:S); I'll add them in later on.

PHP Code:
#pragma semicolon 1

#include <sourcemod>

// Global Definitions
#define PLUGIN_VERSION "1.0.0"

new Handle:cvarTag;
new 
Handle:cvarLoc;

// 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_PLUGINtrue1.0true2.0);

    
RegConsoleCmd("say"Command_Say);
    
RegConsoleCmd("say_team"Command_Say);
}

public 
Action:Command_Say(clientargs)
{
    
decl String:text[192];
    
GetCmdArgString(textsizeof(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(clientnamesizeof(name));
        
GetConVarString(cvarTagtagsizeof(tag));

        switch (
GetConVarInt(cvarLoc))
        {
            case 
1:
            {
                
Format(buffersizeof(buffer), "%s%s"tagname);
            }
            case 
2:
            {
                
Format(buffersizeof(buffer), "%s%s"nametag);
            }
        }

        
ClientCommand(client"name %s"buffer);
        
PrintToChat(client"[SM] You have been tagged!");

        return 
Plugin_Handled;
    }

    return 
Plugin_Continue;

bl4nk is offline