summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-11-15 21:01:23 +0300
committerAndrei Karas <akaras@inbox.ru>2014-11-16 00:03:27 +0300
commitc269e2bb15cfc91fa4e66077f769841fb86ca6ed (patch)
tree7a9100b212c0448718a472b96e5a66324e9d98ae /src
parent5c201b1f0df178d6551210afcec7876f21c73bfe (diff)
downloadplugin-c269e2bb15cfc91fa4e66077f769841fb86ca6ed.tar.gz
plugin-c269e2bb15cfc91fa4e66077f769841fb86ca6ed.tar.bz2
plugin-c269e2bb15cfc91fa4e66077f769841fb86ca6ed.tar.xz
plugin-c269e2bb15cfc91fa4e66077f769841fb86ca6ed.zip
Impliment script command requestLang.
Diffstat (limited to 'src')
-rw-r--r--src/map/init.c2
-rw-r--r--src/map/script.c60
-rw-r--r--src/map/script.h1
3 files changed, 59 insertions, 4 deletions
diff --git a/src/map/init.c b/src/map/init.c
index 3bf987a..f9635b0 100644
--- a/src/map/init.c
+++ b/src/map/init.c
@@ -51,7 +51,7 @@ HPExport void plugin_init (void)
addScriptCommand("l", "s*", l);
addScriptCommandDeprecated("getlang", "", getLang);
addScriptCommandDeprecated("setlang", "i", setLang);
- addScriptCommand("requestlang", "*", dummy);
+ addScriptCommand("requestlang", "v", requestLang);
addScriptCommand("getq", "i", dummyInt);
addScriptCommand("setq", "ii", dummy);
addScriptCommand("getnpcdir", "*", dummyInt);
diff --git a/src/map/script.c b/src/map/script.c
index c8b41ac..1250d1b 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -164,7 +164,7 @@ BUILDIN(getItemLink)
if (script_isstringtype(st, 2))
{
- i_data = itemdb->searchname (script_getstr(st, 2));
+ i_data = itemdb->search_name (script_getstr(st, 2));
}
else
{
@@ -173,7 +173,7 @@ BUILDIN(getItemLink)
}
item_name = (char *) aCalloc (100, sizeof (char));
- TBL_PC *sd = script->rid2sd(st)
+ TBL_PC *sd = script->rid2sd(st);
if (sd)
{
@@ -191,7 +191,7 @@ BUILDIN(getItemLink)
if (i_data)
// +++ after restore lang support need translate here
// sprintf(item_name, "[%s]", lang_pctrans (i_data->jname, sd));
- sprintf(item_name, "[%s]", lang_pctrans (i_data->jname, sd));
+ sprintf(item_name, "[%s]", i_data->jname);
else
sprintf(item_name, "[Unknown Item]");
}
@@ -200,3 +200,57 @@ BUILDIN(getItemLink)
return true;
}
+
+BUILDIN(requestLang)
+{
+ getSD();
+ struct script_data* data;
+ int64 uid;
+ const char* name;
+ int min;
+ int max;
+
+ data = script_getdata(st, 2);
+ if (!data_isreference(data))
+ {
+ ShowError("script:requestlang: not a variable\n");
+ script->reportdata(data);
+ st->state = END;
+ return false;
+ }
+ uid = reference_getuid(data);
+ name = reference_getname(data);
+ min = (script_hasdata(st,3) ? script_getnum(st,3) : script->config.input_min_value);
+ max = (script_hasdata(st,4) ? script_getnum(st,4) : script->config.input_max_value);
+
+ 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, 0);
+ clif->scriptinputstr(sd, st->oid);
+ }
+ else
+ {
+ // take received text/value and store it in the designated variable
+ sd->state.menu_or_input = 0;
+
+ int lng = -1;
+ if (*sd->npc_str)
+ {
+ lng = 3;
+// +++ after restore lang support need translate here
+// lng = lang_getId(sd->npc_str);
+ }
+ script->set_reg(st, sd, uid, name, (void*)h64BPTRSIZE(lng), script_getref(st,2));
+ st->state = RUN;
+ }
+ return true;
+}
+
diff --git a/src/map/script.h b/src/map/script.h
index d9f2f2d..55104dc 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -14,5 +14,6 @@ BUILDIN(npcTalk3);
BUILDIN(closeDialog);
BUILDIN(shop);
BUILDIN(getItemLink);
+BUILDIN(requestLang);
#endif // EVOL_MAP_SCRIPT