Cosmotonio
New Member
- Joined
- Nov 26, 2007
- Messages
- 142
- Reaction score
- 0
How to use isInArray?
table = {"First", "Second", "Third"}
check = isInArray(table, "Second")
check2 = isInArray(table, "NotIn")
print(check, check2)
-- Function by Colandus
function isInArray(t, v, c)
v = (c ~= nil and string.lower(v)) or v
if type(t) == "table" and v ~= nil then
for key, value in pairs(t) do
value = (c ~= nil and string.lower(value)) or value
if v == value then
return 1
end
end
end
return -1
end
table = {"First", "Second", "Third"}
check = isInArray(table, "Second")
check2 = isInArray(table, "THIRD")
print(check, check2)
-- Using my isInArray (in global.lua)
table = {"First", "Second", "Third", "4th Fourth"}
check = isInArray(table, "4th Fourth")
check2 = isInArray(table, "THIRD", true)
print(check, check2)
tilex = {120, 121, 122, 123, 124, 125, 126, 127, 128, 129}
tiley = {32, 33, 34, 35, 36, 37, 38, 39}
tilez = {9}
if (isInArray(tilex, getPlayerPosition(cid).x) == TRUE) and (isInArray(tiley, getPlayerPosition(cid).y) == TRUE) and (isInArray(tilez, getPlayerPosition(cid).z) == TRUE) and getCreatureHealth(cid) < 1 then
arena = TRUE
else
arena = FALSE
end
local position = {fromx=120, fromy=32, tox=129, toy=39, z=9}
function onUse(cid, item, frompos, item2, topos)
for i = position.fromx, position.tox do
for j = position.fromy, position.toy do
local pos = {x=i, y=j, z=position.z, stackpos=253}
local getThing = getThingfromPos(pos).uid
if isPlayer(getThing) == 1 then
//Player found, return a value to break the loop.
end
end
end
return FALSE
end