summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-11-29 19:49:35 +0300
committerAndrei Karas <akaras@inbox.ru>2014-11-29 19:49:35 +0300
commit73b8dc48525960683da90286112e6740b3758101 (patch)
treee202c369f0aaece4d541f7221222e8585a353e47 /src/map
parent8c1ade72e6e44aa73b3609dbcb6eb07bae59c2b9 (diff)
downloadevol-hercules-73b8dc48525960683da90286112e6740b3758101.tar.gz
evol-hercules-73b8dc48525960683da90286112e6740b3758101.tar.bz2
evol-hercules-73b8dc48525960683da90286112e6740b3758101.tar.xz
evol-hercules-73b8dc48525960683da90286112e6740b3758101.zip
Add script command for request multiply items from client to npc.
New script command: requestItems .@var$ [,count]
Diffstat (limited to 'src/map')
-rw-r--r--src/map/init.c1
-rw-r--r--src/map/script.c55
-rw-r--r--src/map/script.h1
3 files changed, 56 insertions, 1 deletions
diff --git a/src/map/init.c b/src/map/init.c
index 2187a36..fb91cfe 100644
--- a/src/map/init.c
+++ b/src/map/init.c
@@ -71,6 +71,7 @@ HPExport void plugin_init (void)
addScriptCommand("lg", "s*", lg);
addScriptCommand("requestlang", "v", requestLang);
addScriptCommand("requestitem", "v", requestItem);
+ addScriptCommand("requestitems", "v*", requestItems);
addScriptCommand("getq", "i", getq);
addScriptCommand("setq", "ii", setq);
addScriptCommand("getnpcdir", "*", getNpcDir);
diff --git a/src/map/script.c b/src/map/script.c
index 55b6cc4..9cb26c5 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -276,7 +276,7 @@ BUILDIN(requestItem)
sd->state.menu_or_input = 1;
st->state = RERUNLINE;
- // send lang request
+ // send item request
send_npccommand(script->rid2sd(st), st->oid, 10);
}
else
@@ -298,6 +298,59 @@ BUILDIN(requestItem)
return true;
}
+BUILDIN(requestItems)
+{
+ 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;
+
+ int count = 1;
+
+ if (script_hasdata(st, 3))
+ {
+ count = script_getnum(st, 3);
+ if (count < 0)
+ count = 1;
+ }
+
+ if (!sd->state.menu_or_input)
+ {
+ // first invocation, display npc input box
+ sd->state.menu_or_input = 1;
+ st->state = RERUNLINE;
+
+ // send item request with limit count
+ send_npccommand2(script->rid2sd (st), st->oid, 10, count, 0, 0);
+ }
+ else
+ {
+ // take received text/value and store it in the designated variable
+ sd->state.menu_or_input = 0;
+
+ if (!sd->npc_str)
+ return false;
+
+ script->set_reg(st, sd, uid, name, (void*)sd->npc_str, 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 ce010ff..3a8ef8b 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -16,6 +16,7 @@ BUILDIN(shop);
BUILDIN(getItemLink);
BUILDIN(requestLang);
BUILDIN(requestItem);
+BUILDIN(requestItems);
BUILDIN(getq);
BUILDIN(setq);
BUILDIN(getNpcDir);