diff options
-rw-r--r-- | npc/commands/force-rename.txt | 46 | ||||
-rw-r--r-- | npc/scripts.conf | 1 |
2 files changed, 47 insertions, 0 deletions
diff --git a/npc/commands/force-rename.txt b/npc/commands/force-rename.txt new file mode 100644 index 00000000..82ba46eb --- /dev/null +++ b/npc/commands/force-rename.txt @@ -0,0 +1,46 @@ +// @charrename/@forcerename atcommand +// FORCEFULLY renames a char. Collision is handled by SQL. +// +// group lv: 80+ +// group char lv: 80+ +// log: True +// +// usage: npc/commands/force-rename.txt +// @charrename New Nickname +// #forcerename "char" <Nickname> +// + +- script @charrename 32767,{ + end; + +OnRename: + // array size validation + if (getarraysize(.@atcmd_parameters$) <= 0) { + dispbottom("Syntax requires argument between 3 and 30 chars long."); + end; + } + // Set new nickname + .@nickname$ += implode(.@atcmd_parameters$, " "); + .@nickname$ = strip(.@nickname$); + // Empty nickname + if (.@nickname$ == "" || .@nickname$ == "NULL") + end; + // Too long or too short nickname + if (getstrlen(.@nickname$) > 30 || getstrlen(.@nickname$) < 3) + end; + // Attempt to rename. If name is taken, will fail at SQL query + dispbottom l("Your nickname has been redefined by GM Team."); + .@id=getcharid(3); + .@n$=strcharinfo(0); + detachrid(); + kick(.@id, 12); + sleep(25); + query_sql(sprintf("UPDATE `char` SET `name`='%s' WHERE `name`='%s'", escape_sql(.@nickname$), escape_sql(.@n$))); + debugmes "[SUCCESS] char %s renamed to %s", .@n$, .@nickname$; + end; + +OnInit: + bindatcmd "charrename", "@charrename::OnRename", 80, 80, 1; + bindatcmd "forcerename", "@charrename::OnRename", 80, 80, 1; + end; +} diff --git a/npc/scripts.conf b/npc/scripts.conf index b2c936e3..6ad4e69b 100644 --- a/npc/scripts.conf +++ b/npc/scripts.conf @@ -94,6 +94,7 @@ // Commands "npc/commands/debug-quest.txt", "npc/commands/debug.txt", +"npc/commands/force-rename.txt", "npc/commands/gm.txt", "npc/commands/ipcheck.txt", "npc/commands/language.txt", |