diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-11-15 18:19:44 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-11-15 18:54:08 +0300 |
commit | 5c201b1f0df178d6551210afcec7876f21c73bfe (patch) | |
tree | 3a704fe8e58166b6e1a09ed8896b425367073d5d /src | |
parent | e48ddae488b467c169682d5ce926b28936afa7be (diff) | |
download | evol-hercules-5c201b1f0df178d6551210afcec7876f21c73bfe.tar.gz evol-hercules-5c201b1f0df178d6551210afcec7876f21c73bfe.tar.bz2 evol-hercules-5c201b1f0df178d6551210afcec7876f21c73bfe.tar.xz evol-hercules-5c201b1f0df178d6551210afcec7876f21c73bfe.zip |
Impliment script function getItemLink.
Diffstat (limited to 'src')
-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 |