diff options
author | Jesusaves <cpntb1@ymail.com> | 2019-02-10 02:04:18 -0200 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2019-02-10 02:04:18 -0200 |
commit | 36040a2d577264bf8460ae1851ffdac622969381 (patch) | |
tree | 9f022de29c3ebb8b6c53cba98e0990087df016ef /npc/functions/array.txt | |
parent | d3cb22c8ff30ca43549331f602e0798d6f859bb9 (diff) | |
download | serverdata-36040a2d577264bf8460ae1851ffdac622969381.tar.gz serverdata-36040a2d577264bf8460ae1851ffdac622969381.tar.bz2 serverdata-36040a2d577264bf8460ae1851ffdac622969381.tar.xz serverdata-36040a2d577264bf8460ae1851ffdac622969381.zip |
[skip ci] I need more verbosity and control
Diffstat (limited to 'npc/functions/array.txt')
-rw-r--r-- | npc/functions/array.txt | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/npc/functions/array.txt b/npc/functions/array.txt index 1a106175e..4da22b6fe 100644 --- a/npc/functions/array.txt +++ b/npc/functions/array.txt @@ -71,6 +71,24 @@ function script array_find { freeloop(false); return -1; } +// array_find2(<array>, <needle>) +// Simplified version +// if not found it returns -1 + +function script array_find2 { + .@size = getarraysize(getarg(0)); + freeloop(true); + + for (.@i = getarrayindex(getarg(0)); .@i < .@size; ++.@i) { + if (getelementofarray(getarg(0), .@i) == getarg(1)) { + freeloop(false); + return true; + } + } + + freeloop(false); + return -1; +} |