AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED}nameprotection need litle help (https://forums.alliedmods.net/showthread.php?t=51700)

hacik 02-22-2007 17:39

[SOLVED}nameprotection need litle help
 
i have editing one script (to make him work) and i have problems...
plugin this protect the nick to connect and change to protected nick`s
i have made he change name on connect/ but problems are in there when in game change someone to this protected nick it justj not work...

Code:


public onChange(id){
 new name[32], namechange[32], strline = 1, data[32], stxtsize
 get_user_info(id, "name", name, 31)
 get_user_name( id, name, 31 )
 set_hudmessage(200, 100, 0, -1.0, 0.25, 0, 1.0, 5.0, 0.1, 0.2, 2)
  if(file_exists("addons/amxmodx/configs/WatchAdmin.cfg")){
  while((strline=read_file("addons/amxmodx/configs/WatchAdmin.cfg",strline,data,31,stxtsize))!=0){
  if(strline < 100 && strline > -1){
    if(containi( name,data )!=-1 ){
    client_print(0,print_chat,"***WARNING*** '%s' - This is a reserved name")
    client_print(0,print_chat,"To view Reserved Names: /reservednames")
 
 
 formatex(namechange, 31, "Bich", id)
 set_user_info(id, "name", namechange)
    client_print(0,print_chat, "say /reservednames")
 
    }
  }
  }
 }
 return PLUGIN_CONTINUE
}

where is problem????? my mistake

[ --<-@ ] Black Rose 02-23-2007 01:26

Re: nameprotection need litle help
 
Add
Code:
new oldname[32];
Change
Code:
get_user_name( id, name, 31 )
to
Code:
get_user_name(id, oldname, 31);
And check if it's the same as the new
Code:
if ( equal(oldname, name) )     return PLUGIN_CONTINUE;

hacik 02-23-2007 03:08

Re: nameprotection need litle help
 
1 Attachment(s)
1)then compilate i have this
Quote:

/home/groups/amxmodx/tmp3/phpyiRnC9.sma(84) : warning 217: loose indentation
/home/groups/amxmodx/tmp3/phpyiRnC9.sma(92) : warning 217: loose indentation
/home/groups/amxmodx/tmp3/phpyiRnC9.sma(94) : warning 217: loose indentation
/home/groups/amxmodx/tmp3/phpyiRnC9.sma(100) : warning 217: loose indentation
/home/groups/amxmodx/tmp3/phpyiRnC9.sma(103) : warning 209: function "onChange" should return a value
2)added like this

[quote]public onChange(id){</p><p> new name[32], namechange[32], oldname[32], strline = 1, data[32], stxtsize</p><p> get_user_info(id, "name", name, 31)</p><p> get_user_name(id, oldname, 31)</p><p> set_hudmessage(200, 100, 0, -1.0, 0.25, 0, 1.0, 5.0, 0.1, 0.2, 2)</p><p> if(file_exists("addons/amxmodx/configs/WatchAdmin.cfg")){</p><p> while((strline=read_file("addons/amxmodx/configs/WatchAdmin.cfg",strline,data,31,stxtsize))!=0){</p><p> if(strline < 100 && strline > -1){</p><p> if(containi( name,data )!=-1 ){</p><p> client_print(0,print_chat,"***WARNING*** '%s' - This is a reserved name")</p><p> client_print(0,print_chat,"To view Reserved Names: /reservednames")</p><p>&nbsp;</p><p>&nbsp;</p><p> formatex(namechange, 31, "Bich", id)</p><p> set_user_info(id, "name", namechange)</p><p> client_print(0,print_chat, "say /reservednames")</p><p>&nbsp;</p><p> }</p><p> }</p><p> }</p><p> }</p><p> if ( equal(oldname, name) )</p><p> return PLUGIN_CONTINUE</p><p>}[/quote]

3)not helepd.... i can change nick to reserved(with out admin privilegies)
4)here is a full source

SAMURAI16 02-23-2007 14:48

Re: nameprotection need litle help
 
just fixed the code
Code:

#include <amxmodx>


public plugin_init()
{
    register_plugin("WatchAdminName","0.6","BillyTheKid")
    register_clcmd("say /reservednames","reservenames_motd")
}

public client_authorized(id)
{
    if (get_user_flags(id)&ADMIN_IMMUNITY)
    return PLUGIN_CONTINUE
   
    else
    {
        onConnect(id)
    }
   
    return PLUGIN_CONTINUE;


}

public client_infochanged(id)
{
    if (get_user_flags(id)&ADMIN_IMMUNITY)
    return PLUGIN_CONTINUE
   
    else
    {
        onChange(id)
    }
   
    return PLUGIN_CONTINUE;

}

public onConnect(id){
    new UserName[32], strline = 1, data[32], stxtsize
    get_user_name( id, UserName, 31 )
    set_hudmessage(200, 100, 0, -1.0, 0.25, 0, 1.0, 5.0, 0.1, 0.2, 2)
      if(file_exists("addons/amxmodx/configs/WatchAdmin.cfg")){
        while((strline=read_file("addons/amxmodx/configs/WatchAdmin.cfg",strline,data,31,stxtsize))!=0){
            if(strline < 100 && strline > -1){
                if(containi( UserName,data )!=-1 ){
                    client_print(0,print_chat,"***WARNING*** '%s' - This is a reserved name")
                    client_print(0,print_chat,"To view Reserved Names: /reservednames")
                    {
    new namechange[32]
    formatex(namechange, 31, "Bich", id)
    set_user_info(id, "name", namechange)
}
                    client_print(0,print_chat, "say /reservednames")
                }
            }
        }
    }
    return PLUGIN_CONTINUE
}

public onChange(id)
{
    new name[32], namechange[32], oldname[32], strline = 1, data[32], stxtsize
    get_user_info(id, "name", name, 31)
    get_user_name(id, oldname, 31)
    set_hudmessage(200, 100, 0, -1.0, 0.25, 0, 1.0, 5.0, 0.1, 0.2, 2)
    if(file_exists("addons/amxmodx/configs/WatchAdmin.cfg"))
    {
        while((strline=read_file("addons/amxmodx/configs/WatchAdmin.cfg",strline,data,31,stxtsize))!=0)
        {
            if(strline < 100 && strline > -1){
                if(containi( name,data )!=-1 )
                {
                    client_print(0,print_chat,"***WARNING*** '%s' - This is a reserved name")
                    client_print(0,print_chat,"To view Reserved Names: /reservednames")
 
 
                    formatex(namechange, 31, "Bich", id)
                    set_user_info(id, "name", namechange)
                    client_print(0,print_chat, "say /reservednames")
                }
            }
        }
    }
 
 
 
    if ( equal(oldname, name) )
    return PLUGIN_CONTINUE;

    return PLUGIN_CONTINUE;
}


public reservenames_motd(id)
{
    new len = 1300, buffer[1301], n = 0, strline = 1, data[32], stxtsize
    n += copy( buffer[n],len-n,"<html><head><style type=^"text/css^">pre{color:#B87B0A;}body{background:#000000;margin-left:8px;}.style1 {font-size: x-small}.style2 {color: #FF0000}</style></head><body><pre>")
    n += copy( buffer[n],len-n,"<h1 align=center>Reserved Admin Names:</h1>")
    n += copy( buffer[n],len-n,"<h2 align=center class=style1 style2>The following names are reserved and cannot be used!</h2>")
   

    while((strline=read_file("addons/amxmodx/configs/WatchAdmin.cfg",strline,data,31,stxtsize))!=0)
    {
        n += copy( buffer[n],len-n,data)
        n += copy( buffer[n],len-n,"<br>")
    }

    n += copy( buffer[n],len-n,"</pre></body></html>")
    show_motd(id,buffer,"Reserved Admin Names")
   
    return PLUGIN_CONTINUE;
}


[ --<-@ ] Black Rose 02-23-2007 16:21

Re: nameprotection need litle help
 
Code:
    if ( equal(oldname, name) )     return PLUGIN_CONTINUE;
Before the check of file existance and set_hudmessage.


All times are GMT -4. The time now is 00:43.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.