From 8a43be3ad6c70a866338ffcebe5fe40392dd23cd Mon Sep 17 00:00:00 2001 From: gumi Date: Tue, 12 May 2020 18:19:14 -0400 Subject: add a function shorthand to convert a char name to id --- npc/functions/main.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'npc') diff --git a/npc/functions/main.txt b/npc/functions/main.txt index e4c4cd88..81204400 100644 --- a/npc/functions/main.txt +++ b/npc/functions/main.txt @@ -6,6 +6,25 @@ // Description: // Build in functions. +/** + * checks whether the given argument is a char name or account id + * and tries to convert it to an account id + * + * @arg 0 - char name or account id + * @return the account id + */ +function script nameid2id { + if (getdatatype(getarg(0, "")) & DATATYPE_STR != 0) { + if (getarg(0, "") == "") { + return playerattached(); + } else { + return getcharid(CHAR_ID_ACCOUNT, getarg(0)); + } + } else { + return getarg(0); + } +} + function script menuimage { return getarg(0) + "|" + getarg(1); } -- cgit v1.2.3-70-g09d2