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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

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