diff options
author | gumi <git@gumi.ca> | 2020-05-12 18:19:14 -0400 |
---|---|---|
committer | gumi <git@gumi.ca> | 2020-07-20 11:06:49 -0400 |
commit | 8a43be3ad6c70a866338ffcebe5fe40392dd23cd (patch) | |
tree | 4bb0425b56e041be1fad88830679aac0478ea919 /npc | |
parent | 619ec9cab33d944be272e075bcc57b5c86e39e1b (diff) | |
download | serverdata-8a43be3ad6c70a866338ffcebe5fe40392dd23cd.tar.gz serverdata-8a43be3ad6c70a866338ffcebe5fe40392dd23cd.tar.bz2 serverdata-8a43be3ad6c70a866338ffcebe5fe40392dd23cd.tar.xz serverdata-8a43be3ad6c70a866338ffcebe5fe40392dd23cd.zip |
add a function shorthand to convert a char name to id
Diffstat (limited to 'npc')
-rw-r--r-- | npc/functions/main.txt | 19 |
1 files changed, 19 insertions, 0 deletions
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); } |