blob: 6535ea22414a4f3b8c662609b8f1cf1820d54067 (
plain) (
tree)
|
|
// @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); // 12 = Pay changed.
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;
}
|