About changing player's name

chiba222

New member
Messages
20
Points
0
Hi everyone,

I am facing a big problem about the Hercules cannot support some Chinese words in player's name.

Therefore, I have to make a script for player change their name.

How to identify is the player's name used?

Thank you

 
Last edited by a moderator:
check:

mes "input new name";
input(@name$);
query_sql("SELECT name FROM `char` WHERE `name` = '" + @name$, @newName$);

if(@newName$ != ""){
mes "this name is already used";
close;
}

for(.i = 0; .i < getarraysize(.badSymbol$); .i++){
if(compare(@name$, .badSymbol$[.i])){
mes "you can't use name with this symbol";
close;
}
}

// changename
close;

OnInit:
setarray .badSymbol$[0], "#", "@"; //add your's
end;

bad english
default_smile.png


 
Thank you Kubix, but the script doesn't work.

After I input the name, the map-server showed this

N8TVyHQ.png


 
Last edited by a moderator:
Change this:

query_sql("SELECT name FROM `char` WHERE `name` = '" + @name$, @newName$);
 


to this:

Code:
query_sql("SELECT name FROM `char` WHERE `name` = " + @name$, @newName$);
 
 
prt_fild08,176,346,3    script    name    50,{
mes "input new name";
input(@name$);
query_sql("SELECT name FROM `char` WHERE `name` = " + @name$, @newName$);
 
if(@newName$ != ""){
   mes "this name is already used";
   close;
}
 
for(.i = 0; .i < getarraysize(.badSymbol$); .i++){
   if(compare(@name$, .badSymbol$[.i])){
      mes "you can't use name with this symbol";
      close;
   }
}
 
// changename
close;
 
OnInit:
setarray .badSymbol$[0], "#", "@"; //add your's
end;
}
 
Last edited by a moderator:
prt_fild08,176,346,3    script    name    50,{
mes "input new name";
input(@name$);
query_sql("SELECT name FROM `char` WHERE `name` = '" + @name$ + "'", @newName$);

if(@newName$ != ""){
mes "this name is already used";
close;
}

for(.i = 0; .i < getarraysize(.badSymbol$); .i++){
if(compare(@name$, .badSymbol$[.i])){
mes "you can't use name with this symbol";
close;
}
}

// changename
close;

OnInit:
setarray .badSymbol$[0], "#", "@"; //add your's
end;
}
idk, try this. I don't have a server for test now :<

 
There is no error in map-server, but the name doesn't change.

I have logout and login again and check the SQL server, the name is still the old one.

 
i dont give you a code that change the name
default_biggrin.png


for change name replace this:

// changename

to this:

Code:
query_sql("UPDATE `char` SET `name` = '" + @name + "' WHERE `char_id` = '" + getcharid(0) + "'");
 
Thank you Kubix!

I have changed a little bit to make it works.

Full script is here.

 
prt_fild08,176,346,3    script    ASDSA    50,{
mes "input new name";
input(.@name$);
query_sql("SELECT name FROM `char` WHERE `name` = '" + .@name$ + "'", @newName$);
 
if(@newName$ != ""){
    mes "this name is already used";
    close;
}
 
for(.i = 0; .i < getarraysize(.badSymbol$); .i++){
    if(compare(.@name$, .badSymbol$[.i])){
        mes "you can't use name with this symbol";
        close;
    }
}
 
query_sql("update `char` set `name` = '"+.@name$+"' WHERE `char_id` ="+getcharid(0));
atcommand "@kick "+strcharinfo(0);
close;
 
OnInit:
setarray .badSymbol$[0], "#", "@"; //add your's
end;
}



After I changed my name, the npc cannot change my name anyone

Is keep showing "this name is already used"

Solved, if the message is keep showing, just logout a few times and the name can be changed again.

But I don't know why.

 
Last edited by a moderator:
Back
Top