/********************************************************
* A sample plugin - Version 0.8                         *
*********************************************************
*                                                       *
* Name: plugin_rindy_forcenamechange                    *
* Author: Rinde (rinde@fiatnox.de)                      *
* Released: 03/01/03                                    *
*                                                       *
*                                                       *
* Commands:                                             *
*                                                       *
* admin_name <target> <name>                            *
*                                                       *
* Changelog:                                            *
*                                                       *
* Version 0.8                                           *
*                                                       *
*  -  Initial release                                   *
*                                                       *
*********************************************************/
 
/* Includes */
#include <plugin>
#include <adminlib>
 
/* Constants */
#define ACCESS_NAME ACCESS_RCON
 
/* Global Variables */
new g_Version[] = "0.8";
 
/* Function Declarations */
forward AdminName(HLCommand,HLData,HLUserName,UserIndex);
 
/* Event Handlers */
public plugin_init() {
    plugin_registerinfo("Rinde's Namechange Plugin","Allows admins to force clients to a nick",g_Version);
    plugin_registercmd("admin_name","AdminName",ACCESS_NAME,"admin_name <target> <name>: Change target's name to <name>.");
    return PLUGIN_CONTINUE;
}
 
/* Command Handlers */
public AdminName(HLCommand,HLData,HLUserName,UserIndex) {
    new Data[MAX_DATA_LENGTH];
    new UserName[MAX_NAME_LENGTH];
    new Target[MAX_NAME_LENGTH];
    new ChangeName[MAX_NAME_LENGTH];
    convert_string(HLData,Data,MAX_DATA_LENGTH);
    convert_string(HLUserName,UserName,MAX_NAME_LENGTH);
    strstripquotes(Data);
    strsep(Data," ",Target,MAX_NAME_LENGTH,ChangeName,MAX_NAME_LENGTH);
    if(ChangeName[0]) {
        if(check_user(Target) == 1) {
            get_username(Target,Target,MAX_NAME_LENGTH);
            snprintf(Data,MAX_NAME_LENGTH + 7,"name ^"%s^"",ChangeName);
            execclient(Target,Data);
 
            snprintf(Data,MAX_DATA_LENGTH,"%s ^"%s^"",Target,ChangeName);
            say_command(UserName,"admin_name",Data);
        } else {
            selfmessage("Unrecognized player:");
            selfmessage(Target);
        }
    } else {
        selfmessage("Unparsable format: Bad argument count.");
    }
    return PLUGIN_HANDLED;
}