From 5c201b1f0df178d6551210afcec7876f21c73bfe Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 15 Nov 2014 18:19:44 +0300 Subject: Impliment script function getItemLink. --- src/map/init.c | 2 +- src/map/script.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ src/map/script.h | 1 + 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/map/init.c b/src/map/init.c index eaa99a6..3bf987a 100644 --- a/src/map/init.c +++ b/src/map/init.c @@ -47,7 +47,7 @@ HPExport void plugin_init (void) addScriptCommand("npctalk3", "s", npcTalk3); addScriptCommand("closedialog", "", closeDialog); addScriptCommand("shop", "s", shop); - addScriptCommand("getitemlink", "s", dummyStr); + addScriptCommand("getitemlink", "s", getItemLink); addScriptCommand("l", "s*", l); addScriptCommandDeprecated("getlang", "", getLang); addScriptCommandDeprecated("setlang", "i", setLang); diff --git a/src/map/script.c b/src/map/script.c index 1671f5c..c8b41ac 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -154,3 +154,49 @@ BUILDIN(shop) clif->npcbuysell (sd, nd->bl.id); return true; } + +BUILDIN(getItemLink) +{ + struct item_data *i_data; + char *item_name; + struct script_data *data; + int item_id = 0; + + if (script_isstringtype(st, 2)) + { + i_data = itemdb->searchname (script_getstr(st, 2)); + } + else + { + item_id = script_getnum (st, 2); + i_data = itemdb->search (item_id); + } + + item_name = (char *) aCalloc (100, sizeof (char)); + TBL_PC *sd = script->rid2sd(st) + + if (sd) + { + if (i_data) +// +++ after restore lang support need translate here +// sprintf(item_name, "[@@%u|%s@@]", (unsigned)i_data->nameid, lang_pctrans (i_data->jname, sd)); + sprintf(item_name, "[@@%u|%s@@]", (unsigned)i_data->nameid, i_data->jname); + else if (item_id > 0) + sprintf(item_name, "[@@%u|Unknown Item@@]", (unsigned)item_id); + else + sprintf(item_name, "[Unknown Item]"); + } + else + { + 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)); + else + sprintf(item_name, "[Unknown Item]"); + } + + script_pushstr(st, item_name); + + return true; +} diff --git a/src/map/script.h b/src/map/script.h index 8d929f9..d9f2f2d 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -13,5 +13,6 @@ BUILDIN(restoreCam); BUILDIN(npcTalk3); BUILDIN(closeDialog); BUILDIN(shop); +BUILDIN(getItemLink); #endif // EVOL_MAP_SCRIPT -- cgit v1.2.3-70-g09d2