Posted 27 January 2014 - 12:18 AM
So I am having a problem with a nested for loop in my command. The purpose of this code is to compare the players inventory with a list of items on a SQL server. All the functions by itself works fine, but if I try to compare them like this it will only grab it if it is in the first position in my inventory.
if sellItems[1] ~= nil then
for i=1, #sellItems do
sell = ocgui.newMenuItem()
item = tostring(sellItems[i].RawName)
for j=1, #sItemsTable do
check = tostring(sItemsTable[j].rawName)
if (item == check) then
dNameS = tostring(sItemsTable[j].dspName)
if(string.find(dNameS, "%s") ~= nil and string.len(dNameS) > 8) then
dNameS= string.sub(dNameS, 1, 2).."."..string.sub(dNameS, string.find(dNameS, "%s"), -1)
dNameS= string.sub(dNameS, 1, 8)
end
sell:newName(dNameS)
sell:newType("sellItem")
sell:newColour(colors.white)
sell:setData(sItemsTable[j])
table.insert(sMenuItemList, sell)
table.insert(sItemsList, sellItems[i])
end
end
end
else
invPlayer = 0
end
Edited on 26 January 2014 - 11:37 PM