I think this will work, I haven't tested it or tried to compile it:
Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <nvault>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "stupok69"
#define VAULT_NAME "alka_name_steamid"
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /namereg", "register_name", _, "registers your name with your STEAMID")
}
public client_putinserver(id)
{
set_task(1.0, "check_name", id)
}
public client_infochanged(id)
{
set_task(1.0, "check_name", id)
}
public check_name(id)
{
new name[32], steamid[32]
get_user_name(id, name, 31)
get_user_authid(id, steamid, 31)
new vault = nvault_open(VAULT_NAME)
new timestamp
if(!nvault_lookup(vault, name, steamid, 31, timestamp))
{
new read_steamid[32]
if(nvault_get(vault, name, read_steamid, 31))
{
if(!equal(read_steamid, steamid))
{
server_cmd("amx_kick #%i ^"You must change your name to enter this server!^"", get_user_userid(id))
}
}
else
{
client_print(id, print_chat, "Say '/namereg name' to register your name with your STEAMID!")
set_task(30.0, "check_name", id)
}
}
nvault_close(VAULT_NAME)
}
public register_name(id)
{
new name[32], steamid[32]
get_user_name(id, name, 31)
get_user_authid(id, steamid, 31)
new vault = nvault_open(VAULT_NAME)
new timestamp
if(!nvault_lookup(vault, name, steamid, 31, timestamp)
{
if(!nvault_get(vault, name))
{
nvault_set(vault, steamid, name)
client_print(id, print_chat, "Your name has been registered with you STEAMID successfully.")
}
else
{
client_print(id, print_chat, "You may not register with this name, it has already been used.")
}
}
else
{
client_print(id, print_chat, "You have already registered your name.")
}
nvault_close(VAULT_NAME)
}