/*
This plugin allows players to change their name without having to access the console.
This is especially useful in DoD and TFC, because in these games Valve disabled the name field in the multiplayer options with the hint that the Friends name should be altered instead, but this doesn't have an effect.
CVAR
amx_name_usage - Display usage info? 0 = no, 1 = yes
Credits:
Original plugin: KyleD
Translations: xPaw, Xalus, MmikiM, Ciio, xD_1991, papyrus_kn, Mandiii
Help & suggestions to get this plugin approved: ConnorMcLeod, fysiks
Version history:
v1.0 (KyleD)
- Original release
v1.1 (pizzahut)
- Bug fix: Global chat isn't blocked anymore.
- Change: A slash in front isn't necessary anymore, this is especially helpful for players who don't have an English keyboard layout.
v1.2
- Change: Made name change chat visible, so other players can see how it's done.
v1.3
- Players get a message when spawning, if the name is blank they get a name prompt.
v1.4
- Added multi-language support.
v1.5
- Changed trigger "name" to ".name".
v1.6
- Allowing any single character prefix as suggested by fysiks.
v1.6.4
- Bug fixes for single character prefix.
v1.7
Code taken from "multilingual.sma" for the following changes:
- Usage info is displayed 10s after joining instead of when respawning
and it's displayed only one time instead of two times.
- Added cvar to turn on / off usage info.
Other changes:
- Code optimisation
v1.7.1
- Moved the remove_task function as suggested.
*/
#include <amxmodx>
new g_cvar_usage
public plugin_init()
{
register_plugin("ChangeName", "1.7.1", "pizzahut")
register_concmd("say", "handle_say")
register_dictionary("name.txt")
g_cvar_usage = register_cvar("amx_name_usage", "1") // Display usage info? 0 = no, 1 = yes
}
public handle_say(id)
{
static message[128]
read_args(message, 127)
remove_quotes(message)
// The first character should be '.' or '/'. However because of Half-Life's fixed US keyboard
// layout, any special character is accepted to make it easier for foreign new players.
if( isalnum(message[0]) || (containi(message,"name")!=1) )
return PLUGIN_CONTINUE
switch(message[5])
{
// Syntax 1: /name without a parameter
case 0: client_cmd(id, "messagemode name")
// Syntax 2: /name <name>
case ' ': client_cmd(id, "name ^"%s^"", message[6])
}
return PLUGIN_CONTINUE
}
public client_putinserver(id)
{
if (get_pcvar_num(g_cvar_usage) && !is_user_bot(id))
{
// I decided to put the remove_task function into the "if" branch.
// This means that a previous task may be executed on bots,
// but there is less overhead if the cvar is 0.
remove_task(id)
set_task(10.0, "dispInfo", id)
}
}
public dispInfo(id)
{
client_print(id, print_chat, "[AMXX] %L", id, "usage")
}