Jump to content

how to get near elements?


mrvicio

Recommended Posts

Function: getElementsInRadius

  
table getElementsInRadius( float Radius,element toEl,[ string el ] ) 
  

Required Arguments

  • Radius:Radius.
  • toEl:Element

Optional Arguments

  • el:Elements are in the distance ("player", "object" etc) to see..

Return

Returns a table with elements that are in range.

function getElementsInRadius( Radius,toEl,el ) 
    if type( Radius ) == "number" and type( toEl ) == "userdata" then 
        local Table = { } 
        local x,y,_ = getElementPosition( toEl ) 
        local shape = createColCircle ( x,y,Radius ) 
         
        local function _getElementsWithinColShape ( shape,el ) 
            if not el then 
                return getElementsWithinColShape( shape ) 
            end 
            return getElementsWithinColShape( shape,el ) 
        end 
         
        for _,v in ipairs( _getElementsWithinColShape( shape,el ) ) do 
            table.insert( Table,v ) 
        end 
        return Table 
    end 
    return false 
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...