/*
* About Me Profile Command (olds.ro workshop card LIB-2082)
*
* Players write a short line about themselves; others look it up by name.
* say /aboutme <text> saves your line (olds_about_len characters at most)
* say /about [name|#userid] shows that player's line (yours without a name)
* amx_aboutclear <name|#userid> deletes a player's line (ADMIN_BAN)
* amx_about_list every connected player's line (ADMIN_KICK)
*
* Cvars
* olds_about_len 64 longest line; longer text is cut, not refused
* olds_about_cd 30 seconds between two /aboutme of one player
* olds_about_filter 1 refuse lines holding a word of
* addons/amxmodx/configs/olds_about_bad.ini (one word
* or phrase per line, any case, found inside words too)
*
* Lines are kept in the nVault "olds_about" by SteamID (the name for bots and
* LAN ids), so they stay across reconnects and maps. Colour codes (^1-^4),
* other control characters and % are removed before saving.
*
* Copyright (C) 2026 daemon (olds.ro)
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include <amxmodx>
#include <amxmisc>
#include <nvault>
#define PLUGIN "About Me Profile Command"
#define VERSION "1.0.0"
#define AUTHOR "olds.ro"
const MAX_LEN = 128
const MAX_BAD = 128
const BAD_LEN = 32
new g_len, g_cd, g_filter
new g_vault = INVALID_HANDLE
new g_bad[MAX_BAD][BAD_LEN], g_badCount
new Float:g_nextSet[MAX_PLAYERS + 1]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_dictionary("olds_about.txt")
bind_pcvar_num(create_cvar("olds_about_len", "64", FCVAR_NONE,
"Longest profile line.", true, 8.0, true, float(MAX_LEN - 1)), g_len)
bind_pcvar_num(create_cvar("olds_about_cd", "30", FCVAR_NONE,
"Seconds between two /aboutme of one player.", true, 0.0, true, 3600.0), g_cd)
bind_pcvar_num(create_cvar("olds_about_filter", "1", FCVAR_NONE,
"1 = refuse lines holding a word of olds_about_bad.ini.", true, 0.0, true, 1.0), g_filter)
AutoExecConfig(true, "olds_about")
register_clcmd("say", "on_say")
register_clcmd("say_team", "on_say")
register_concmd("amx_aboutclear", "cmd_clear", ADMIN_BAN, "<name|#userid> - deletes a player's profile line")
register_concmd("amx_about_list", "cmd_list", ADMIN_KICK, "- every connected player's profile line")
g_vault = nvault_open("olds_about")
if (g_vault == INVALID_HANDLE)
log_amx("cannot open the nVault olds_about: profile lines cannot be saved")
}
public plugin_cfg()
{
load_bad_words()
}
public plugin_end()
{
if (g_vault != INVALID_HANDLE)
nvault_close(g_vault)
}
public client_disconnected(id)
{
g_nextSet[id] = 0.0
}
load_bad_words()
{
new path[160]
get_configsdir(path, charsmax(path))
add(path, charsmax(path), "/olds_about_bad.ini")
g_badCount = 0
new file = fopen(path, "rt")
if (!file)
return
new line[64]
while (fgets(file, line, charsmax(line)) && g_badCount < MAX_BAD)
{
trim(line)
if (!line[0] || line[0] == ';' || line[0] == '#')
continue
strtolower(line)
copy(g_bad[g_badCount++], BAD_LEN - 1, line)
}
fclose(file)
}
/* ---------- text ---------- */
// Removes colour codes and other control characters and %; folds spaces; cuts to olds_about_len.
clean(const text[], out[], len)
{
new o, bool:space = true
new limit = min(len, g_len)
for (new i = 0; text[i] && o < limit; i++)
{
new c = text[i]
if (c == '%' || (c >= 0 && c < 32))
continue
if (c == ' ')
{
if (space)
continue
space = true
}
else
space = false
out[o++] = c
}
out[o] = EOS
trim(out)
}
bool:has_bad_word(const text[])
{
if (!g_filter || !g_badCount)
return false
new low[MAX_LEN]
copy(low, charsmax(low), text)
strtolower(low)
for (new i = 0; i < g_badCount; i++)
if (contain(low, g_bad[i]) != -1)
return true
return false
}
player_key(id, key[], len)
{
get_user_authid(id, key, len)
if (is_user_bot(id) || !key[0] || contain(key, "LAN") != -1 || contain(key, "PENDING") != -1 || equal(key, "BOT"))
{
new name[MAX_NAME_LENGTH]
get_user_name(id, name, charsmax(name))
formatex(key, len, "name:%s", name)
}
}
bool:read_line(id, line[], len)
{
line[0] = EOS
if (g_vault == INVALID_HANDLE)
return false
new key[64]
player_key(id, key, charsmax(key))
return nvault_get(g_vault, key, line, len) > 0 && line[0] != EOS
}
/* ---------- say ---------- */
public on_say(id)
{
new text[192]
read_args(text, charsmax(text))
remove_quotes(text)
trim(text)
if (equali(text, "/aboutme", 8) && (!text[8] || text[8] == ' '))
{
set_line(id, text[8])
return PLUGIN_HANDLED
}
if (equali(text, "/about", 6) && (!text[6] || text[6] == ' '))
{
new who[64]
copy(who, charsmax(who), text[6])
trim(who)
show_line(id, who)
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
set_line(id, const raw[])
{
new line[MAX_LEN]
clean(raw, line, charsmax(line))
if (!line[0])
{
client_print_color(id, print_team_default, "^4[About]^1 %L", id, "ABOUT_USAGE", g_len)
return
}
new Float:now = get_gametime()
if (now < g_nextSet[id])
{
client_print_color(id, print_team_default, "^4[About]^1 %L", id, "ABOUT_WAIT", floatround(g_nextSet[id] - now, floatround_ceil))
return
}
if (has_bad_word(line))
{
client_print_color(id, print_team_default, "^4[About]^1 %L", id, "ABOUT_BAD")
log_amx("profile line refused (blocked word) for %n", id)
return
}
if (g_vault == INVALID_HANDLE)
{
client_print_color(id, print_team_default, "^4[About]^1 %L", id, "ABOUT_NO_VAULT")
return
}
new key[64]
player_key(id, key, charsmax(key))
nvault_set(g_vault, key, line)
g_nextSet[id] = now + float(g_cd)
client_print_color(id, print_team_default, "^4[About]^1 %L", id, "ABOUT_SAVED", line)
}
// The player the text names: #userid, an exact name, else a unique name part.
find_target(const who[])
{
if (who[0] == '#' && is_str_num(who[1]))
return find_player_ex(FindPlayer_MatchUserId, str_to_num(who[1]))
new id = find_player_ex(FindPlayer_MatchName | FindPlayer_CaseInsensitive, who)
if (id)
return id
new count, found
for (new p = 1; p <= MaxClients; p++)
{
if (!is_user_connected(p))
continue
new name[MAX_NAME_LENGTH]
get_user_name(p, name, charsmax(name))
if (containi(name, who) != -1)
{
found = p
count++
}
}
if (count == 1)
return found
return -count
}
show_line(id, const who[])
{
new target = id
if (who[0])
{
target = find_target(who)
if (target < -1)
{
client_print_color(id, print_team_default, "^4[About]^1 %L", id, "ABOUT_MANY", who)
return
}
if (target <= 0)
{
client_print_color(id, print_team_default, "^4[About]^1 %L", id, "ABOUT_NOBODY", who)
return
}
}
new name[MAX_NAME_LENGTH], line[MAX_LEN]
get_user_name(target, name, charsmax(name))
if (!read_line(target, line, charsmax(line)))
{
client_print_color(id, target, "^4[About]^1 %L", id, "ABOUT_NONE", name)
return
}
client_print_color(id, target, "^4[About] ^3%s^1: %s", name, line)
if (!is_user_bot(id))
{
set_hudmessage(120, 200, 255, -1.0, 0.25, 0, 0.0, 5.0, 0.2, 0.5, -1)
show_hudmessage(id, "%s: %s", name, line)
}
}
/* ---------- admins ---------- */
public cmd_clear(id, level, cid)
{
if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new who[64]
read_argv(1, who, charsmax(who))
new target = find_target(who)
if (target <= 0)
{
console_print(id, "[About] no single player matches ^"%s^"", who)
return PLUGIN_HANDLED
}
new key[64], name[MAX_NAME_LENGTH]
player_key(target, key, charsmax(key))
get_user_name(target, name, charsmax(name))
if (g_vault != INVALID_HANDLE)
nvault_remove(g_vault, key)
console_print(id, "[About] %s's profile line deleted", name)
log_amx("%n deleted the profile line of %s <%s>", id, name, key)
return PLUGIN_HANDLED
}
public cmd_list(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
console_print(id, "[About] length %d, cooldown %d s, filter %d (%d word(s))", g_len, g_cd, g_filter, g_badCount)
new name[MAX_NAME_LENGTH], line[MAX_LEN], key[64]
for (new p = 1; p <= MaxClients; p++)
{
if (!is_user_connected(p))
continue
get_user_name(p, name, charsmax(name))
player_key(p, key, charsmax(key))
if (read_line(p, line, charsmax(line)))
console_print(id, "[About] %s (%s): %s [%d chars]", name, key, line, strlen(line))
else
console_print(id, "[About] %s (%s): no line", name, key)
}
return PLUGIN_HANDLED
}