diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-11-23 19:32:40 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-11-23 19:32:40 +0300 |
commit | 40f0847e0faff7526c4290b83b50f9237c1e1438 (patch) | |
tree | 4b18f20e2e2416af341853a373e450ba3548da47 /src/map/script.c | |
parent | bf50409735647a80a7145def628822d5235ea753 (diff) | |
download | plugin-40f0847e0faff7526c4290b83b50f9237c1e1438.tar.gz plugin-40f0847e0faff7526c4290b83b50f9237c1e1438.tar.bz2 plugin-40f0847e0faff7526c4290b83b50f9237c1e1438.tar.xz plugin-40f0847e0faff7526c4290b83b50f9237c1e1438.zip |
Partially impliment script command countitemcolor.
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/map/script.c b/src/map/script.c index 2bc9422..efb53a9 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -382,3 +382,43 @@ BUILDIN(rif) return true; } + +BUILDIN(countItemColor) +{ + int nameid, i; + int count = 0; + struct item_data* id = NULL; + + TBL_PC* sd = script->rid2sd(st); + if (!sd) + return true; + + if (script_isstringtype(st, 2)) + { + // item name + id = itemdb->search_name(script_getstr(st, 2)); + } + else + { + // item id + id = itemdb->exists(script_getnum(st, 2)); + } + + if (id == NULL) + { + ShowError("buildin_countitem: Invalid item '%s'.\n", script_getstr(st,2)); // returns string, regardless of what it was + script_pushint(st,0); + return false; + } + + nameid = id->nameid; + + for(i = 0; i < MAX_INVENTORY; i++) + { + if(sd->status.inventory[i].nameid == nameid) + count += sd->status.inventory[i].amount; + } + + script_pushint(st, count); + return true; +} |