Jump to content
  • 0
Sign in to follow this  
chiba222

About changing player's name

Question

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

Edited by chiba222

Share this post


Link to post
Share on other sites

10 answers to this question

Recommended Posts

  • 0
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 :<

Share this post


Link to post
Share on other sites
  • 0

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 :)

Share this post


Link to post
Share on other sites
  • 0

Change this:

 

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

 

 

to this:

 

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

Share this post


Link to post
Share on other sites
  • 0
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;
}


 

Edited by chiba222

Share this post


Link to post
Share on other sites
  • 0

i dont give you a code that change the name :D

 

for change name replace this:

 

// changename

 

to this:

query_sql("UPDATE `char` SET `name` = '" + @name + "' WHERE `char_id` = '" + getcharid(0) + "'");

Share this post


Link to post
Share on other sites
  • 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.

Edited by chiba222

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.