Jump to content

Return nil


Sasu

Recommended Posts

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?

Link to comment
  • Moderators

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 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...