Sasu Posted August 28, 2013 Posted August 28, 2013 I made this function to check if the player is in some colshape in table. function isPlayerWithInZone(source) if source and getElementType(source) == "player" then outputChatBox("TEST1", root) for i,v in ipairs(SXDueloE) do outputChatBox(getElementType(v[1])..", "..getElementType(v[2]), root) if isElementWithinColShape(source, v[2]) then theReturn = true break end end else theReturn = false end return theReturn end And Here when It create the colshape addEventHandler("onResourceStart", resourceRoot, function() for i,v in ipairs(markerPos) do local x,y,z = unpack(v) local marker = createMarker(x, y, z, "cylinder", 2, 255, 0, 0, 100) createBlipAttachedTo(marker, 56) local col = createColSphere(x, y, z, 10) SXDueloE[marker] = {marker, col} end end) My question is why my function return nil?
Moderators IIYAMA Posted August 28, 2013 Moderators Posted August 28, 2013 Line 4: for i,v in pairs(SXDueloE) do That should work reading the table SXDueloE[marker] = {marker, col}
Sasu Posted August 28, 2013 Author Posted August 28, 2013 I think you didnt understand or I am wrong. I want to check in all the colshapes.
Moderators IIYAMA Posted August 28, 2013 Moderators Posted August 28, 2013 you know ipairs can only check numeric stuff? Why are you trying to use ipairs with a table with markers as key?
Sasu Posted August 28, 2013 Author Posted August 28, 2013 you know ipairs can only check numeric stuff?Why are you trying to use ipairs with a table with markers as key? Oh, I didnt know that. So, I have to use 'pairs' ?
Moderators IIYAMA Posted August 28, 2013 Moderators Posted August 28, 2013 np. BTW:(I don't know if you know this, just as extra info) When you want to check if a table is empty, with keys like that. Use: next(table) local myTable = { ["marker"]=true} if #myTable > 0 then outputChatBox("# is working") -- no it isn't end if next(myTable) then outputChatBox("next is working") -- yes it is end
Sasu Posted August 28, 2013 Author Posted August 28, 2013 I hope that this will be helpful in the future. Thank you.
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