diff options
-rw-r--r-- | src/map/init.c | 2 | ||||
-rw-r--r-- | src/map/script.c | 46 | ||||
-rw-r--r-- | src/map/script.h | 1 |
3 files changed, 48 insertions, 1 deletions
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 |