chiba222 0 Posted January 22, 2016 (edited) 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 January 22, 2016 by chiba222 Quote Share this post Link to post Share on other sites
0 Kubix 83 Posted January 22, 2016 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 :< 2 butasro and chiba222 reacted to this Quote Share this post Link to post Share on other sites
0 Kubix 83 Posted January 22, 2016 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 Quote Share this post Link to post Share on other sites
0 chiba222 0 Posted January 22, 2016 (edited) Thank you Kubix, but the script doesn't work. After I input the name, the map-server showed this Edited January 22, 2016 by chiba222 Quote Share this post Link to post Share on other sites
0 Kubix 83 Posted January 22, 2016 Change this: query_sql("SELECT name FROM `char` WHERE `name` = '" + @name$, @newName$); to this: query_sql("SELECT name FROM `char` WHERE `name` = " + @name$, @newName$); Quote Share this post Link to post Share on other sites
0 chiba222 0 Posted January 22, 2016 (edited) It showed this TEST123 is the new name I input Edited January 22, 2016 by chiba222 Quote Share this post Link to post Share on other sites
0 Kubix 83 Posted January 22, 2016 lol o.O show me full script:) Quote Share this post Link to post Share on other sites
0 chiba222 0 Posted January 22, 2016 (edited) 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 January 22, 2016 by chiba222 Quote Share this post Link to post Share on other sites
0 chiba222 0 Posted January 22, 2016 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. Quote Share this post Link to post Share on other sites
0 Kubix 83 Posted January 22, 2016 i dont give you a code that change the name for change name replace this: // changename to this: query_sql("UPDATE `char` SET `name` = '" + @name + "' WHERE `char_id` = '" + getcharid(0) + "'"); 2 chiba222 and butasro reacted to this Quote Share this post Link to post Share on other sites
0 chiba222 0 Posted January 22, 2016 (edited) 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 January 22, 2016 by chiba222 Quote Share this post Link to post Share on other sites
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 chiba222Share this post
Link to post
Share on other sites