erisP Posted July 22, 2020 Posted July 22, 2020 client.lua setTimer ( function () local theCol = getElementData(root, "BlockExportCol") function isInColExport () if isElement(theCol) and isElementWithinColShape(localPlayer,theCol) then return true else return false end end function ClientExplosionCFunction() if isInColExport () then cancelEvent () end end addEventHandler("onClientExplosion", root, ClientExplosionCFunction) end , 1000, 1 ) shared.lua BlockVehicle = createColCuboid ( 1573.84900,-1637.5,12, 10,6,6 ) setElementData(root, "BlockExportCol", BlockVehicle) I want to block vehicles in more areas how can I do it?
Moderators IIYAMA Posted July 22, 2020 Moderators Posted July 22, 2020 @erisP Use the (dynamic) element tree. -- server local colshapeParent = createElement("colshapeParent", "blockColshapeParent") local BlockVehicle = createColCuboid ( 1573.84900,-1637.5,12, 10,6,6 ) setElementParent(BlockVehicle, colshapeParent) local BlockVehicle2 = createColCuboid ( 1573.84900,-1637.5,12, 20,6,6 ) setElementParent(BlockVehicle2, colshapeParent) -- client --[[ -- clientside colshapes do local colshapeParent = getElementByID("blockColshapeParent") if colshapeParent then local BlockVehicle2 = createColCuboid ( 1573.84900,-1637.5,12, 20,6,6 ) setElementParent(BlockVehicle2, colshapeParent) end end ]] function isInColExport () local colshapeParent = getElementByID("blockColshapeParent") if colshapeParent then local colshapes = getElementChildren(colshapeParent) for i=1, #colshapes do local colshape = colshapes[i] if isElementWithinColShape(localPlayer, colshape) then return true end end end return false end Untested. Colshapes must be created in the same resource as the parent, clientside/serverside doesn't matter. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Moderators IIYAMA Posted July 24, 2020 Moderators Posted July 24, 2020 @erisP You might want to reply at least (, even if you are not going to do anything with it). 1 Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
erisP Posted July 25, 2020 Author Posted July 25, 2020 (edited) @ IIYAMA successful thanks Edited July 25, 2020 by erisP 1
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