Cadell Posted July 11, 2015 Share Posted July 11, 2015 hi i am making a spawn panel thing but having problem with matching 2 table data with each other and only show result which get match i am using this c = { {"Los Santos"}, {"Las Venture"} } t = { {"Squads",0,0,150,"Los Santos"}, {"Gangs",150,0,0,"Las Venture"} } s = { {"F.B.I HQ",133.933,-85.56,1.45,"270","1,20",0,255,0,"Everyone","23.25","information22","Squads"}, {"B-Crew",133.933,-85.56,1.45,"270","1,20",0,255,0,"Everyone","23.25","information23","Squads"} } i want to match that s table squads with t table if that match show result which have that same entry and same i want for t with c table . I am doing this in client file local cities = {} for i,v in ipairs(c) do cityname = v[1] cities[cityname] = {} for i,v in ipairs(t) do classname = v[1] cities[cityname][classname] = {} for i,v in ipairs(s) do skinName = v[1] cities[cityname][classname][skinName] = {} cities[cityname][classname][skinName]["spawnX"] = v[2] cities[cityname][classname][skinName]["spawnY"] = v[3] cities[cityname][classname][skinName]["spawnZ"] = v[4] cities[cityname][classname][skinName]["rot"] = v[5] cities[cityname][classname][skinName]["r"] = v[7] cities[cityname][classname][skinName]["g"] = v[8] cities[cityname][classname][skinName]["b"] = v[9] cities[cityname][classname][skinName]["skins"] = {} local skinID = v[6] cities[cityname][classname][skinName]["skins"] = split(skinID, ",") cities[cityname][classname][skinName]["permission"] = v[10] cities[cityname][classname][skinName]["weapons"] = v[11] cities[cityname][classname][skinName]["information"] = v[12] cities[cityname][classname][skinName]["team"] = v[13] end end end On class click function local selectedRow, selectedCol = guiGridListGetSelectedItem( cityGridList ); local cityName = guiGridListGetItemText( cityGridList, selectedRow, selectedCol ) local selectedRow, selectedCol = guiGridListGetSelectedItem( classGridList ); gridlist local className = guiGridListGetItemText( classGridList, selectedRow, selectedCol ) local classSkins = cities[cityName][className] for i, v in pairs(classSkins) do local row = guiGridListAddRow(spawnGridList) guiGridListSetItemText(spawnGridList, row, 1, i, false, false) end Really want it as fast as possible fixed please help me Link to comment
Cadell Posted July 12, 2015 Author Share Posted July 12, 2015 (edited) Any 1 plz help i really want this working --- Help plz Edited July 12, 2015 by Guest Link to comment
xXMADEXx Posted July 12, 2015 Share Posted July 12, 2015 What exactly is the problem? Link to comment
Cadell Posted July 12, 2015 Author Share Posted July 12, 2015 I want to compare t table 1st entry with s table last entry and set that result in grid and same i want for t table with c table its like city-》select class-> result which have that class and all data in grid Link to comment
iMr.Dawix~# Posted July 12, 2015 Share Posted July 12, 2015 i don't know what you mean but, try this local cities = {} for _,v in ipairs(c) do cityname = v[1] cities[cityname] = {} for i,ev in ipairs(t) do classname = ev[1] cities[cityname][classname] = {} for i,dv in ipairs(s) do skinName = dv[1] cities[cityname][classname][skinName] = {} cities[cityname][classname][skinName]["spawnX"] = dv[2] cities[cityname][classname][skinName]["spawnY"] = dv[3] cities[cityname][classname][skinName]["spawnZ"] = dv[4] cities[cityname][classname][skinName]["rot"] = dv[5] cities[cityname][classname][skinName]["r"] = dv[7] cities[cityname][classname][skinName]["g"] = dv[8] cities[cityname][classname][skinName]["b"] = dv[9] cities[cityname][classname][skinName]["skins"] = {} local skinID = dv[6] cities[cityname][classname][skinName]["skins"] = split(skinID, ",") cities[cityname][classname][skinName]["permission"] = dv[10] cities[cityname][classname][skinName]["weapons"] = dv[11] cities[cityname][classname][skinName]["information"] = dv[12] cities[cityname][classname][skinName]["team"] = dv[13] end end end Link to comment
Cadell Posted July 12, 2015 Author Share Posted July 12, 2015 Thanks but i want to compare 1 tablr value with other and then specific take that value which matches Link to comment
Cadell Posted July 12, 2015 Author Share Posted July 12, 2015 here is my table structure ^^ here is how all stuff store in tables ^^ But working is wrong i want if i select Los Santos then it show me only team name squads not gangs as i want it to come under las venture like under s table at last its defined where this spawn need to come but i dont know how to compare and show matched data. i get result like this at the moment Please help me Link to comment
Perfect Posted July 18, 2015 Share Posted July 18, 2015 Is this what you want ? c = { {"Los Santos"}, {"Las Venture"} } t = { {"Squads",0,0,150,"Los Santos"}, {"Gangs",150,0,0,"Las Venture"} } s = { {"F.B.I HQ",133.933,-85.56,1.45,"270","1,20",0,255,0,"Everyone","23.25","information22","Squads"}, {"B-Crew",133.933,-85.56,1.45,"270","1,20",0,255,0,"Everyone","23.25","information23","Squads"} } gridct = {} gridts = {} for i=1,#c do for i1, v1 in ipairs(c[i]) do for i2,v2 in ipairs(t[i]) do if v1 == v2 then table.insert(gridct, v1) end end end end for i=1,#t do for i1, v1 in ipairs(t[i]) do for i2,v2 in ipairs(s[i]) do if v1 == v2 then table.insert(gridts, v1) end end end end Now: gridct = { "Los Santos", "Los Venture"} gridts = { "Squads",0,0,0,0,0,0,0} And also its pretty useless to put a table inside the 'c' table as it has only single value , unless you are planning to put more values later. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now