SpecT Posted January 18, 2016 Share Posted January 18, 2016 (edited) Hey guys! Well the topic name says it all. I'm filling a table with serials that have more than 1 accounts registered to. But then it inserts the same serial once, twice or more (depends on accounts count). I tried some ways to prevent this but none of them worked. I even used the code provided from arezu here: https://forum.multitheftauto.com/viewtopic.php?f=91&t=40652&p=412597&hilit=table+duplicated#p414513 But it removes just some duplicates and the other stay there. So yeah .. I need help. Thanks in advance! Edited January 18, 2016 by Guest Link to comment
Addlibs Posted January 18, 2016 Share Posted January 18, 2016 You can check whether a value is already within the table using this function function in_table(haystack, needle) for k, v in pairs(haystack) do -- if your table has standard auto-generated keys, you can change 'pairs' to 'pairs' (it might be less CPU intensive that way, but I'm not sure) if v == needle then return true, k -- returns true along with the key at which the value is first found end end return false -- not found, returns false end Link to comment
SpecT Posted January 18, 2016 Author Share Posted January 18, 2016 Wow. That worked like a charm! Thanks man! #Solved 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