Jump to content

isElementWithinColShape | HELP!


Annas

Recommended Posts

All i need is:

- If object created out of ColShape, then destroy it

But it's not working..

-- FirstFile.slua (server side)

  
local SmallTest = createColRectangle(1982, -2574, 60, 60 )  
  
function isObjectWithinCityZone(object) 
    if (not (getElementType(object) == "object")) then return false end 
        if (isElementWithinColShape(object, SmallTest)) then return true end 
    return false 
end 

-- SecondFile.slua (server side)

  
function CSTmapEditorMouseClick(button, state, el, wX, wY, wZ) 
        local object = createObject(model, wX, wY, wZ) 
        if (not (isObjectWithinCityZone(object))) then 
        destroyElement(object) 
        end 
end 
  

Notice: it should be 2 files.

Link to comment

since the isObjectWithinCityZone function is in the 1stfile. and you're calling the function "isObjectWithinCityZone" in the second file. which the function "isObjectWithinCityZone" is located in 1st file , functions aren't globally shared in resources.

Link to comment

Just be sure the second file is declared in the meta.xml, that's all.

local SmallTest = createColRectangle ( 1982, -2574, 60, 60 ) 
  
function isObjectWithinCityZone ( object ) 
    if ( object and not getElementType ( object ) == "object" ) then  
        return false  
    end 
     
    if isElementWithinColShape ( object, SmallTest ) then  
        return true  
    end 
end 

Second code:

function CSTmapEditorMouseClick ( button, state, el, wX, wY, wZ ) 
    local object = createObject ( model, wX, wY, wZ ) 
    if isElement ( object ) then  
        if ( not isObjectWithinCityZone ( object ) ) then    
            destroyElement ( object ) 
        end 
    end  
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...