• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved isInArray problem

Aeronx

Intermediate OT User
Joined
Dec 17, 2015
Messages
736
Solutions
9
Reaction score
121
Hello all!

I've been doing many test, but i've been totally unsuccessful.

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
   local it = ItemType(itemEx.itemid)
   for h = 2375, 2378 do
   j = h
   print(j)
   print(isInArray(j, itemEx.itemid))
   print("-----")
   print(itemEx.itemid)
   if isInArray(j, itemEx.itemid) == true then
   doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You cannot upgrade items dropped from monsters.")
   end
   end

And i get these prints:
Code:
2375
false
-----
2376
2376
false
-----
2376
2377
false
-----
2376
2378
false
-----
2376

to my understanding isInArray(table, value to search in table). As you can see on the prints 2376 false ------- 2376 should be true, why it isnt? >.<

Thank you for your help and time!
 
Solution
Maybe this?​
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
   local id = itemEx.itemid
   if (id >= 100 and id <= 26509) then
      doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "blalbalba")
   end
end
Yeah that far i know, but the actual problem is that j = 100 ... 26000 (I just used 2375, 2378 for testing purposes and printing)
And i cant really spend HOURS to write 26000 numbers >.<

I was trying to turn this for j = 100, 26000 do into a table so the array would work.
 
Yeah that far i know, but the actual problem is that j = 100 ... 26000 (I just used 2375, 2378 for testing purposes and printing)
And i cant really spend HOURS to write 26000 numbers >.<

I was trying to turn this for j = 100, 26000 do into a table so the array would work.
What are you actually trying to do then?
Maybe there is a better solution.

But if your only comparing 1 number at a time..

Code:
local x = itemEx.itemid
for i = 100, 26000 do
   if i == x then
       - - some code
       break
   end
end
 
When using this onUse on a item that its id is equal to one of this ids (100...26509) return cancel msg
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
   h = {100, 101,...26509)
   if isInArray(h, itemEx.itemid) then
      doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "blalbalba")
   end
end
I want to exclude ALL those ids from being used on.
 
Maybe this?​
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
   local id = itemEx.itemid
   if (id >= 100 and id <= 26509) then
      doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "blalbalba")
   end
end
 
Solution
When using this onUse on a item that its id is equal to one of this ids (100...26509) return cancel msg
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
   h = {100, 101,...26509)
   if isInArray(h, itemEx.itemid) then
      doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "blalbalba")
   end
end
I want to exclude ALL those ids from being used on.
Oh, is that all?
Since you know all of the values from x through y, just evaluate it.
Code:
if itemEx.itemid > 100 and itemEx.itemid < 26509 then
   -- cancel 
end
Maybe this?​
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
   local id = itemEx.itemid
   if (id >= 100 and id <= 26509) then
      doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "blalbalba")
   end
end
aha, see this guy get's it
 
LoL you are right! I didnt think about that.. damn.. so easy! <.<

Im just really tired today!

Thank you guys!
 
Back
Top