#include <amxmodx>
#include <amxmisc>
#include <fun>

new PLUGIN[]="Server Name Secure"
new AUTHOR[]="JohnJ"
new VERSION[]="1.00"

#define servuserid 1

new bool:can=false

public plugin_init()
{
     register_plugin(PLUGIN, VERSION, AUTHOR)

     register_concmd("sname", "changesname", ADMIN_ADMIN, "<nick>")
}

public changesname(id, level, cid)
{
     if (!cmd_access(id, level, cid, 2))
        return PLUGIN_HANDLED

     new Arg1[24],ip[16]

     read_argv(1, Arg1, 23)
     get_user_ip(id,ip,15)
     if (equali(ip,"loopback"))
     {
      can=true
//	client_cmd(id,"name %s", Arg1)
	set_user_info(id, "name", Arg1)
     }
      else
      {
       console_print(servuserid, "Attempt to change nik adminu with IP,",ip)
      }
}

public client_infochanged(id)
{
      new ip[16]
      get_user_ip(id,ip,15)
      if (equali(ip,"loopback"))
      {
       if (!can)
       {
	  new newname[32], oldname[32]
	  get_user_info(id, "name", newname,31)
	  get_user_name(id,oldname,31)
	  if (!equal(oldname,newname))
        {
         console_print(id, "***It is forbidden to change nik***")
	   set_user_info(id,"name",oldname)
  	  }
       }
       can=false
      }
}
