• Tables don't Love me
    2 replies, posted
Making a private zone addon, which works to a degree. Everything works appart from this. If I try and add a buddy to it (/invite monkstick will add me to the buddy table) it stops working correctly. I know exactly why, just not how to fix it. [CODE] function PrivateZone() MunerisFriends = table.ToString(TableFriends,"table1") MunerisFriends = MunerisFriends.." " --PrintMessage(HUD_PRINTTALK,MunerisFriends) if(IsValid(MunerisHoloprop))then local orgin_ents = ents.FindInSphere( MunerisHoloprop:GetPos(), 1000 ) for k,v in pairs (orgin_ents) do if(IsValid(v)) then if(v:GetClass()=="player") then TempMunPlayer = v:Nick() TempMunPlayerUser = v for k,v in pairs(TableFriends) do -- This is the problem part. its looking key by key for that player. I don't know how to search the whole table, then do this, v != TempMunPlayer then table.insert(KillTable,TempMunPlayerUser) if v != TempMunPlayer then table.insert(KillTable,TempMunPlayerUser) else end end end end end end for k,v in pairs(KillTable) do if(IsValid(v) and v:Alive()) then v:Kill() end end end [/CODE] What im basically asking is, how do I search the WHOLE table first, then do v != TempMunPlayer then table.insert(KillTable,TempMunPlayerUser) if there not found, not just if there not found in that specific key.
table.HasValue(yourtable, value)? for id, ply in pairs(yourtable) do end? yourtable[key] ?
My god do I feel like an idiot now. I never realised HasValue existed, and yes I have been using the wiki. Its like my bible. I just somehow skimmed over that. I will try this now and report back! [editline]28th June 2013[/editline] I can confirm that I am an idiot!, I mean, that it worked perfectly! Whilst we are here, could you point me towards something that can explain using "sub variables". eg: if I want to make a private zone for me and 2 others, I can use table.insert(TableFriends.PLAYERTHATMADEIT,ply:Nick()) I dont quite understand how the variable.subvariable works, thanks!
Sorry, you need to Log In to post a reply to this thread.