Jump to content

[Help] createColCuboid


erisP

Recommended Posts

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?

Link to comment
  • Moderators

@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.

 

 

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...