summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-01-01 22:24:17 +0300
committerAndrei Karas <akaras@inbox.ru>2015-01-01 22:24:17 +0300
commit3242c560742518770c6ea97db03bf89d314cb963 (patch)
tree107e7868125bb67034e0ef3a9ef2101007420033 /src/map/script.c
parentdc7c6e13e5535e4fe78bb84f9920347880022327 (diff)
downloadplugin-3242c560742518770c6ea97db03bf89d314cb963.tar.gz
plugin-3242c560742518770c6ea97db03bf89d314cb963.tar.bz2
plugin-3242c560742518770c6ea97db03bf89d314cb963.tar.xz
plugin-3242c560742518770c6ea97db03bf89d314cb963.zip
Add script function for unequip item by id.
New script function: unequipbyid ID
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 79e6043..d225052 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -706,8 +706,33 @@ BUILDIN(getMapName)
if (!sd || sd->bl.m == -1)
{
script_pushstr(st, aStrdup(""));
- return 1;
+ return false;
}
script_pushstr(st, aStrdup(map->list[sd->bl.m].name));
- return 0;
+ return true;
+}
+
+BUILDIN(unequipById)
+{
+ int nameid = 0;
+ int i;
+ struct item_data *item_data;
+ TBL_PC *sd = script->rid2sd(st);
+
+ if (sd == NULL)
+ return false;
+
+ nameid = script_getnum(st, 2);
+ if((item_data = itemdb->exists(nameid)) == NULL)
+ return false;
+ for (i = 0; i < EQI_MAX; i++)
+ {
+ const int idx = sd->equip_index[i];
+ if (idx >= 0)
+ {
+ if (sd->status.inventory[idx].nameid == nameid)
+ pc->unequipitem(sd, idx, 1 | 2);
+ }
+ }
+ return true;
}