diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-11-29 19:29:51 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-11-29 19:29:51 +0300 |
commit | 8c1ade72e6e44aa73b3609dbcb6eb07bae59c2b9 (patch) | |
tree | 0f9046863f75dc622e71a42a35f4974007af1dea /src/map/script.c | |
parent | 7d9fb1c5c1101fc1fc0afaa2508c842cedbf1a5a (diff) | |
download | plugin-8c1ade72e6e44aa73b3609dbcb6eb07bae59c2b9.tar.gz plugin-8c1ade72e6e44aa73b3609dbcb6eb07bae59c2b9.tar.bz2 plugin-8c1ade72e6e44aa73b3609dbcb6eb07bae59c2b9.tar.xz plugin-8c1ade72e6e44aa73b3609dbcb6eb07bae59c2b9.zip |
Add script function for request item from player to npc.
New script command: requestitem .@var
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/map/script.c b/src/map/script.c index 1f629bd..55b6cc4 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -249,6 +249,55 @@ BUILDIN(requestLang) return true; } +BUILDIN(requestItem) +{ + getSD(); + struct script_data* data; + int64 uid; + const char* name; + + data = script_getdata(st, 2); + if (!data_isreference(data)) + { + ShowError("script:requestitem: not a variable\n"); + script->reportdata(data); + st->state = END; + return false; + } + uid = reference_getuid(data); + name = reference_getname(data); + + if (is_string_variable(name)) + return false; + + if (!sd->state.menu_or_input) + { + // first invocation, display npc input box + sd->state.menu_or_input = 1; + st->state = RERUNLINE; + + // send lang request + send_npccommand(script->rid2sd(st), st->oid, 10); + } + else + { + // take received text/value and store it in the designated variable + sd->state.menu_or_input = 0; + + int item = 0; + + if (!sd->npc_str) + return false; + + if (sscanf (sd->npc_str, "%5d", &item) < 1) + return false; + + script->set_reg(st, sd, uid, name, (void*)h64BPTRSIZE(item), script_getref(st,2)); + st->state = RUN; + } + return true; +} + BUILDIN(setq) { int i; |