Jump to content

[Help] createColCuboid


erisP

Recommended Posts

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

@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 

  Tutorials  4x 

 

  • Moderators
Posted

@erisP

You might want to reply at least (, even if you are not going to do anything with it).

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   ?

 

  Useful functions  3x 

  Tutorials  4x 

 

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