summaryrefslogtreecommitdiff
path: root/src/map/script.c
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/script.c
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/script.c')
-rw-r--r--src/map/script.c55
1 files changed, 54 insertions, 1 deletions
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;