#Black_Hawk Posted April 30, 2017 Posted April 30, 2017 (edited) Hello guys, I'm having a little problem with this code, The problem is when every new object created it should give it new valid it that is not used by another object the id will be Number. NOTE: i'm using a 'split' cause i need it in the whole code. My code: local object = createObject (3095, 1557.835, 1575.586, 10.820) setElementID (object, "1,Object") function getFreeID () local id = 0 for _,v in ipairs (getElementsByType ("object", resourceRoot)) do local data = split (getElementID (v), ",") for i = 0, #getElementsByType ("object", resourceRoot) + 1 do if (data[1] == i) then id = id + 1 end end end return id end Edited April 30, 2017 by #Black_Hawk
Simple. Posted May 2, 2017 Posted May 2, 2017 use tonumber like this if ( tonumber ( data[1] ) == i ) then
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