summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/init.c1
-rw-r--r--src/map/script.c49
-rw-r--r--src/map/script.h1
3 files changed, 51 insertions, 0 deletions
diff --git a/src/map/init.c b/src/map/init.c
index f9378f8..2187a36 100644
--- a/src/map/init.c
+++ b/src/map/init.c
@@ -70,6 +70,7 @@ HPExport void plugin_init (void)
addScriptCommand("l", "s*", l);
addScriptCommand("lg", "s*", lg);
addScriptCommand("requestlang", "v", requestLang);
+ addScriptCommand("requestitem", "v", requestItem);
addScriptCommand("getq", "i", getq);
addScriptCommand("setq", "ii", setq);
addScriptCommand("getnpcdir", "*", getNpcDir);
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;
diff --git a/src/map/script.h b/src/map/script.h
index eb917d7..ce010ff 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -15,6 +15,7 @@ BUILDIN(closeDialog);
BUILDIN(shop);
BUILDIN(getItemLink);
BUILDIN(requestLang);
+BUILDIN(requestItem);
BUILDIN(getq);
BUILDIN(setq);
BUILDIN(getNpcDir);